As it stands today, the database is a separate entity completely separate from the application

  1. Manual database changes (large environment, error prone)
  2. Using an inefficient manual comparison method to manage changes between database versions (time-consuming and error-prone)
  3. Database changes cannot be shared with other members of the team
  4. Inconsistencies occur when the code does not commit updates at the same time as the DDL or DML

The realization form

Database changes are stored in XML, where a change (ChangSet) is uniquely identified by author and ID. Save the DatabaseChangeHistory in the database and automatically skip the applied changes when the database is upgraded

The following steps are required to start using LiquiBase

  1. Create a change log file liquibase-data. XML liquibase-table. XML liquibase-view. XML
  2. Create a change set inside the change log file
<changeSet id="2018100801" author="wangshuo">
        <sql>
            update t_system_dict a set  a.can_update = '0',a.can_del = '0' where a.groupcode = 'ZD_SKFS' and a.dictcode = '4'; </ SQL > <comment> T_system_dict Network teaching cannot be deleted and modified </comment> </changeSet>Copy the code
  1. Commit change sets synchronously when committing code
  2. Run change sets through Jenkins updates
  3. Verify changes in the database
  4. Verify the correctness of program functions

ChangeSet Maintenance description

  1. Select the script to place in the corresponding XML file
  2. ID naming rule: Date + two-digit serial number
  3. The author indicated
  4. Context Settings need to be updated or not updated to the specified environment note: Omit the context Settings when you do not need to specify them
  5. Multiple SQL can be maintained at a time
  6. Comment specifies the corresponding implementation function and script implementation purpose

The sample

<changeSet id="2018100801" author="wangshuo" context=! "" jwgly and ! beta and ! test"/context="jwgly,beta">
    <sql>
        update t_system_dict a set  a.can_update = '0',a.can_del = '0' where a.groupcode = 'ZD_SKFS' and a.dictcode = '4'; </ SQL > <comment> T_system_dict Network teaching cannot be deleted and modified </comment> </changeSet>Copy the code