diff --git a/yuniql-aspnetcore/YuniqApplicationBuilderExtensions.cs b/yuniql-aspnetcore/YuniqApplicationBuilderExtensions.cs
index bb4bfdcd..779653d5 100644
--- a/yuniql-aspnetcore/YuniqApplicationBuilderExtensions.cs
+++ b/yuniql-aspnetcore/YuniqApplicationBuilderExtensions.cs
@@ -40,15 +40,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.CommandTimeout,
- configuration.BatchSize,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
@@ -76,15 +78,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.BatchSize,
- configuration.CommandTimeout,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
diff --git a/yuniql-aspnetcore/Yuniql.AspNetCore.csproj b/yuniql-aspnetcore/Yuniql.AspNetCore.csproj
index 467720db..c188f8c1 100644
--- a/yuniql-aspnetcore/Yuniql.AspNetCore.csproj
+++ b/yuniql-aspnetcore/Yuniql.AspNetCore.csproj
@@ -22,7 +22,7 @@
-
+
diff --git a/yuniql-aspnetcore/YuniqlConfiguration.cs b/yuniql-aspnetcore/YuniqlConfiguration.cs
index 41e4c998..646cd72e 100644
--- a/yuniql-aspnetcore/YuniqlConfiguration.cs
+++ b/yuniql-aspnetcore/YuniqlConfiguration.cs
@@ -52,7 +52,7 @@ public class YuniqlConfiguration
/// The size of each batch when performing bulk load. Default is 100 rows.
/// This may not be used in non-sqlserver platforms.
///
- public int BatchSize { get; set; } = 100;
+ public int BulkBatchSize { get; set; } = 0;
///
/// The time it taks to wait for one commend to execute before it expires and throws error.
@@ -82,5 +82,15 @@ public class YuniqlConfiguration
/// See https://github.com/rdagumampan/yuniql/wiki/environment-aware-scripts
///
public string Environment { get; set; } = null;
+
+ ///
+ /// Schema name for schema versions table.
+ ///
+ public string MetaSchemaName { get; set; } = null;
+
+ ///
+ /// Table name for schema versions table.
+ ///
+ public string MetaTableName { get; set; } = null;
}
}
diff --git a/yuniql-aspnetcore/YuniqlHostBuilderExtensions.cs b/yuniql-aspnetcore/YuniqlHostBuilderExtensions.cs
index fd170851..29677f40 100644
--- a/yuniql-aspnetcore/YuniqlHostBuilderExtensions.cs
+++ b/yuniql-aspnetcore/YuniqlHostBuilderExtensions.cs
@@ -41,15 +41,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.BatchSize,
- configuration.CommandTimeout,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
@@ -77,15 +79,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.BatchSize,
- configuration.CommandTimeout,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
diff --git a/yuniql-aspnetcore/YuniqlWebHostBuilderExtensions.cs b/yuniql-aspnetcore/YuniqlWebHostBuilderExtensions.cs
index cdef8ff9..d1d05b42 100644
--- a/yuniql-aspnetcore/YuniqlWebHostBuilderExtensions.cs
+++ b/yuniql-aspnetcore/YuniqlWebHostBuilderExtensions.cs
@@ -40,15 +40,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.BatchSize,
- configuration.CommandTimeout,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
@@ -76,15 +78,17 @@ YuniqlConfiguration configuration
migrationService.Run(
configuration.WorkspacePath,
configuration.TargetVersion,
- configuration.AutoCreateDatabase,
- configuration.Tokens,
- configuration.VerifyOnly,
- configuration.BulkSeparator,
- configuration.BatchSize,
- configuration.CommandTimeout,
- configuration.ApplyByTool,
- configuration.ApplyByToolVersion,
- configuration.Environment);
+ autoCreateDatabase: configuration.AutoCreateDatabase,
+ tokens: configuration.Tokens,
+ verifyOnly: configuration.VerifyOnly,
+ bulkSeparator: configuration.BulkSeparator,
+ metaSchemaName: configuration.MetaSchemaName,
+ metaTableName: configuration.MetaTableName,
+ commandTimeout: configuration.CommandTimeout,
+ bulkBatchSize: configuration.BulkBatchSize,
+ appliedByTool: configuration.ApplyByTool,
+ appliedByToolVersion: configuration.ApplyByToolVersion,
+ environmentCode: configuration.Environment);
return builder;
}
diff --git a/yuniql-cli/BaseRunPlatformOption.cs b/yuniql-cli/BaseRunPlatformOption.cs
index dca26193..1d6114de 100644
--- a/yuniql-cli/BaseRunPlatformOption.cs
+++ b/yuniql-cli/BaseRunPlatformOption.cs
@@ -3,7 +3,6 @@
namespace Yuniql.CLI
{
-
public class BaseRunPlatformOption : BasePlatformOption
{
//yuniql -t v1.05 | --target-version v1.05
@@ -31,12 +30,12 @@ public class BaseRunPlatformOption : BasePlatformOption
[Option("environment", Required = false, HelpText = "Environment code for environment-aware scripts.")]
public string Environment { get; set; }
- //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; }
+ //yuniql --meta-table "__yuniqlschemaversions"
+ [Option("meta-table", Required = false, HelpText = "Table name for schema versions table.")]
+ public string MetaTable { get; set; }
}
}
diff --git a/yuniql-cli/CommandLineService.cs b/yuniql-cli/CommandLineService.cs
index 168bf9f5..ef4c95f9 100644
--- a/yuniql-cli/CommandLineService.cs
+++ b/yuniql-cli/CommandLineService.cs
@@ -134,8 +134,8 @@ public int RunMigration(RunOption opts)
tokens: tokens,
verifyOnly: false,
bulkSeparator: opts.BulkSeparator,
- schemaName: opts.Schema,
- tableName: opts.Table,
+ metaSchemaName: opts.MetaSchema,
+ metaTableName: opts.MetaTable,
commandTimeout: opts.CommandTimeout,
bulkBatchSize: opts.BulkBatchSize,
appliedByTool: toolName,
@@ -204,8 +204,8 @@ public int RunVerify(VerifyOption opts)
tokens: tokens,
verifyOnly: true,
bulkSeparator: opts.BulkSeparator,
- schemaName: opts.Schema,
- tableName: opts.Table,
+ metaSchemaName: opts.MetaSchema,
+ metaTableName: opts.MetaTable,
commandTimeout: opts.CommandTimeout,
bulkBatchSize: opts.BulkBatchSize,
appliedByTool: toolName,
@@ -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 15836d53..bc7117d8 100644
--- a/yuniql-core/ConfigurationDataService.cs
+++ b/yuniql-core/ConfigurationDataService.cs
@@ -29,12 +29,12 @@ public ConfigurationDataService(
_tokenReplacementService = tokenReplacementService;
}
- private string GetPreparedSqlStatement(string sqlStatement, string schemaName, string tableName)
+ private string GetPreparedSqlStatement(string sqlStatement, string metaSchemaName, string metaTableName)
{
var tokens = new List> {
new KeyValuePair(RESERVED_TOKENS.YUNIQL_DB_NAME, _dataService.GetConnectionInfo().Database),
- new KeyValuePair(RESERVED_TOKENS.YUNIQL_SCHEMA_NAME, schemaName ?? _dataService.SchemaName),
- new KeyValuePair(RESERVED_TOKENS.YUNIQL_TABLE_NAME, tableName?? _dataService.TableName)
+ new KeyValuePair(RESERVED_TOKENS.YUNIQL_SCHEMA_NAME, metaSchemaName ?? _dataService.SchemaName),
+ new KeyValuePair(RESERVED_TOKENS.YUNIQL_TABLE_NAME, metaTableName?? _dataService.TableName)
};
return _tokenReplacementService.Replace(tokens, sqlStatement);
@@ -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,21 +157,21 @@ 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();
}
///
public List GetAllVersions(
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null)
{
- var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForGetAllVersions(), schemaName, tableName);
+ var sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForGetAllVersions(), metaSchemaName, metaTableName);
_traceService?.Debug($"Executing statement: {Environment.NewLine}{sqlStatement}");
var result = new List();
@@ -223,8 +223,8 @@ public void InsertVersion(
IDbConnection connection,
IDbTransaction transaction,
string version,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
string appliedByTool = null,
string appliedByToolVersion = null,
@@ -255,7 +255,7 @@ public void InsertVersion(
if (_dataService is INonTransactionalFlow nonTransactionalDataService)
{
//override insert statement with upsert when targeting platforms not supporting non-transaction ddl
- sqlStatement = GetPreparedSqlStatement(nonTransactionalDataService.GetSqlForUpsertVersion(), schemaName, tableName);
+ sqlStatement = GetPreparedSqlStatement(nonTransactionalDataService.GetSqlForUpsertVersion(), metaSchemaName, metaTableName);
var status = string.IsNullOrEmpty(failedScriptPath) ? Status.Successful.ToString() : Status.Failed.ToString();
command.Parameters.Add(CreateDbParameter("status", status));
command.Parameters.Add(CreateDbParameter("failedScriptPath", failedScriptPath));
@@ -263,7 +263,7 @@ public void InsertVersion(
}
else
{
- sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForInsertVersion(), schemaName, tableName);
+ sqlStatement = GetPreparedSqlStatement(_dataService.GetSqlForInsertVersion(), metaSchemaName, metaTableName);
}
//upsert version information
diff --git a/yuniql-core/IConfigurationDataService.cs b/yuniql-core/IConfigurationDataService.cs
index 7fbf2d25..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);
///
@@ -86,8 +86,8 @@ public interface IConfigurationDataService
/// Connection to target database. Connection will be open automatically.
/// An active transaction.
/// Migration version.
- /// 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.
/// The source that initiates the migration. This can be yuniql-cli, yuniql-aspnetcore or yuniql-azdevops.
/// The version of the source that initiates the migration.
@@ -98,8 +98,8 @@ void InsertVersion(
IDbConnection connection,
IDbTransaction transaction,
string version,
- string schemaName,
- string tableName,
+ string metaSchemaName,
+ string metaTableName,
int? commandTimeout = null,
string appliedByTool = null,
string appliedByToolVersion = null,
diff --git a/yuniql-core/IMigrationService.cs b/yuniql-core/IMigrationService.cs
index 28eab10c..6bf32267 100644
--- a/yuniql-core/IMigrationService.cs
+++ b/yuniql-core/IMigrationService.cs
@@ -36,8 +36,8 @@ public interface IMigrationService
/// Token kev/value pairs to replace tokens in script files.
/// When TRUE, runs the migration in uncommitted mode. No changes are committed to target database. When NULL, runs migration in atomic mode.
/// Bulk file values separator character in the CSV bulk import files. When NULL, uses comma.
- /// 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. When NULL, it uses default provider command timeout.
/// Batch rows to processed when performing bulk import. When NULL, it uses default provider batch size.
/// The source that initiates the migration. This can be yuniql-cli, yuniql-aspnetcore or yuniql-azdevops.
@@ -51,8 +51,8 @@ void Run(
List> tokens = null,
bool? verifyOnly = null,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -90,8 +90,8 @@ void RunVersionScripts(
NonTransactionalContext nonTransactionalContext,
List> tokenKeyPairs = null,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -117,8 +117,8 @@ void RunSqlScripts(
string version,
string workingPath,
string scriptDirectory,
- string schemaName,
- string tableName,
+ string metaSchemaName,
+ string metaTableName,
List> tokenKeyPairs = null,
int? commandTimeout = null,
string environmentCode = null,
diff --git a/yuniql-core/MigrationService.cs b/yuniql-core/MigrationService.cs
index 2646d04a..ad722f40 100644
--- a/yuniql-core/MigrationService.cs
+++ b/yuniql-core/MigrationService.cs
@@ -58,8 +58,8 @@ public override void Run(
List> tokenKeyPairs = null,
bool? verifyOnly = false,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -107,30 +107,30 @@ public override void Run(
}
//check if database has been pre-configured to support migration and setup when its not
- var targetDatabaseConfigured = _configurationDataService.IsDatabaseConfigured(schemaName, tableName);
+ var targetDatabaseConfigured = _configurationDataService.IsDatabaseConfigured(metaSchemaName, metaTableName);
if (!targetDatabaseConfigured)
{
//create custom schema when user supplied and only if platform supports it
- if (_dataService.IsSchemaSupported && null != schemaName && !_dataService.SchemaName.Equals(schemaName))
+ if (_dataService.IsSchemaSupported && null != metaSchemaName && !_dataService.SchemaName.Equals(metaSchemaName))
{
- _traceService.Info($"Target schema does not exist. Creating schema {schemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
- _configurationDataService.CreateSchema(schemaName);
- _traceService.Info($"Created schema {schemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
+ _traceService.Info($"Target schema does not exist. Creating schema {metaSchemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
+ _configurationDataService.CreateSchema(metaSchemaName);
+ _traceService.Info($"Created schema {metaSchemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
}
//create empty versions tracking table
_traceService.Info($"Target database {targetDatabaseName} on {targetDatabaseServer} not yet configured for migration.");
- _configurationDataService.ConfigureDatabase(schemaName, tableName);
+ _configurationDataService.ConfigureDatabase(metaSchemaName, metaTableName);
_traceService.Info($"Configured database migration support for {targetDatabaseName} on {targetDatabaseServer}.");
}
- var allVersions = _configurationDataService.GetAllVersions(schemaName, tableName)
+ var allVersions = _configurationDataService.GetAllVersions(metaSchemaName, metaTableName)
.Select(dv => dv.Version)
.OrderBy(v => v)
.ToList();
//check if target database already runs the latest version and skips work if it already is
- var targeDatabaseLatest = IsTargetDatabaseLatest(targetVersion, schemaName, tableName);
+ var targeDatabaseLatest = IsTargetDatabaseLatest(targetVersion, metaSchemaName, metaTableName);
if (!targeDatabaseLatest)
{
//enclose all executions in a single transaction, in the event of failure we roll back everything
@@ -206,7 +206,7 @@ void RunAllInternal(IDbConnection connection, IDbTransaction transaction)
_traceService.Info($"Executed script files on {Path.Combine(workingPath, "_pre")}");
//runs all scripts int the vxx.xx folders and subfolders
- RunVersionScripts(connection, transaction, allVersions, workingPath, targetVersion, null, tokenKeyPairs, bulkSeparator: bulkSeparator, schemaName: schemaName, tableName: tableName, commandTimeout: commandTimeout, bulkBatchSize: bulkBatchSize, appliedByTool: appliedByTool, appliedByToolVersion: appliedByToolVersion, environmentCode: environmentCode);
+ RunVersionScripts(connection, transaction, allVersions, workingPath, targetVersion, null, tokenKeyPairs, bulkSeparator: bulkSeparator, metaSchemaName: metaSchemaName, metaTableName: metaTableName, commandTimeout: commandTimeout, bulkBatchSize: bulkBatchSize, appliedByTool: appliedByTool, appliedByToolVersion: appliedByToolVersion, environmentCode: environmentCode);
//runs all scripts in the _draft folder and subfolders
RunNonVersionScripts(connection, transaction, Path.Combine(workingPath, "_draft"), tokenKeyPairs, bulkSeparator: bulkSeparator, commandTimeout: commandTimeout, environmentCode: environmentCode);
@@ -244,8 +244,8 @@ public override void RunVersionScripts(
NonTransactionalContext nonTransactionalContext,
List> tokenKeyPairs = null,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -284,22 +284,22 @@ public override void RunVersionScripts(
scriptSubDirectories.ForEach(scriptSubDirectory =>
{
//run all scripts in the current version folder
- RunSqlScripts(connection, transaction, nonTransactionalContext, versionName, workingPath, scriptSubDirectory, schemaName, tableName, tokenKeyPairs, commandTimeout, environmentCode);
+ RunSqlScripts(connection, transaction, nonTransactionalContext, versionName, workingPath, scriptSubDirectory, metaSchemaName, metaTableName, tokenKeyPairs, commandTimeout, environmentCode);
//import csv files into tables of the the same filename as the csv
RunBulkImport(connection, transaction, workingPath, scriptSubDirectory, bulkSeparator, bulkBatchSize, commandTimeout, environmentCode);
});
//run all scripts in the current version folder
- RunSqlScripts(connection, transaction, nonTransactionalContext, versionName, workingPath, versionDirectory, schemaName, tableName, tokenKeyPairs, commandTimeout, environmentCode);
+ RunSqlScripts(connection, transaction, nonTransactionalContext, versionName, workingPath, versionDirectory, metaSchemaName, metaTableName, tokenKeyPairs, commandTimeout, environmentCode);
//import csv files into tables of the the same filename as the csv
RunBulkImport(connection, transaction, workingPath, versionDirectory, bulkSeparator, bulkBatchSize, commandTimeout, environmentCode);
//update db version
_configurationDataService.InsertVersion(connection, transaction, versionName,
- schemaName: schemaName,
- tableName: tableName,
+ metaSchemaName: metaSchemaName,
+ metaTableName: metaTableName,
commandTimeout: commandTimeout,
appliedByTool: appliedByTool,
appliedByToolVersion: appliedByToolVersion);
@@ -322,8 +322,8 @@ public override void RunSqlScripts(
string version,
string workingPath,
string scriptDirectory,
- string schemaName,
- string tableName,
+ string metaSchemaName,
+ string metaTableName,
List> tokenKeyPairs = null,
int? commandTimeout = null,
string environmentCode = null,
diff --git a/yuniql-core/MigrationServiceBase.cs b/yuniql-core/MigrationServiceBase.cs
index cceafac5..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);
}
///
@@ -71,8 +71,8 @@ public abstract void Run(
List> tokenKeyPairs = null,
bool? verifyOnly = false,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -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
@@ -148,8 +148,8 @@ public abstract void RunVersionScripts(
NonTransactionalContext nonTransactionalContext,
List> tokenKeyPairs = null,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaschemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -189,8 +189,8 @@ public abstract void RunSqlScripts(
string version,
string workingPath,
string scriptDirectory,
- string schemaName,
- string tableName,
+ string metaSchemaName,
+ string metaTableName,
List> tokenKeyPairs = null,
int? commandTimeout = null,
string environmentCode = null,
diff --git a/yuniql-core/NonTransactionalMigrationService.cs b/yuniql-core/NonTransactionalMigrationService.cs
index 1a442b18..a61c869d 100644
--- a/yuniql-core/NonTransactionalMigrationService.cs
+++ b/yuniql-core/NonTransactionalMigrationService.cs
@@ -58,8 +58,8 @@ public override void Run(
List> tokenKeyPairs = null,
bool? verifyOnly = false,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -111,24 +111,24 @@ public override void Run(
}
//check if database has been pre-configured to support migration and setup when its not
- var targetDatabaseConfigured = _configurationDataService.IsDatabaseConfigured(schemaName, tableName);
+ var targetDatabaseConfigured = _configurationDataService.IsDatabaseConfigured(metaSchemaName, metaTableName);
if (!targetDatabaseConfigured)
{
//create custom schema when user supplied and only if platform supports it
- if (_dataService.IsSchemaSupported && null != schemaName && !_dataService.SchemaName.Equals(schemaName))
+ if (_dataService.IsSchemaSupported && null != metaSchemaName && !_dataService.SchemaName.Equals(metaSchemaName))
{
- _traceService.Info($"Target schema does not exist. Creating schema {schemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
- _configurationDataService.CreateSchema(schemaName);
- _traceService.Info($"Created schema {schemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
+ _traceService.Info($"Target schema does not exist. Creating schema {metaSchemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
+ _configurationDataService.CreateSchema(metaSchemaName);
+ _traceService.Info($"Created schema {metaSchemaName} on {targetDatabaseName} on {targetDatabaseServer}.");
}
//create empty versions tracking table
_traceService.Info($"Target database {targetDatabaseName} on {targetDatabaseServer} not yet configured for migration.");
- _configurationDataService.ConfigureDatabase(schemaName, tableName);
+ _configurationDataService.ConfigureDatabase(metaSchemaName, metaTableName);
_traceService.Info($"Configured database migration support for {targetDatabaseName} on {targetDatabaseServer}.");
}
- var targetDatabaseUpdated = _configurationDataService.UpdateDatabaseConfiguration(schemaName, tableName);
+ var targetDatabaseUpdated = _configurationDataService.UpdateDatabaseConfiguration(metaSchemaName, metaTableName);
if (targetDatabaseUpdated)
_traceService.Info($"The configuration of migration has been updated for {targetDatabaseName} on {targetDatabaseServer}.");
else
@@ -137,7 +137,7 @@ public override void Run(
NonTransactionalContext nonTransactionalContext = null;
//check for presence of failed no-transactional versions from previous runs
- var allVersions = _configurationDataService.GetAllVersions(schemaName, tableName);
+ var allVersions = _configurationDataService.GetAllVersions(metaSchemaName, metaTableName);
var failedVersion = allVersions.Where(x => x.Status == Status.Failed).FirstOrDefault();
if (failedVersion != null)
{
@@ -163,13 +163,13 @@ public override void Run(
}
}
- var appliedVersions = _configurationDataService.GetAllAppliedVersions(schemaName, tableName)
+ var appliedVersions = _configurationDataService.GetAllAppliedVersions(metaSchemaName, metaTableName)
.Select(dv => dv.Version)
.OrderBy(v => v)
.ToList();
//checks if target database already runs the latest version and skips work if it already is
- var targeDatabaseLatest = IsTargetDatabaseLatest(targetVersion, schemaName, tableName);
+ var targeDatabaseLatest = IsTargetDatabaseLatest(targetVersion, metaSchemaName, metaTableName);
if (!targeDatabaseLatest)
{
//create a shared open connection to entire migration run
@@ -206,7 +206,7 @@ void RunAllInternal(IDbConnection connection, IDbTransaction transaction)
_traceService.Info($"Executed script files on {Path.Combine(workingPath, "_pre")}");
//runs all scripts int the vxx.xx folders and subfolders
- RunVersionScripts(connection, transaction, appliedVersions, workingPath, targetVersion, nonTransactionalContext, tokenKeyPairs, bulkSeparator: bulkSeparator, schemaName: schemaName, tableName: tableName, commandTimeout: commandTimeout, bulkBatchSize: bulkBatchSize, appliedByTool: appliedByTool, appliedByToolVersion: appliedByToolVersion, environmentCode: environmentCode);
+ RunVersionScripts(connection, transaction, appliedVersions, workingPath, targetVersion, nonTransactionalContext, tokenKeyPairs, bulkSeparator: bulkSeparator, metaSchemaName: metaSchemaName, metaTableName: metaTableName, commandTimeout: commandTimeout, bulkBatchSize: bulkBatchSize, appliedByTool: appliedByTool, appliedByToolVersion: appliedByToolVersion, environmentCode: environmentCode);
//runs all scripts in the _draft folder and subfolders
RunNonVersionScripts(connection, transaction, Path.Combine(workingPath, "_draft"), tokenKeyPairs, bulkSeparator: bulkSeparator, commandTimeout: commandTimeout, environmentCode: environmentCode);
@@ -244,8 +244,8 @@ public override void RunVersionScripts(
NonTransactionalContext nonTransactionalContext,
List> tokenKeyPairs = null,
string bulkSeparator = null,
- string schemaName = null,
- string tableName = null,
+ string metaSchemaName = null,
+ string metaTableName = null,
int? commandTimeout = null,
int? bulkBatchSize = null,
string appliedByTool = null,
@@ -316,7 +316,7 @@ public override void RunVersionScripts(
{
try
{
- RunVersionScriptsInternal(transaction, scriptSubDirectories, transactionDirectory, versionDirectory, schemaName, tableName);
+ RunVersionScriptsInternal(transaction, scriptSubDirectories, transactionDirectory, versionDirectory, metaSchemaName, metaTableName);
transaction.Commit();
_traceService.Info(@$"Target database has been commited after running ""{versionName}"" version scripts.");
@@ -332,7 +332,7 @@ public override void RunVersionScripts(
else
{
//run scripts without transaction
- RunVersionScriptsInternal(transaction, scriptSubDirectories, versionDirectory, versionDirectory, schemaName, tableName);
+ RunVersionScriptsInternal(transaction, scriptSubDirectories, versionDirectory, versionDirectory, metaSchemaName, metaTableName);
}
});
}
@@ -366,8 +366,8 @@ void RunVersionScriptsInternal(IDbTransaction transaction, List scriptSu
//update db version
_configurationDataService.InsertVersion(connection, transaction, versionName,
- schemaName: schemaName,
- tableName: tableName,
+ metaSchemaName: schemaName,
+ metaTableName: tableName,
commandTimeout: commandTimeout,
appliedByTool: appliedByTool,
appliedByToolVersion: appliedByToolVersion);
@@ -390,8 +390,8 @@ public override void RunSqlScripts(
string version,
string workingPath,
string scriptDirectory,
- string schemaName,
- string tableName,
+ string metaSchemaName,
+ string metaTableName,
List> tokenKeyPairs = null,
int? commandTimeout = null,
string environmentCode = null,
@@ -464,8 +464,8 @@ public override void RunSqlScripts(
if (transaction == null)
{
_configurationDataService.InsertVersion(connection, transaction, version,
- schemaName,
- tableName,
+ metaSchemaName: metaSchemaName,
+ metaTableName: metaTableName,
commandTimeout: commandTimeout,
appliedByTool: appliedByTool,
appliedByToolVersion: appliedByToolVersion,
diff --git a/yuniql-tests/platform-tests/Cli/CliTests.cs b/yuniql-tests/platform-tests/Cli/CliTests.cs
index d3b6f720..e30c7b96 100644
--- a/yuniql-tests/platform-tests/Cli/CliTests.cs
+++ b/yuniql-tests/platform-tests/Cli/CliTests.cs
@@ -71,9 +71,9 @@ public void Test_Cli_vnext(string command, string arguments)
[DataRow("run", "-a -d --bulk-batch-size 50")]
[DataRow("run", "-a -d --command-timeout 10")]
[DataRow("run", "-a -d --environment DEV")]
- [DataRow("run", "-a -d --schema \"my_schema\"")]
- [DataRow("run", "-a -d --table \"my_versions\" ")]
- [DataRow("run", "-a -d --schema \"my_schema\" --table \"my_versions\" ")]
+ [DataRow("run", "-a -d --meta-schema \"my_schema\"")]
+ [DataRow("run", "-a -d --meta-table \"my_versions\" ")]
+ [DataRow("run", "-a -d --meta-schema \"my_schema\" --meta-table \"my_versions\" ")]
[DataRow("run", "-a -d -k \"VwColumnPrefix1=Vw1,VwColumnPrefix2=Vw2,VwColumnPrefix3=Vw3,VwColumnPrefix4=Vw4\"")]
[DataRow("run", "-a -d -k \"VwColumnPrefix1=Vw1\" -k \"VwColumnPrefix2=Vw2\" -k \"VwColumnPrefix3=Vw3\" -k \"VwColumnPrefix4=Vw4\"")]
public void Test_Cli_run(string command, string arguments)
@@ -93,9 +93,9 @@ public void Test_Cli_run(string command, string arguments)
[DataRow("verify", "-d --bulk-batch-size 50")]
[DataRow("verify", "-d --command-timeout 10")]
[DataRow("verify", "-d --environment DEV")]
- [DataRow("verify", "-d --schema \"my_schema\"")]
- [DataRow("verify", "-d --table \"my_versions\" ")]
- [DataRow("verify", "-d --schema \"my_schema\" --table \"my_versions\" ")]
+ [DataRow("verify", "-d --meta-schema \"my_schema\"")]
+ [DataRow("verify", "-d --meta-table \"my_versions\" ")]
+ [DataRow("verify", "-d --meta-schema \"my_schema\" --meta-table \"my_versions\" ")]
[DataRow("verify", "-d -k \"VwColumnPrefix1=Vw1,VwColumnPrefix2=Vw2,VwColumnPrefix3=Vw3,VwColumnPrefix4=Vw4\"")]
[DataRow("verify", "-d -k \"VwColumnPrefix1=Vw1\" -k \"VwColumnPrefix2=Vw2\" -k \"VwColumnPrefix3=Vw3\" -k \"VwColumnPrefix4=Vw4\"")]
public void Test_Cli_verify(string command, string arguments)
@@ -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();
}