Last active
February 15, 2019 12:37
-
-
Save thetekst/e91c18b2dd30a88a1b8b0e7e3b337506 to your computer and use it in GitHub Desktop.
Add liquibase to Spring Boot project. Generate changelog from existed DB in IDEA > Gradle > Tasks > liquibase > generateChangelog. Before make generateChangelog be sure that directory liquibase is exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current file location: src/main/liquibase/v-1.0/2018_12_14--01-dictionary.groovy | |
databaseChangeLog() { | |
changeSet(id: '1547828693315-1', author: 'dmitry_tkachenko (generated)') { | |
createSequence(cacheSize: 0, cycle: false, incrementBy: 1, maxValue: 9999999999999999999999999999, minValue: 1, ordered: false, sequenceName: 'CHANNEL_SEQ', startValue: 3) | |
} | |
changeSet(id: '1547828693315-41', author: 'dmitry_tkachenko (generated)') { | |
createTable(tableName: 'TEMPLATE_CHANNEL_TAB') { | |
column(name: 'TEMPLATE_ID', type: 'NUMBER(19, 0)') { | |
constraints(nullable: false) | |
} | |
column(name: 'CHANNEL_ID', type: 'NUMBER(19, 0)') { | |
constraints(nullable: false) | |
} | |
} | |
} | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current file location: src/main/liquibase/v-1.0/2018_12_14--01-dictionary.yml | |
databaseChangeLog: | |
- changeSet: | |
id: drop_unique_group_tab_constraint | |
author: rtln | |
changes: | |
- dropUniqueConstraint: | |
constraintName: uk_sw62vm5lf3sdy93djsk40i3rh | |
tableName: group_tab | |
- changeSet: | |
id: 1550074683089-3 | |
author: dmitry_tkachenko (generated) | |
changes: | |
- createSequence: | |
cacheSize: 0 | |
maxValue: 9999999999999999999999999999 | |
sequenceName: DICTIONARY_FIELD_SEQ | |
startValue: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'java' | |
id 'groovy' | |
id 'org.springframework.boot' version '2.0.6.RELEASE' | |
id 'org.liquibase.gradle' version '2.0.1' // required | |
} | |
apply plugin: 'io.spring.dependency-management' | |
dependencies { | |
compile('org.springframework.boot:spring-boot-starter-jetty') { | |
exclude group: 'org.eclipse.jetty.websocket' | |
} | |
compile('org.springframework.boot:spring-boot-starter-web') { | |
exclude module: 'spring-boot-starter-tomcat' | |
} | |
compile 'org.springframework.boot:spring-boot-starter-data-jpa' | |
// compile "org.liquibase:liquibase-core" - don't include for manual star liquibase | |
... | |
liquibaseRuntime 'org.liquibase:liquibase-core' // required | |
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1' // required | |
liquibaseRuntime "com.oracle:ojdbc7:${oracleJdbcVersion}" // required | |
liquibaseRuntime 'ch.qos.logback:logback-classic' | |
} | |
liquibase { | |
activities { | |
main { | |
def file = new File("${projectDir}/liquibase.properties") | |
if (file.exists()) { | |
def props = new Properties() | |
InputStream is = new FileInputStream(file) | |
props.load(is) | |
is.close() | |
changeLogFile props['changeLogFile'] | |
url props['url'] | |
username props['username'] | |
password props['password'] | |
} else { | |
println "Add ${projectDir}/liquibase.properties if you want use liquibase plugin" | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeLogFile=src/main/liquibase/root.groovy # or changeLogFile=src/main/liquibase/root.yml | |
url=jdbc:oracle:thin:@localhost:1521/xe | |
username=test | |
password=test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current file location: src/main/liquibase/root.groovy | |
databaseChangeLog() { | |
include(file: "v-1.0/2018_12_14--01-dictionary.groovy", relativeToChangelogFile: "true") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current file location: src/main/liquibase/root.yml | |
databaseChangeLog: | |
- include: | |
file: src/main/liquibase/v-1.0/2018_12_14--01-dictionary.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment