From bcd1692541313edb658893d9951ba4867c27ae67 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Tue, 12 Jul 2016 03:00:19 +0200 Subject: [PATCH] Spring JPA: liquibase --- SpringJava/JPA/README | 13 +- SpringJava/JPA/context.xml | 2 +- SpringJava/JPA/pom.xml | 6 + .../datasource-configuration.xml | 2 + .../spring-configuration/liquibase/changeLogs.xml | 19 + .../liquibase/ddlChangelog.xml | 52 + .../liquibase/dmlChangelog.xml | 1960 ++++++++++++++++++++ .../spring-configuration/liquibase/liquibase.xml | 18 + 8 files changed, 2069 insertions(+), 3 deletions(-) create mode 100644 SpringJava/JPA/src/main/resources/spring-configuration/liquibase/changeLogs.xml create mode 100644 SpringJava/JPA/src/main/resources/spring-configuration/liquibase/ddlChangelog.xml create mode 100644 SpringJava/JPA/src/main/resources/spring-configuration/liquibase/dmlChangelog.xml create mode 100644 SpringJava/JPA/src/main/resources/spring-configuration/liquibase/liquibase.xml diff --git a/SpringJava/JPA/README b/SpringJava/JPA/README index a642204..db059a1 100644 --- a/SpringJava/JPA/README +++ b/SpringJava/JPA/README @@ -1,6 +1,7 @@ mvn clean install - -mvn dependency:sources && mvn dependency:resolve -Dclassifier=javadoc +mvn clean install -Dmaven.test.skip=true +mvn dependency:sources +mvn dependency:resolve -Dclassifier=javadoc POST /spring-jpa-1.0-SNAPSHOT/ads/ HTTP/1.1 @@ -45,3 +46,11 @@ Host: 127.0.0.1:8080 Content-Type: application/json Cache-Control: no-cache + + +# Useful commands for liquibase that I used in order to create the changelog files from an existing schema. +# Changelog from DDL. Creates DDL changelog from current database (if schema was previously created without liquibase as above) +/opt/liquibase/liquibase3.5.1/liquibase --driver=com.mysql.jdbc.Driver --classpath=$HOME/.m2/repository/mysql/mysql-connector-java/5.1.9/mysql-connector-java-5.1.9.jar --logLevel=debug --changeLogFile=src/main/resources/spring-configuration/liquibase/ddlChangelog.xml --url="jdbc:mysql://localhost/mybatis_example" --username=root --password=root generateChangeLog + +# Changelog for DML. Creates DML changelog from current database (if there are data) +/opt/liquibase/liquibase3.5.1/liquibase --driver=com.mysql.jdbc.Driver --classpath=$HOME/.m2/repository/mysql/mysql-connector-java/5.1.9/mysql-connector-java-5.1.9.jar --logLevel=debug --changeLogFile=src/main/resources/spring-configuration/liquibase/dmlChangelog.xml --url="jdbc:mysql://localhost/mybatis_example" --username=root --password=root --diffTypes="data" generateChangeLog diff --git a/SpringJava/JPA/context.xml b/SpringJava/JPA/context.xml index e053ee3..1b3628f 100644 --- a/SpringJava/JPA/context.xml +++ b/SpringJava/JPA/context.xml @@ -45,7 +45,7 @@ removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true" type="javax.sql.DataSource" - url="jdbc:mysql://localhost:3306/mybatis_example?allowMultiQueries=true&autoReconnect=true&characterEncoding=UTF-8" + url="jdbc:mysql://localhost:3306/mybatis_example?createDatabaseIfNotExist=true&allowMultiQueries=true&autoReconnect=true&characterEncoding=UTF-8" username="root" validationQuery="select 1" /> diff --git a/SpringJava/JPA/pom.xml b/SpringJava/JPA/pom.xml index d84e688..bac065d 100644 --- a/SpringJava/JPA/pom.xml +++ b/SpringJava/JPA/pom.xml @@ -231,6 +231,12 @@ ${querydsl.version} + + + org.liquibase + liquibase-core + 3.5.1 + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/datasource-configuration.xml b/SpringJava/JPA/src/main/resources/spring-configuration/datasource-configuration.xml index babff20..6b5500c 100644 --- a/SpringJava/JPA/src/main/resources/spring-configuration/datasource-configuration.xml +++ b/SpringJava/JPA/src/main/resources/spring-configuration/datasource-configuration.xml @@ -26,4 +26,6 @@ + + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/changeLogs.xml b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/changeLogs.xml new file mode 100644 index 0000000..4d558c2 --- /dev/null +++ b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/changeLogs.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/ddlChangelog.xml b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/ddlChangelog.xml new file mode 100644 index 0000000..e8fbd91 --- /dev/null +++ b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/ddlChangelog.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/dmlChangelog.xml b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/dmlChangelog.xml new file mode 100644 index 0000000..0f07094 --- /dev/null +++ b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/dmlChangelog.xml @@ -0,0 +1,1960 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/liquibase.xml b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/liquibase.xml new file mode 100644 index 0000000..705fc46 --- /dev/null +++ b/SpringJava/JPA/src/main/resources/spring-configuration/liquibase/liquibase.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file -- 2.1.4