/// <summary> /// Initializes the Merchell Migrations. /// </summary> /// <param name="migrations"> /// The migrations. /// </param> /// <param name="database"> /// The database. /// </param> /// <param name="databaseProvider"> /// The database provider. /// </param> /// <param name="isUpgrade"> /// The is upgrade. /// </param> /// <returns> /// The <see cref="MerchelloMigrationContext"/>. /// </returns> internal MerchelloMigrationContext InitializeMigrations(List <IMigration> migrations, Database database, DatabaseProviders databaseProvider, bool isUpgrade = true) { //Loop through migrations to generate sql var context = new MerchelloMigrationContext(databaseProvider, database, _logger); foreach (var migration in migrations) { var baseMigration = migration as MerchelloMigrationBase; if (baseMigration != null) { if (isUpgrade) { baseMigration.GetUpExpressions(context); _logger.Info <CoreMigrationManager>(string.Format("Added UPGRADE migration '{0}' to context", baseMigration.GetType().Name)); } else { baseMigration.GetDownExpressions(context); _logger.Info <CoreMigrationManager>(string.Format("Added DOWNGRADE migration '{0}' to context", baseMigration.GetType().Name)); } } else { //this is just a normal migration so we can only call Up/Down if (isUpgrade) { migration.Up(); _logger.Info <MigrationRunner>(string.Format("Added UPGRADE migration '{0}' to context", migration.GetType().Name)); } else { migration.Down(); _logger.Info <MigrationRunner>(string.Format("Added DOWNGRADE migration '{0}' to context", migration.GetType().Name)); } } } return(context); }
/// <summary> /// Initializes the Merchell Migrations. /// </summary> /// <param name="migrations"> /// The migrations. /// </param> /// <param name="database"> /// The database. /// </param> /// <param name="databaseProvider"> /// The database provider. /// </param> /// <param name="isUpgrade"> /// The is upgrade. /// </param> /// <returns> /// The <see cref="MerchelloMigrationContext"/>. /// </returns> internal MerchelloMigrationContext InitializeMigrations(List<IMigration> migrations, Database database, DatabaseProviders databaseProvider, bool isUpgrade = true) { //Loop through migrations to generate sql var context = new MerchelloMigrationContext(databaseProvider, database, _logger); foreach (var migration in migrations) { var baseMigration = migration as MerchelloMigrationBase; if (baseMigration != null) { if (isUpgrade) { baseMigration.GetUpExpressions(context); _logger.Info<CoreMigrationManager>(string.Format("Added UPGRADE migration '{0}' to context", baseMigration.GetType().Name)); } else { baseMigration.GetDownExpressions(context); _logger.Info<CoreMigrationManager>(string.Format("Added DOWNGRADE migration '{0}' to context", baseMigration.GetType().Name)); } } else { //this is just a normal migration so we can only call Up/Down if (isUpgrade) { migration.Up(); _logger.Info<MigrationRunner>(string.Format("Added UPGRADE migration '{0}' to context", migration.GetType().Name)); } else { migration.Down(); _logger.Info<MigrationRunner>(string.Format("Added DOWNGRADE migration '{0}' to context", migration.GetType().Name)); } } } return context; }