/
Liquibase Docker Testing

Liquibase Docker Testing

Generate changeLog for database

docker run -v /mnt/c/Users/ktimoney/changelog:/liquibase/changelog liquibase/liquibase --driver=org.mariadb.jdbc.Driver --url="jdbc:mariadb://host.docker.internal:3306/policy" --changeLogFile=/liquibase/changelog/dbchangelog.mariadb.yaml --username=policy --password=****** generateChangeLog



Drop and re-create policy database/schema

MariaDB [mysql]> drop database policy;
Query OK, 76 rows affected (0.296 sec)

MariaDB [mysql]> CREATE DATABASE IF NOT EXISTS `policy` ;
Query OK, 1 row affected (0.001 sec)



Apply changeLog 

docker run -v /mnt/c/Users/ktimoney/changelog:/liquibase/changelog liquibase/liquibase --driver=org.mariadb.jdbc.Driver --url="jdbc:mariadb://host.docker.internal:3306/policy" --changeLogFile=dbchangelog.mariadb.yaml --username=policy --password=****** update



Update persistemce.xml

Update :

models-dao/src/test/resources/META-INF/persistence.xml

models-pdp/src/test/resources/META-INF/persistence.xml

models-provider/src/test/resources/META-INF/persistence.xml

models-tosca/src/test/resources/META-INF/persistence.xml

change:

<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />

to

<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />



Test Modules

Run mvn clean install -DUSE-MARIADB on

models-dao: passed

models-pdp: failed

models-provider: passed

models-tosca: failed

Some tests are now failing as tables are not being dropped and re-created so records remain from previous tests.

See MVN Testing Errors for details.





Docker Compose

A docker compose version of the liquibase can be used like so:

docker-compose.yaml
version: '2' services: liquibase: image: liquibase/liquibase container_name: liquibase command: ['--driver=$DRIVER', '--url=$URL', '--changeLogFile=$CHANGELOG', '--username=$USERNAME', '--password=$PASSWORD', '$CMD'] volumes: - /mnt/c/Users/ktimoney/changelog:/liquibase/changelog



Links

Using Liquibase via Docker

ddl-generation



Related content

Liquibase changeLog Testing
Liquibase changeLog Testing
More like this
Liquibase Docker Compose Testing
Liquibase Docker Compose Testing
More like this
Database backup and restore
Database backup and restore
More like this
Allow underlying database to be configured: MariaDB or Postgres
Allow underlying database to be configured: MariaDB or Postgres
More like this
Backup Testing
Backup Testing
More like this
Upgrade/rollback of database tables
Upgrade/rollback of database tables
More like this