简体   繁体   English

FluentMigrator - 它如何知道要执行哪个迁移

[英]FluentMigrator - how does it know which migration to execute

How does FluentMigrator know what migrations to execute / migrate when you start up the application?当您启动应用程序时,FluentMigrator 如何知道要执行/迁移的迁移?

Example: I got two migrations already performed (1 and 2).示例:我已经执行了两次迁移(1 和 2)。 Now I create a third migration and give it an id of 3 .现在我创建第三个迁移并给它一个 id 3 When I launch my application, FluentMigrator will execute the migrations, but how does it know to skip the first two?当我启动我的应用程序时,FluentMigrator 将执行迁移,但它如何知道跳过前两个?

using FluentMigrator;

namespace test
{
    [Migration(3)]
    public class AddLogTable : Migration
    {
        public override void Up()
        {
            Create.Table("Log")
                .WithColumn("Id").AsInt64().PrimaryKey().Identity()
                .WithColumn("Text").AsString();
        }

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

A table called VersionInfo is created in the database where information about each migration is recorded.在数据库中创建了一个名为 VersionInfo 的表,其中记录了有关每次迁移的信息。 Before applying the migration, a check will be performed to see what records are already in this table.在应用迁移之前,将执行检查以查看此表中已有哪些记录。

It stores all information in “ VersionInfo ” table by default.它默认将所有信息存储在“ VersionInfo ”表中。 Using this information, it can determine what migrations need to be applied to that database and will then execute each migration in succession that it needs to apply.使用此信息,它可以确定需要将哪些迁移应用到该数据库,然后将依次执行需要应用的每个迁移。 Also, you can manage metadata of this table if you need此外,如果需要,您可以管理此表的元数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM