Skip to content

Commit d123d4d

Browse files
authored
Added liquibase support adding #49 changes to changelog (#51)
1 parent a3b8b9b commit d123d4d

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

build.gradle

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ buildscript {
99
classpath "org.grails.plugins:hibernate5:${gormVersion}"
1010
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.3.2"
1111
classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
12+
classpath 'org.grails.plugins:database-migration:3.1.0'
1213
}
1314
}
1415

@@ -73,6 +74,14 @@ configurations {
7374
}
7475
}
7576

77+
sourceSets {
78+
main {
79+
resources {
80+
srcDir 'grails-app/migrations'
81+
}
82+
}
83+
}
84+
7685
dependencies {
7786
developmentOnly("org.springframework.boot:spring-boot-devtools")
7887
compile "org.springframework.boot:spring-boot-starter-logging"
@@ -120,13 +129,18 @@ dependencies {
120129
// Third-party plugins
121130
compile "org.grails.plugins:external-config:2.0.0"
122131
compile 'org.grails.plugins:csv:1.0.1'
123-
runtime "mysql:mysql-connector-java:8.0.23"
132+
runtime "mysql:mysql-connector-java:8.0.22"
124133

125134
// ALA deps
126135
compile "au.org.ala:ala-logger:1.4.1"
127136
compile "org.grails.plugins:ala-auth:3.2.3" //, noCache
128137
compile "org.grails.plugins:ala-bootstrap3:3.2.3" //, noCache
129138
compile "org.grails.plugins:ala-admin-plugin:2.2" //, noCache
139+
140+
// db-migration
141+
// In newer versions use 'implementation'
142+
compile 'org.liquibase:liquibase-core:3.10.3'
143+
compile "org.grails.plugins:database-migration:3.1.0"
130144
}
131145

132146
webdriverBinaries {

grails-app/conf/application.groovy

+14-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,17 @@ grails.hibernate.pass.readonly = false
6969
grails.hibernate.osiv.readonly = false
7070

7171
// We need to override the System message data dir path (assumes it will be logger-service via ${Metadata.current.getApplicationName()})
72-
ala.admin.systemMessage.path = "/data/logger/config"
72+
ala.admin.systemMessage.path = "/data/logger/config"
73+
74+
grails.plugin.databasemigration.changelogFileName = 'changelog.xml'
75+
grails.plugin.databasemigration.updateOnStart = true
76+
grails.plugin.databasemigration.updateOnStartFileName = 'changelog.xml'
77+
78+
// We can limit the context where the db migration run
79+
// https://liquibase.org/blog/contexts-vs-labels
80+
// typically to skip during test or dev
81+
// grails.plugin.databasemigration.updateOnStartContexts = ['context1,context2']
82+
83+
// If extra logs are needed for liquibase
84+
// logging.level.liquibase=on
85+
// logging.level.liquibase.executor=on

grails-app/migrations/changelog.xml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd">
3+
4+
<!-- required indexes for log_event to allow faster/more efficient sorting. -->
5+
6+
<changeSet author="ALA Dev Team" id="1">
7+
<preConditions onFail="MARK_RAN">
8+
<not>
9+
<indexExists tableName="log_event" columnNames="month" />
10+
</not>
11+
</preConditions>
12+
<createIndex indexName="month_idx" tableName="log_event">
13+
<column name="month"/>
14+
</createIndex>
15+
</changeSet>
16+
17+
<changeSet author="ALA Dev Team" id="2">
18+
<preConditions onFail="MARK_RAN">
19+
<not>
20+
<indexExists tableName="log_event" columnNames="log_event_type_id" />
21+
</not>
22+
</preConditions>
23+
<createIndex indexName="log_event_type_id_idx" tableName="log_event">
24+
<column name="log_event_type_id"/>
25+
</createIndex>
26+
</changeSet>
27+
28+
<changeSet author="ALA Dev Team" id="3">
29+
<preConditions onFail="MARK_RAN">
30+
<not>
31+
<indexExists tableName="log_event" columnNames="log_source_type_id" />
32+
</not>
33+
</preConditions>
34+
<createIndex indexName="log_source_type_id_idx" tableName="log_event">
35+
<column name="log_source_type_id"/>
36+
</createIndex>
37+
</changeSet>
38+
39+
<changeSet author="ALA Dev Team" id="4">
40+
<preConditions onFail="MARK_RAN">
41+
<not>
42+
<indexExists tableName="log_event" columnNames="log_reason_type_id" />
43+
</not>
44+
</preConditions>
45+
<createIndex indexName="log_reason_type_id_idx" tableName="log_event">
46+
<column name="log_reason_type_id"/>
47+
</createIndex>
48+
</changeSet>
49+
50+
<changeSet author="ALA Dev Team" id="5">
51+
<preConditions onFail="MARK_RAN">
52+
<not>
53+
<indexExists tableName="log_event" columnNames="user_email" />
54+
</not>
55+
</preConditions>
56+
<createIndex indexName="user_email_idx" tableName="log_event">
57+
<column name="user_email"/>
58+
</createIndex>
59+
</changeSet>
60+
61+
<changeSet author="ALA Dev Team" id="6">
62+
<preConditions onFail="MARK_RAN">
63+
<not>
64+
<indexExists tableName="log_event" columnNames="source" />
65+
</not>
66+
</preConditions>
67+
<createIndex indexName="source_idx" tableName="log_event">
68+
<column name="source"/>
69+
</createIndex>
70+
</changeSet>
71+
72+
<!-- required indexes for log_detail to allow faster/more efficient sorting.-->
73+
74+
<changeSet author="ALA Dev Team" id="7">
75+
<preConditions onFail="MARK_RAN">
76+
<not>
77+
<indexExists tableName="log_detail" columnNames="entity_type" />
78+
</not>
79+
</preConditions>
80+
<createIndex indexName="entity_type_idx" tableName="log_detail">
81+
<column name="entity_type"/>
82+
</createIndex>
83+
</changeSet>
84+
85+
<changeSet author="ALA Dev Team" id="8">
86+
<preConditions onFail="MARK_RAN">
87+
<not>
88+
<indexExists tableName="log_detail" columnNames="entity_uid" />
89+
</not>
90+
</preConditions>
91+
<createIndex indexName="entity_uid_idx" tableName="log_detail">
92+
<column name="entity_uid"/>
93+
</createIndex>
94+
</changeSet>
95+
96+
<changeSet author="ALA Dev Team" id="9">
97+
<preConditions onFail="MARK_RAN">
98+
<not>
99+
<indexExists tableName="log_detail" columnNames="record_count" />
100+
</not>
101+
</preConditions>
102+
<createIndex indexName="record_count_idx" tableName="log_detail">
103+
<column name="record_count"/>
104+
</createIndex>
105+
</changeSet>
106+
107+
</databaseChangeLog>

0 commit comments

Comments
 (0)