Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 2.43 KB

README.md

File metadata and controls

78 lines (50 loc) · 2.43 KB

GBIF Registry Persistence

This module includes persistence related functionality: Liquibase migration scripts and MyBatis mapper interfaces\xml.

Create

Create an empty PostgreSQL database. Name of the created database should be identical in these places:

Update

Update database manually by liquibase-maven-plugin (use values for db.url, db.username, db.password):

mvn liquibase:update -Dliquibase.url=<db.url> -Dliquibase.username=<db.username> -Dliquibase.password=<db.password>

Run script under registry-persistence directory.

In case of exception:

Error setting up or running Liquibase: liquibase.exception.SetupException: liquibase/some-changelog.xml does not exist

run the following maven command:

mvn process-resources

DB on the environments (dev, uat, prod) are updated automatically on application startup.

Rollback

Each changeset should contain rollback section:

<changeSet id="testRollback" author="programmer">
    <createTable tableName="user">
        <column name="id" type="int"/>
        <column name="username" type="varchar(36)"/>
        <column name="age" type="integer"/>
    </createTable>
    <rollback>
        <dropTable tableName="user"/>
    </rollback>
</changeSet>

in order to be able to rollback changes automatically in case of exception.

Rollback may be also performed manually. There are several ways to do that.

By count:

mvn liquibase:rollback -Dliquibase.rollbackCount=1 -Dliquibase.url=<db.url> -Dliquibase.username=<db.username> -Dliquibase.password=<db.password>

rollbackCount is a parameter which defines how many changeset will be rolled back.

or by date:

mvn liquibase:rollback "-Dliquibase.rollbackDate=Oct 18, 2020" -Dliquibase.url=<db.url> -Dliquibase.username=<db.username> -Dliquibase.password=<db.password>

rollbackDate is a parameter which defines date; any changeset executed after that day will be rolled back (including the date).

Parent