0

一些更新

我有一个 sql 脚本迁移,如果我将它通过管道传输到 mysql,它将运行,但不是通过 flyway。该脚本正在执行,但第一行显然出错了。

一旦遇到这样的行: /*!50003 SET character_set_results = latin1 */ ;

该脚本静默停止运行。我使用了简单的插入语句来确保脚本至少已启动,并且确实如此。

我不想针对不同类型的数据库或任何东西运行 mysql 语句。我的 pom.xml 是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.cpt.migrations</groupId>
  <artifactId>cpt_migrations</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>cpt_migrations</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.24</version>
    </dependency>
  </dependencies>
  <build>
      <plugins>
          <plugin>
              <groupId>com.googlecode.flyway</groupId>
              <artifactId>flyway-maven-plugin</artifactId>
              <version>2.1.1</version>
              <configuration>
                  <user>root</user>
                  <password></password>
                  <driver>com.mysql.jdbc.Driver</driver>
                  <url>jdbc:mysql://localhost:3306/cpt</url>
              </configuration>
          </plugin>
      </plugins>
  </build>
</project>

跑步: mvn clean compile flyway:clean flyway:migrate --debug --offline -ff -e

仅在第二次迁移中使用此网络:

[DEBUG] Locking table `cpt`.`schema_version`...
[DEBUG] Lock acquired for table `cpt`.`schema_version`
[INFO] Migrating schema `cpt` to version 2
[DEBUG] Successfully completed and committed migration of schema `cpt` to version 2
[DEBUG] Finished migrating schema `cpt` to version 2 (execution time 00:00.003s)
[DEBUG] MetaData table `cpt`.`schema_version` successfully updated to reflect changes
[DEBUG] Unlocking table `cpt`.`schema_version`...
[DEBUG] Lock released for table `cpt`.`schema_version`
[DEBUG] Locking table `cpt`.`schema_version`...
[DEBUG] Lock acquired for table `cpt`.`schema_version`
[DEBUG] Unlocking table `cpt`.`schema_version`...
[DEBUG] Lock released for table `cpt`.`schema_version`

如果我立即运行:

cat target/classes/db/migration/V2__Triggers.sql | mysql -u root cpt 

更改按预期进行。

关于这里发生的事情有什么建议吗?看起来它应该只是将这个 sql 直接扔到数据库而不尝试解析它,但显然情况并非如此。

而且,很容易也很重要。为什么我没有收到失败消息?

4

1 回答 1

0

Sounds like you hit an issue with the parser. Please file an issue in the issue tracker with a small sample migration that fails, and I'll try to address it in time for 2.2.

于 2013-04-16T16:30:49.157 回答