diff --git a/yuniql-cli/CommandLineService.cs b/yuniql-cli/CommandLineService.cs index 63c4b6cd..ef4c95f9 100644 --- a/yuniql-cli/CommandLineService.cs +++ b/yuniql-cli/CommandLineService.cs @@ -247,7 +247,7 @@ public int RunInfoOption(InfoOption opts) //get all exsiting db versions var migrationService = _migrationServiceFactory.Create(opts.Platform); migrationService.Initialize(opts.ConnectionString, opts.CommandTimeout); - var versions = migrationService.GetAllVersions(opts.Schema, opts.Table); + var versions = migrationService.GetAllVersions(opts.MetaSchema, opts.MetaTable); var results = new StringBuilder(); results.AppendLine($"Version\t\tCreated\t\t\t\tCreatedBy"); diff --git a/yuniql-cli/InfoOption.cs b/yuniql-cli/InfoOption.cs index 7cc4add4..7e6bdcbb 100644 --- a/yuniql-cli/InfoOption.cs +++ b/yuniql-cli/InfoOption.cs @@ -6,12 +6,12 @@ namespace Yuniql.CLI [Verb("info", HelpText = "Shows all the migrations applied to target database.")] public class InfoOption : BasePlatformOption { - //yuniql --schema "yuniql" - [Option("schema", Required = false, HelpText = "Schema name for schema versions table.")] - public string Schema { get; set; } + //yuniql --meta-schema "yuniql" + [Option("meta-schema", Required = false, HelpText = "Schema name for schema versions table.")] + public string MetaSchema { get; set; } //yuniql --table "__yuniqlschemaversions" - [Option("table", Required = false, HelpText = "Table name for schema versions table.")] - public string Table { get; set; } + [Option("meta-table", Required = false, HelpText = "Table name for schema versions table.")] + public string MetaTable { get; set; } } } diff --git a/yuniql-core/ConfigurationDataService.cs b/yuniql-core/ConfigurationDataService.cs index e988f4d6..bc7117d8 100644 --- a/yuniql-core/ConfigurationDataService.cs +++ b/yuniql-core/ConfigurationDataService.cs @@ -75,10 +75,10 @@ public void CreateDatabase(int? commandTimeout = null) } /// - public void CreateSchema(string schemaName, int? commandTimeout = null) + public void CreateSchema(string metaSchemaName, int? commandTimeout = null) { var tokens = new List> { - new KeyValuePair(RESERVED_TOKENS.YUNIQL_SCHEMA_NAME, schemaName), + new KeyValuePair(RESERVED_TOKENS.YUNIQL_SCHEMA_NAME, metaSchemaName), }; var sqlStatement = _tokenReplacementService.Replace(tokens, _dataService.GetSqlForCreateSchema()); using (var connection = _dataService.CreateConnection()) @@ -93,11 +93,11 @@ public void CreateSchema(string schemaName, int? commandTimeout = null) /// public bool IsDatabaseConfigured( - string schemaName = null, - string tableName = null, + string metaSchemaName = null, + string metaTableName = null, int? commandTimeout = null) { - var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForCheckIfDatabaseConfigured(), schemaName, tableName); + var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForCheckIfDatabaseConfigured(), metaSchemaName, metaTableName); using (var connection = _dataService.CreateConnection()) { return connection.QuerySingleBool( @@ -110,11 +110,11 @@ public bool IsDatabaseConfigured( /// public void ConfigureDatabase( - string schemaName = null, - string tableName = null, + string metaSchemaName = null, + string metaTableName = null, int? commandTimeout = null) { - var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForConfigureDatabase(), schemaName, tableName); + var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForConfigureDatabase(), metaSchemaName, metaTableName); using (var connection = _dataService.CreateConnection()) { connection.ExecuteNonQuery( @@ -127,24 +127,24 @@ public void ConfigureDatabase( /// public bool UpdateDatabaseConfiguration( - string schemaName = null, - string tableName = null, + string metaSchemaName = null, + string metaTableName = null, int? commandTimeout = null) { using (var connection = _dataService.CreateConnection()) { connection.KeepOpen(); - return _dataService.UpdateDatabaseConfiguration(connection, _traceService, schemaName, tableName); + return _dataService.UpdateDatabaseConfiguration(connection, _traceService, metaSchemaName, metaTableName); } } /// public string GetCurrentVersion( - string schemaName = null, - string tableName = null, + string metaSchemaName = null, + string metaTableName = null, int? commandTimeout = null) { - var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForGetCurrentVersion(), schemaName, tableName); + var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForGetCurrentVersion(), metaSchemaName, metaTableName); using (var connection = _dataService.CreateConnection()) { return connection.QuerySingleString( @@ -157,11 +157,11 @@ public string GetCurrentVersion( /// public List GetAllAppliedVersions( - string schemaName = null, - string tableName = null, + string metaSchemaName = null, + string metaTableName = null, int? commandTimeout = null) { - return this.GetAllVersions(schemaName, tableName, commandTimeout) + return this.GetAllVersions(metaSchemaName, metaTableName, commandTimeout) .Where(x => x.Status == Status.Successful).ToList(); } diff --git a/yuniql-core/IConfigurationDataService.cs b/yuniql-core/IConfigurationDataService.cs index e0e73b05..1591bbec 100644 --- a/yuniql-core/IConfigurationDataService.cs +++ b/yuniql-core/IConfigurationDataService.cs @@ -25,59 +25,59 @@ public interface IConfigurationDataService /// /// Returns true when migration version tracking table is already created. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. - /// Table name for schema versions table. When empty, uses __yuniqldbversion. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Table name for schema versions table. When empty, uses __yuniqldbversion. /// Command timeout in seconds. /// Returns true when version tracking table is already created. - bool IsDatabaseConfigured(string schemaName, string tableName, int? commandTimeout = null); + bool IsDatabaseConfigured(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// /// Creates schema in target databases. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. /// Command timeout in seconds. - void CreateSchema(string schemaName, int? commandTimeout = null); + void CreateSchema(string metaSchemaName, int? commandTimeout = null); /// /// Creates migration version tracking table in the target database. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. - /// Table name for schema versions table. When empty, uses __yuniqldbversion. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Table name for schema versions table. When empty, uses __yuniqldbversion. /// Command timeout in seconds. - void ConfigureDatabase(string schemaName, string tableName, int? commandTimeout = null); + void ConfigureDatabase(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// /// Updates migration version tracking table in the target database.. /// /// True if target database was updated, otherwise returns false - bool UpdateDatabaseConfiguration(string schemaName, string tableName, int? commandTimeout = null); + bool UpdateDatabaseConfiguration(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// /// Returns the latest version applied in the target database. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. - /// Table name for schema versions table. When empty, uses __yuniqldbversion. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Table name for schema versions table. When empty, uses __yuniqldbversion. /// Command timeout in seconds. /// Returns the latest version applied in the target database. - string GetCurrentVersion(string schemaName, string tableName, int? commandTimeout = null); + string GetCurrentVersion(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// /// Returns all versions applied in the target database. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. - /// Table name for schema versions table. When empty, uses __yuniqldbversion. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Table name for schema versions table. When empty, uses __yuniqldbversion. /// Command timeout in seconds. /// All versions applied in the target database. - public List GetAllAppliedVersions(string schemaName, string tableName, int? commandTimeout = null); + public List GetAllAppliedVersions(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// /// Returns all versions applied in the target database. /// - /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. - /// Table name for schema versions table. When empty, uses __yuniqldbversion. + /// Schema name for schema versions table. When empty, uses the default schema in the target data platform. + /// Table name for schema versions table. When empty, uses __yuniqldbversion. /// Command timeout in seconds. /// All versions applied in the target database. - List GetAllVersions(string schemaName, string tableName, int? commandTimeout = null); + List GetAllVersions(string metaSchemaName, string metaTableName, int? commandTimeout = null); /// diff --git a/yuniql-core/MigrationServiceBase.cs b/yuniql-core/MigrationServiceBase.cs index 9039257b..1bb43b6a 100644 --- a/yuniql-core/MigrationServiceBase.cs +++ b/yuniql-core/MigrationServiceBase.cs @@ -51,16 +51,16 @@ public virtual void Initialize( } /// - public virtual string GetCurrentVersion(string schemaName = null, string tableName = null) + public virtual string GetCurrentVersion(string metaSchemaName = null, string metaTableName = null) { - return _configurationDataService.GetCurrentVersion(schemaName, tableName); + return _configurationDataService.GetCurrentVersion(metaSchemaName, metaTableName); } /// //TODO: Move this to MigrationServiceBase - public virtual List GetAllVersions(string schemaName = null, string tableName = null) + public virtual List GetAllVersions(string metaSchemaName = null, string metaTableName = null) { - return _configurationDataService.GetAllAppliedVersions(schemaName, tableName); + return _configurationDataService.GetAllAppliedVersions(metaSchemaName, metaTableName); } /// @@ -82,10 +82,10 @@ public abstract void Run( ); /// - public virtual bool IsTargetDatabaseLatest(string targetVersion, string schemaName = null, string tableName = null) + public virtual bool IsTargetDatabaseLatest(string targetVersion, string metaSchemaName = null, string metaTableName = null) { //get the current version stored in database - var remoteCurrentVersion = _configurationDataService.GetCurrentVersion(schemaName, tableName); + var remoteCurrentVersion = _configurationDataService.GetCurrentVersion(metaSchemaName, metaTableName); if (string.IsNullOrEmpty(remoteCurrentVersion)) return false; //compare version applied in db vs versions available locally diff --git a/yuniql-tests/platform-tests/Cli/CliTests.cs b/yuniql-tests/platform-tests/Cli/CliTests.cs index 6017f78a..e30c7b96 100644 --- a/yuniql-tests/platform-tests/Cli/CliTests.cs +++ b/yuniql-tests/platform-tests/Cli/CliTests.cs @@ -126,11 +126,11 @@ public void Test_Cli_verify_With_Custom_Schema(string command, string arguments) SetupWorkspaceWithSampleDb(); //act & assert - var result = _executionService.Run("run", _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "-a -t v0.00 --schema \"my_schema\" --table \"my_versions\" "); + var result = _executionService.Run("run", _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "-a -t v0.00 --meta-schema \"my_schema\" --meta-table \"my_versions\" "); result.Contains($"Failed to execute run").ShouldBeFalse(); //act & assert - result = _executionService.Run(command, _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "--schema \"my_schema\" --table \"my_versions\" " +arguments); + result = _executionService.Run(command, _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "--meta-schema \"my_schema\" --meta-table \"my_versions\" " + arguments); result.Contains($"Failed to execute {command}").ShouldBeFalse(); } @@ -162,11 +162,11 @@ public void Test_Cli_info_With_Custom_Schema(string command, string arguments) SetupWorkspaceWithSampleDb(); //act & assert - var result = _executionService.Run("run", _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "-a --schema \"my_schema\" --table \"my_versions\" -d"); + var result = _executionService.Run("run", _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "-a --meta-schema \"my_schema\" --meta-table \"my_versions\" -d"); result.Contains($"Failed to execute run").ShouldBeFalse(); //act & assert - result = _executionService.Run(command, _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "--schema \"my_schema\" --table \"my_versions\" " + arguments); + result = _executionService.Run(command, _testConfiguration.WorkspacePath, _testConfiguration.ConnectionString, _testConfiguration.Platform, "--meta-schema \"my_schema\" --meta-table \"my_versions\" " + arguments); result.Contains($"Failed to execute {command}").ShouldBeFalse(); }