开发者

FluentMigrator Failed Migrations Don't Rollback?

开发者 https://www.devze.com 2022-12-17 03:16 出处:网络
I just began experimenting with Fl开发者_StackOverflowuentMigrator. I noticed that failed migrations are not being rolled back. Has this just not been implemented yet? This seems rather bad because it

I just began experimenting with Fl开发者_StackOverflowuentMigrator. I noticed that failed migrations are not being rolled back. Has this just not been implemented yet? This seems rather bad because it leaves the database in a broken state.

For example, the migration below will obviously fail when it tries to add Table1 for a second time (I'm just doing this to force an error). I would expect the migration to be contained in a transaction which would then be rolled back when it fails.

[Migration(1)]
public class AddTable : Migration
{
    public override void Up()
    {
        Create.Table("Table1").WithIdColumn();
        Create.Table("Table1").WithIdColumn();
    }

    public override void Down()
    {
        Delete.Table("Table1");
    }
}

However, what happens instead is that the runner throws an error (which causes the console app to crash) and the database is left with Table1 created and no row in the VersionInfo table. This seems like a bad state to leave things in.

Using latest FluentMigrator code (as of today), Visual Studio 2008 and going against SQL Server 2008 Express.


Support for transactions was added on Jan. 26.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号