Class DefaultRevisionManager

  • All Implemented Interfaces:
    pro.fessional.wings.faceless.flywave.InteractiveManager , pro.fessional.wings.faceless.flywave.SchemaRevisionManager

    
    public final class DefaultRevisionManager
     implements SchemaRevisionManager
                        

    Manage database version based on the names of the tables (including shard tables).

    Since:

    2019-06-05

    Author:

    trydofor

    • Method Detail

      • addDropRegexp

         final Unit addDropRegexp(String regexp)

        Add a RegExp to match drop statement.

        Parameters:
        regexp - RegExp
      • publishRevision

         Unit publishRevision(Long revision, Long commitId)

        Publish the given revision to the database, possibly cascading upgrades or downgrades. If there is an inconsistency between the start and end points or a breakpoint, write to the log and skip the execution.

        A breakpoint, a discontinuous APPLY state, is an abnormal or inserting state. When upgrading, the start point must be APPLY and the end point must NOT be APPLY. When downgrading, the start point and the end points must be APPLY, ignoring the un-APPLY breakpoints in between.

        Be careful with backup data when downgrading, the data or table may be deleted.

        Parameters:
        revision - To this version, i.e.
        commitId - commit id of Journal
      • forceApplyBreak

         Unit forceApplyBreak(Long revision, Long commitId, Boolean isUpto, String dataSource)

        Force to run a breakpoint script (script only, no cascading upgrades or downgrades), usually to fix an abnormal operation.

        Parameters:
        revision - To this version, i.e.
        commitId - commit id of Journal
        isUpto - upto or undo, default upto(true).
        dataSource - name of datasource to execute, null means all
      • checkAndInitSql

         Unit checkAndInitSql(SortedMap<Long, SchemaRevisionManager.RevisionSql> sqls, Long commitId, Boolean updateDiff)

        Compare the SQL between in local and in database. If not initialized, run the REVISION_1ST_SCHEMA revision. If it does not exist, then save local to database. If it exists but the contents are not the same and has been APPLY then log error, otherwise update it.

        Parameters:
        sqls - sql in local
        commitId - commit id of Journal
        updateDiff - Whether to auto update inconsistent sql, default false.
      • forceUpdateSql

         Unit forceUpdateSql(Long revision, String upto, String undo, Long commitId)

        Force to insert/update the local SQL to the management table if inconsistent (do nothing if consistent)

        Parameters:
        revision - revision
        upto - upgrade sql text
        undo - downgrade sql text
        commitId - commit id of Journal
      • forceExecuteSql

         Unit forceExecuteSql(String text)

        Force to execute a sql with flywave syntax, but no versioning, no stateful logging and checking.

        Parameters:
        text - sql text