zoukankan      html  css  js  c++  java
  • How Flyway works

    The easiest scenario is when you point Flyway to an empty database.

    It will try to locate its schema history table. As the database is empty, Flyway won't find it and will create it instead.

    You now have a database with a single empty table called flyway_schema_history by default:

    This table will be used to track the state of the database.

    Immediately afterwards Flyway will begin scanning the filesystem or the classpath of the application for migrations. They can be written in either Sql or Java.

    The migrations are then sorted based on their version number and applied in order:

    As each migration gets applied, the schema history table is updated accordingly:

    flyway_schema_history
    installed_rankversiondescriptiontypescriptchecksuminstalled_byinstalled_onexecution_timesuccess
    1 1 Initial Setup SQL V1__Initial_Setup.sql 1996767037 axel 2016-02-04 22:23:00.0 546 true
    2 2 First Changes SQL V2__First_Changes.sql 1279644856 axel 2016-02-06 09:18:00.0 127 true

    With the metadata and the initial state in place, we can now talk about migrating to newer versions.

    Flyway will once again scan the filesystem or the classpath of the application for migrations. The migrations are checked against the schema history table. If their version number is lower or equal to the one of the version marked as current, they are ignored.

    The remaining migrations are the pending migrations: available, but not applied.

    They are then sorted by version number and executed in order:

    The schema history table is updated accordingly:

    flyway_schema_history
    installed_rankversiondescriptiontypescriptchecksuminstalled_byinstalled_onexecution_timesuccess
    1 1 Initial Setup SQL V1__Initial_Setup.sql 1996767037 axel 2016-02-04 22:23:00.0 546 true
    2 2 First Changes SQL V2__First_Changes.sql 1279644856 axel 2016-02-06 09:18:00.0 127 true
    3 2.1 Refactoring JDBC V2_1__Refactoring   axel 2016-02-10 17:45:05.4 251 true

    And that's it! Every time the need to evolve the database arises, whether structure (DDL) or reference data (DML), simply create a new migration with a version number higher than the current one. The next time Flyway starts, it will find it and upgrade the database accordingly.

  • 相关阅读:
    element-ui 表格实现单元格可编辑的示例
    vue.js数组追加合并与对象追加合并
    Gym 101471G BZOJ 4954 [WF2017]Replicate Replicate Rfplicbte
    Gym 100299E BZOJ 4054 [CERC2013]Escape (启发式合并)
    Gym 101239E BZOJ 4110 [CERC2013]Evolution in Parallel (DP、结论)
    Gym 101221I BZOJ 4080 [WF2014]Sensor Network (二分图匹配)
    Gym 101190D BZOJ 4842 Luogu P6967 LOJ #6071 [NEERC2016]Delight for a Cat (费用流)
    记录一次dubbo不能正常抛出特定异常
    JAVA 类加载机制学习笔记
    JAVA 垃圾回收读书笔记
  • 原文地址:https://www.cnblogs.com/chucklu/p/10538967.html
Copyright © 2011-2022 走看看