java Flyway Future State防止新的迁移

6yoyoihd  于 2023-01-04  发布在  Java
关注(0)|答案(1)|浏览(147)

我正在尝试Java迁移教程。修改迁移的Java类后,Java类卡在Future状态并阻止新的迁移。我是Flyway新手,不确定我做错了什么。或者Future状态是否存在任何已知问题?
我先添加了两个SQL文件,运行mvn flyway:migrate,两个文件都迁移成功,然后添加了一个Java类V3__Anonymize,再次运行mvn flyway:migrate,同样成功,info命令显示

+-----------+--------+---------------------+------+---------------------+---------+  
| Category  | Version| Description         | Type | Installed On        | State   |  
+-----------+--------+---------------------+------+---------------------+---------+  
| Versioned | 1      | Create person table | SQL  | 2022-11-03 08:26:52 | Success |  
| Versioned | 2      | Add people          | SQL  | 2022-11-03 08:28:45 | Success | 
| Versioned | 3      | Anonymize           | JDBC | 2022-11-03 09:05:29 | Success | 
+-----------+--------+---------------------+------+---------------------+---------+

然后我修改了V3__Anonymize类,只添加了一行代码来迁移System.out.println(“something”)的函数。info命令显示了第三个作业的Future状态:

+-----------+--------+---------------------+------+---------------------+---------+  
| Category  | Version| Description         | Type | Installed On        | State   |
+-----------+--------+---------------------+------+---------------------+---------+  
| Versioned | 1      | Create person table | SQL  | 2022-11-03 08:26:52 | Success | 
| Versioned | 2      | Add people          | SQL  | 2022-11-03 08:28:45 | Success | 
| Versioned | 3      | Anonymize           | JDBC | 2022-11-03 09:05:29 | Future  | +-----------+--------+---------------------+------+---------------------+---------+

然后运行mvn flyway:migrate,它给出了如下所示的警告。

[INFO] --- flyway-maven-plugin:9.7.0:migrate (default-cli) @ my-migration-service ---
[INFO] Flyway Community Edition 9.7.0 by Redgate  
[INFO] See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.7.0 
[INFO]
[INFO] Database: jdbc:h2:file:./target/foobar (H2 2.1)  
[INFO] Successfully validated 3 migrations (execution time 00:00.020s)  
[INFO] Current version of schema "PUBLIC": 3 
[WARNING] Schema "PUBLIC" has a version (3) that is newer than the latest available migration (2) !  
[INFO] Schema "PUBLIC" is up to date. No migration necessary.

我尝试运行mvn编译,然后运行mvn flyway:migrate,mvn flyway:info,但我仍然得到相同的警告,第三个作业停留在未来状态。
我还添加了一个新的Java类V4__Add_another_person,然后运行mvn compile、mvn flyway:migrate,但第三个作业的状态没有变化,新作业没有添加到flyway:info输出中。
然后运行mvn flyway:migrate,它给出了如下所示的警告。

lymnna71

lymnna711#

一旦你运行了一个迁移,你就不应该再碰它的脚本了。这里它被识别为是你做的,因为校验和是不同的。只要这个代码没有被推到master分支(并且有人运行迁移),你就可以从flyway_schema_history中删除最新的一行,然后再次迁移。

相关问题