2014-09-22 102 views
1

我刚开始使用flywaydb,只是一个测试试图与创建和插入查询,并发射了迁移,但它忽略了我所有的创建表脚本:(如何打开DDL事务支持?

我用于调试-X选项,发现了一个奇怪的线 DEBUG: DDL Transactions Supported: false

看来,如果我做到了真正的,它会工作。

有谁遇到这个问题,如果是如何摆脱呢? 我已经做了这个新的架构,用干净的-INIT-迁移 下面全堆栈跟踪:

[[email protected] flyway]$ ./flyway -X clean 
/usr/bin/tput 
Flyway (Command-line Tool) v.3.0 

DEBUG: Adding location to classpath: /home/ec2-user/installables/flyway-3.0/bin/../jars/mysql-connector-java-5.1.26.jar 
Database: jdbc:mysql://0.0.0.0:3306/test (MySQL 5.5) 
DEBUG: DDL Transactions Supported: false 
DEBUG: Schema: test 
DEBUG: Cleaning schema `test` ... 
Cleaned schema `test` (execution time 00:00.025s) 

[[email protected] flyway]$ 
[[email protected] flyway]$ ./flyway -X init 
/usr/bin/tput 
Flyway (Command-line Tool) v.3.0 

DEBUG: Adding location to classpath: /home/ec2-user/installables/flyway-3.0/bin/../jars/mysql-connector-java-5.1.26.jar 
Database: jdbc:mysql://0.0.0.0:3306/test (MySQL 5.5) 
DEBUG: DDL Transactions Supported: false 
DEBUG: Schema: test 
DEBUG: Schema `test` already exists. Skipping schema creation. 
Creating Metadata table: `test`.`schema_version` 
DEBUG: Found statement at line 17: CREATE TABLE `test`.`schema_version` (
    `version_rank` INT NOT NULL, 
    `installed_rank` INT NOT NULL, 
    `version` VARCHAR(50) NOT NULL, 
    `description` VARCHAR(200) NOT NULL, 
    `type` VARCHAR(20) NOT NULL, 
    `script` VARCHAR(1000) NOT NULL, 
    `checksum` INT, 
    `installed_by` VARCHAR(100) NOT NULL, 
    `installed_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
    `execution_time` INT NOT NULL, 
    `success` BOOL NOT NULL 
) ENGINE=InnoDB 
DEBUG: Found statement at line 30: ALTER TABLE `test`.`schema_version` ADD CONSTRAINT `schema_version_pk` PRIMARY KEY (`version`) 
DEBUG: Found statement at line 32: CREATE INDEX `schema_version_vr_idx` ON `test`.`schema_version` (`version_rank`) 
DEBUG: Found statement at line 33: CREATE INDEX `schema_version_ir_idx` ON `test`.`schema_version` (`installed_rank`) 
DEBUG: Found statement at line 34: CREATE INDEX `schema_version_s_idx` ON `test`.`schema_version` (`success`) 
DEBUG: Executing SQL: CREATE TABLE `test`.`schema_version` (
    `version_rank` INT NOT NULL, 
    `installed_rank` INT NOT NULL, 
    `version` VARCHAR(50) NOT NULL, 
    `description` VARCHAR(200) NOT NULL, 
    `type` VARCHAR(20) NOT NULL, 
    `script` VARCHAR(1000) NOT NULL, 
    `checksum` INT, 
    `installed_by` VARCHAR(100) NOT NULL, 
    `installed_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
    `execution_time` INT NOT NULL, 
    `success` BOOL NOT NULL 
) ENGINE=InnoDB 
DEBUG: Executing SQL: ALTER TABLE `test`.`schema_version` ADD CONSTRAINT `schema_version_pk` PRIMARY KEY (`version`) 
DEBUG: Executing SQL: CREATE INDEX `schema_version_vr_idx` ON `test`.`schema_version` (`version_rank`) 
DEBUG: Executing SQL: CREATE INDEX `schema_version_ir_idx` ON `test`.`schema_version` (`installed_rank`) 
DEBUG: Executing SQL: CREATE INDEX `schema_version_s_idx` ON `test`.`schema_version` (`success`) 
DEBUG: Metadata table `test`.`schema_version` created. 
DEBUG: MetaData table `test`.`schema_version` successfully updated to reflect changes 
Schema initialized with version: 1 
[[email protected] flyway]$ ./flyway -X migrate 
/usr/bin/tput 
Flyway (Command-line Tool) v.3.0 

DEBUG: Adding location to classpath: /home/ec2-user/installables/flyway-3.0/bin/../jars/mysql-connector-java-5.1.26.jar 
Database: jdbc:mysql://0.0.0.0:3306/test (MySQL 5.5) 
DEBUG: DDL Transactions Supported: false 
DEBUG: Schema: test 
DEBUG: Spring Jdbc available: false 
DEBUG: Validating migrations ... 
DEBUG: Scanning for filesystem resources at '/home/ec2-user/installables/flyway-3.0/bin/../sql' (Prefix: 'V', Suffix: '.sql') 
DEBUG: Scanning for resources in path: /home/ec2-user/installables/flyway-3.0/bin/../sql (/home/ec2-user/installables/flyway-3.0/bin/../sql) 
DEBUG: Found filesystem resource: /home/ec2-user/installables/flyway-3.0/bin/../sql/V1__cr_tbl.sql 
DEBUG: Found filesystem resource: /home/ec2-user/installables/flyway-3.0/bin/../sql/V2__Add_people.sql 
Validated 2 migrations (execution time 00:00.032s) 
DEBUG: Schema `test` already exists. Skipping schema creation. 
DEBUG: Locking table `test`.`schema_version`... 
DEBUG: Lock acquired for table `test`.`schema_version` 
Current version of schema `test`: 1 
Migrating schema `test` to version 2 
DEBUG: Found statement at line 1: insert into PERSON (ID, NAME) values (1, 'Axel') 
DEBUG: Found statement at line 2: insert into PERSON (ID, NAME) values (2, 'Mr. Foo') 
DEBUG: Found statement at line 3: insert into PERSON (ID, NAME) values (3, 'Ms. Bar') 
DEBUG: Executing SQL: insert into PERSON (ID, NAME) values (1, 'Axel') 
DEBUG: Rolling back transaction... 
DEBUG: Transaction rolled back 
ERROR: Migration of schema `test` to version 2 failed! Please restore backups and roll back database and code! 
DEBUG: MetaData table `test`.`schema_version` successfully updated to reflect changes 
ERROR: Unexpected error 
org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: Error executing statement at line 1: insert into PERSON (ID, NAME) values (1, 'Axel') 
    at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:91) 
    at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:73) 
    at org.flywaydb.core.internal.command.DbMigrate$5.doInTransaction(DbMigrate.java:287) 
    at org.flywaydb.core.internal.command.DbMigrate$5.doInTransaction(DbMigrate.java:285) 
    at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72) 
    at org.flywaydb.core.internal.command.DbMigrate.applyMigration(DbMigrate.java:285) 
    at org.flywaydb.core.internal.command.DbMigrate.access$800(DbMigrate.java:46) 
    at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:207) 
    at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:156) 
    at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72) 
    at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:156) 
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:864) 
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:811) 
    at org.flywaydb.core.Flyway.execute(Flyway.java:1171) 
    at org.flywaydb.core.Flyway.migrate(Flyway.java:811) 
    at org.flywaydb.commandline.Main.executeOperation(Main.java:120) 
    at org.flywaydb.commandline.Main.main(Main.java:88) 
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.PERSON' doesn't exist 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
    at com.mysql.jdbc.Util.getInstance(Util.java:386) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122) 
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) 
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) 
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812) 
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761) 
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894) 
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732) 
    at org.flywaydb.core.internal.dbsupport.JdbcTemplate.executeStatement(JdbcTemplate.java:235) 
    at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:89) 
    ... 16 more 

回答

0

这只是表示您的数据库不支持DDL事务。如果需要,可以使用不同的PostgreSQL,DB2或SqlServer。

现在,为什么你的脚本就不会被拾起,这是不可能的从你的问题告诉。

从入门教程开始,一旦成功,将其调整到您的项目。

+0

嗨Axel,我正在使用MySQL和这个问题,我从入门教程。 – 2014-09-23 08:09:55

+0

如果您完全按照步骤操作。发出一条飞行道路干净并再试一次。 – 2014-09-23 08:50:22

+0

@ alex-fontaine,我是这样做的,你从[此链接](http://flywaydb.org/getstarted/firststeps/commandline.html)中说,除了我使用mysql。 init和clean正在工作,但为了迁移它忽略V1__cr_tbl.sql,我已经在原始问题 – 2014-09-23 09:35:23