FluentMigrator迁移失败不回滚吗? [英] FluentMigrator Failed Migrations Don't Rollback?

查看:160
本文介绍了FluentMigrator迁移失败不回滚吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始尝试使用 FluentMigrator .我注意到失败的迁移没有被回滚.难道这还没有实现吗?这似乎很糟糕,因为它使数据库处于损坏状态.

I just began experimenting with FluentMigrator. 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.

例如,当第二次尝试添加Table1时,下面的迁移显然会失败(我只是这样做以强制执行错误).我希望迁移将包含在事务中,然后在失败时将回滚.

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");
    }
}

但是,发生的是转轮抛出一个错误(这会导致控制台应用程序崩溃),并且数据库保留了创建的Table1,而VersionInfo表中没有任何行.丢东西似乎是一种糟糕的状态.

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.

使用最新的FluentMigrator代码(截至今天),Visual Studio 2008并针对SQL Server 2008 Express进行操作.

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

推荐答案

对交易的支持在1月26日添加了.

这篇关于FluentMigrator迁移失败不回滚吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆