FluentMigrator 失败的迁移不回滚?

发布于 2024-08-19 07:11:41 字数 722 浏览 3 评论 0原文

我刚刚开始尝试 FluentMigrator。我注意到失败的迁移不会被回滚。这还没有实施吗?这看起来相当糟糕,因为它使数据库处于损坏状态。

例如,当第二次尝试添加 Table1 时,下面的迁移显然会失败(我这样做只是为了强制发生错误)。我希望迁移包含在一个事务中,然后在失败时回滚。

[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 表中没有任何行。这似乎是一个不好的状态。

使用最新的 FluentMigrator 代码(截至今天)、Visual Studio 2008 并反对 SQL Server 2008 Express。

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2024-08-26 07:11:41

Support for transactions was added on Jan. 26.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文