forked from fluentmigrator/fluentmigrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Auto Reversing Migrations
daniellee edited this page Jan 14, 2013
·
2 revisions
Auto reversing migrations are migrations that only contain an up command and FluentMigrator figures out the down command. Create a migration class that inherits from AutoReversingMigration (instead of Migration) to use this feature.
[Migration(201207080104)]
public class RenameTableWithSchema : AutoReversingMigration
{
public override void Up()
{
Rename.Table("TestTable2").InSchema("TestSchema").To("TestTable'3");
}
}
FluentMigrator can automatically figure out the down command and revert the rename. However, not all expressions are supported for auto reversing. For example, using the Execute expression to execute an sql script is impossible to reverse. Expressions that are currently supported for auto reversing are:
- Create.Table
- Create.Column
- Create.Index
- Create.ForeignKey
- Create.Schema
- Delete.ForeignKey
- Rename.Table
- Rename.Column
- Getting FluentMigrator
- How to create a Migration
- Fluent Interface
- Migration Runners
- Use inbuilt database functions when setting the default value
- Sql Server Specific Extensions
- Raw Sql Helper for inserting data
- Auto Reversing Migrations
- Resharper File Template
- Transaction Modes for the Migration Runner
- ApplicationContext: Passing parameters to Migrations
- Dealing with Multiple Database Types
- Filter migrations run based on Tags
- Enforce migration version numbering rules
- Create custom metadata for the VersionInfo table