Permalink
Browse files

fix migrations

  • Loading branch information...
robfletcher
robfletcher committed Jan 17, 2013
1 parent 090286a commit e7642cac6242b291e955a879ab09ac6e4b9952df
@@ -62,6 +62,9 @@ grails.exceptionresolver.params.exclude = ['password']
// enable query caching by default
grails.hibernate.cache.queries = true
+grails.plugin.databasemigration.updateOnStart = true
+grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
+
// set per-environment serverURL stem for creating absolute links
environments {
development {
@@ -13,19 +13,19 @@ hibernate {
environments {
development {
dataSource {
- dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
+ dbCreate = "" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
test {
dataSource {
- dbCreate = "update"
+ dbCreate = ""
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
production {
dataSource {
- dbCreate = "update"
+ dbCreate = ""
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
pooled = true
properties {
@@ -0,0 +1,50 @@
+databaseChangeLog = {
+
+ changeSet(author: "rob (generated)", id: "1358405807992-1") {
+
+ preConditions(onFail: 'MARK_RAN') {
+ not {
+ tableExists tableName: 'album'
+ }
+ }
+
+ createTable(tableName: "album") {
+ column(autoIncrement: "true", name: "id", type: "bigint") {
+ constraints(nullable: "false", primaryKey: "true", primaryKeyName: "albumPK")
+ }
+
+ column(name: "version", type: "bigint") {
+ constraints(nullable: "false")
+ }
+
+ column(name: "artist", type: "varchar(255)") {
+ constraints(nullable: "false")
+ }
+
+ column(name: "title", type: "varchar(255)") {
+ constraints(nullable: "false")
+ }
+
+ column(name: "year", type: "varchar(255)") {
+ constraints(nullable: "false")
+ }
+ }
+
+ }
+
+ changeSet(author: "rob (generated)", id: "1358405807992-2") {
+
+ preConditions(onFail: 'MARK_RAN') {
+ not {
+ indexExists indexName: 'unique_title'
+ }
+ }
+
+ createIndex(indexName: "unique_title", tableName: "album", unique: "true") {
+ column(name: "artist")
+
+ column(name: "title")
+ }
+
+ }
+}
@@ -1,34 +1,6 @@
databaseChangeLog = {
- changeSet(author: "rob (generated)", id: "1358405807992-1") {
- createTable(tableName: "album") {
- column(autoIncrement: "true", name: "id", type: "bigint") {
- constraints(nullable: "false", primaryKey: "true", primaryKeyName: "albumPK")
- }
+ include file: 'base-changelog.groovy'
+ include file: 'field-types.groovy'
- column(name: "version", type: "bigint") {
- constraints(nullable: "false")
- }
-
- column(name: "artist", type: "varchar(255)") {
- constraints(nullable: "false")
- }
-
- column(name: "title", type: "varchar(255)") {
- constraints(nullable: "false")
- }
-
- column(name: "year", type: "varchar(255)") {
- constraints(nullable: "false")
- }
- }
- }
-
- changeSet(author: "rob (generated)", id: "1358405807992-2") {
- createIndex(indexName: "unique_title", tableName: "album", unique: "true") {
- column(name: "artist")
-
- column(name: "title")
- }
- }
-}
+}
@@ -1,23 +1,48 @@
databaseChangeLog = {
changeSet(author: "rob (generated)", id: "1358406936189-1") {
+
+ preConditions(onFail: 'MARK_RAN') {
+ not {
+ columnExists tableName: 'album', columnName: 'compilation'
+ }
+ }
+
addColumn(tableName: "album") {
column(name: "compilation", type: "boolean") {
constraints(nullable: "false")
}
}
+
}
changeSet(author: "rob (generated)", id: "1358406936189-2") {
+
+ preConditions(onFail: 'MARK_RAN') {
+ not {
+ columnExists tableName: 'album', columnName: 'review_rating'
+ }
+ }
+
addColumn(tableName: "album") {
column(name: "review_rating", type: "integer")
}
+
}
changeSet(author: "rob (generated)", id: "1358406936189-3") {
+
+
+ preConditions(onFail: 'MARK_RAN') {
+ not {
+ columnExists tableName: 'album', columnName: 'review_text'
+ }
+ }
+
addColumn(tableName: "album") {
column(name: "review_text", type: "varchar(255)")
}
+
}
}

0 comments on commit e7642ca

Please sign in to comment.