0
我通過數據庫遷移插件0.2.1使用了Grails 1.3.7 + MySQL 5.5 + Liquibase。通過liquibase創建表時MySQL錯誤
當我在我的開發環境中時,我將Hibernate配置爲使用「創建 - 刪除」,但在我的QA環境中,我想使用liquibase創建我的表。這裏是我的環境配置:
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"
}
}
...
}
當我把應用程序在開發模式下,數據庫表創建罰款。我做了以下內容來創建的changelog:
$ grails dbm-generate-gorm-changelog changelog.groovy
,看起來像這樣:
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)")
}
}
然後我嘗試創建從更新日誌表:
$ grails -Dgrails.env=localQa dbm-update
但是,當我運行dbm-update,出現以下錯誤:
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)
當我在MySQL中複製/粘貼create語句時,出現同樣的錯誤。我甚至將ENGINE = InnoDB關閉,看是否有所作爲,但事實並非如此。有任何想法嗎?
僅供參考:我在我的Mac上使用HomeBrew安裝了MySQL。
謝謝!這從MySQL命令行工作。在我的域對象中,該字段是一個BigDecimal,所以我假設它的錯誤是db-migration插件,或者在Liquibase中它以雙精度生成它(19)。我將提交一份錯誤報告,並查看我的相關信息。 –