You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 25, 2021. It is now read-only.
Find the MigratePlugins method within the Global.asax.cs file
Find this section:
// Iterate each assembly that contains plugin migrationsforeach(varassemblyMigrationsinassemblies){try{// Get the versions that have already been installedvarinstalledVersions=pluginMigrationService.Queryable().Where( m =>m.PluginAssemblyName==assemblyMigrations.Key).ToList();// Iterate each migration in the assembly in MigrationNumber orderforeach(varmigrationTypeinassemblyMigrations.Value.OrderBy( t =>t.Key)){// Check to make sure migration has not already been runif(!installedVersions.Any( v =>v.MigrationNumber==migrationType.Key)){using(varsqlTxn=con.BeginTransaction()){booltransactionActive=true;try{// Create an instance of the migration and run the up migrationvarmigration=Activator.CreateInstance(migrationType.Value)asRock.Plugin.Migration;migration.SqlConnection=con;migration.SqlTransaction=sqlTxn;migration.Up();sqlTxn.Commit();transactionActive=false;// Save the plugin migration version so that it is not run againvarpluginMigration=newPluginMigration();pluginMigration.PluginAssemblyName=assemblyMigrations.Key;pluginMigration.MigrationNumber=migrationType.Key;pluginMigration.MigrationName=migrationType.Value.Name;pluginMigrationService.Add(pluginMigration);rockContext.SaveChanges();result=true;}catch(Exceptionex){if(transactionActive){sqlTxn.Rollback();}thrownewException(string.Format("Plugin Migration error occurred in {0}, {1}",assemblyMigrations.Key,migrationType.Value.Name),ex);}}}}}catch(Exceptionex){// If an exception occurs in an an assembly, log the error, and continue with next assemblyLogError(ex,null);}}
Change this line foreach ( var migrationType in assemblyMigrations.Value.OrderBy( t => t.Key ) ) to be foreach ( var migrationType in assemblyMigrations.Value.Where( t => t.Name == "MIGRATION_NAME_HERE" ) )
Change this migration.Up(); to migration.Down();
Delete this section:
// Save the plugin migration version so that it is not run againvarpluginMigration=newPluginMigration();pluginMigration.PluginAssemblyName=assemblyMigrations.Key;pluginMigration.MigrationNumber=migrationType.Key;pluginMigration.MigrationName=migrationType.Value.Name;pluginMigrationService.Add(pluginMigration);rockContext.SaveChanges();
After testing locally, change your database connection strings to point to the database server you wish to modify, such as staging.
Run it.
Remove record from PluginMigrations table so that the migration's up will run again if desired.
Do not commit your changes to the Global.asax.cs file or gremlins will destroy your car.