I’m using Grails 1.3.7 + MySQL 5.5 + Liquibase through the database-migration plugin 0.2.1.
When I’m in my development environment, I have Hibernate configured to use “create-drop” but in my QA environment, I want to use liquibase to create my tables. Here is my environments config:
environments {
development {
dataSource {
configClass = GrailsAnnotationConfiguration.class
pooled = false
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
dbCreate = "create-drop"
url = "jdbc:mysql://localhost/dripita_dev"
}
}
localQa {
dataSource {
configClass=GrailsAnnotationConfiguration.class
pooled=false
driverClassName="com.mysql.jdbc.Driver"
username="root"
password=""
dialect="org.hibernate.dialect.MySQL5InnoDBDialect"
url="jdbc:mysql://localhost/dripita_localqa"
}
}
...
}
When I bring the app up in dev mode, the database tables are create fine. I do the following to create the changelog:
$ grails dbm-generate-gorm-changelog changelog.groovy
Which looks like this:
changeSet(author: "javidjamae (generated)", id: "1309959832163-2") {
createTable(tableName: "payment") {
column(autoIncrement: "true", name: "id", type: "bigint") {
constraints(nullable: "false", primaryKey: "true", primaryKeyName: "paymentPK")
}
column(name: "version", type: "bigint") {
constraints(nullable: "false")
}
column(name: "buyer_id", type: "bigint") {
constraints(nullable: "false")
}
column(name: "buyer_information_id", type: "bigint")
column(name: "currency", type: "varchar(255)") {
constraints(nullable: "false")
}
column(name: "discount_cart_amount", type: "decimal(19,2)") {
constraints(nullable: "false")
}
column(name: "paypal_transaction_id", type: "varchar(255)")
column(name: "status", type: "varchar(9)") {
constraints(nullable: "false")
}
column(name: "tax", type: "double precision(19)") {
constraints(nullable: "false")
}
column(name: "transaction_id", type: "varchar(255)")
}
}
Then I try to create the tables from the changelog:
$ grails -Dgrails.env=localQa dbm-update
But, when I run the dbm-update, I get the following error:
07/06 08:52:41 INFO [main]: liquibase - Successfully acquired change log lock
07/06 08:52:42 INFO [main]: liquibase - Reading from `DATABASECHANGELOG`
07/06 08:52:42 INFO [main]: liquibase - Reading from `DATABASECHANGELOG`
07/06 08:52:42 ERROR [main]: liquibase - Error executing SQL CREATE TABLE `payment` (`id` BIGINT AUTO_INCREMENT NOT NULL, `version` BIGINT NOT NULL, `buyer_id` BIGINT NOT NULL, `buyer_information_id` BIGINT, `currency` VARCHAR(255) NOT NULL, `discount_cart_amount` decimal(19,2) NOT NULL, `paypal_transaction_id` VARCHAR(255), `status` VARCHAR(9) NOT NULL, `tax` double precision(19) NOT NULL, `transaction_id` VARCHAR(255), CONSTRAINT `paymentPK` PRIMARY KEY (`id`)) ENGINE=InnoDB
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') NOT NULL, `transaction_id` VARCHAR(255), CONSTRAINT `paymentPK` PRIMARY KEY (`' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
When I copy/paste the create statement in MySQL, I get the same error. I even took the ENGINE=InnoDB off to see if that made a difference, but it didn’t. Any ideas?
FYI: I installed MySQL using HomeBrew on my Mac.
My guess is that your QA db doesn’t know what the datatype
double precision(19)is.Try changing it to just
double precision.If that fails, consider using another datatype: The doc says that double precision is a “nonstandard variation”