我在我喜欢的项目中使用了Java+Spring+Maven+Flyway+Postgres。下面是db/migration中的两个sql文件。当我第一次使用
mvn spring-boot:run或在应用程序开始使用之前
mvn flyway:migrate -Dflyway.url=jdbc:postgresql://localhost:5432/university -Dflyway.user=tester -Dflyway.password=testDb是创建正确的,没有任何错误,但当我想要创建V1时,首先使用
mvn flyway:baseline -Dflyway.url=jdbc:postgresql://localhost:5432/university -Dflyway.user=tester -Dflyway.password=test在那之后:
mvn flyway:migrate -Dflyway.url=jdbc:postgresql://localhost:5432/university -Dflyway.user=tester -Dflyway.password=test我发现错误:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:6.4.4:migrate (default-cli) on project universityschedule: org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
[ERROR] Migration V2__add_email_and_phone_to_person.sql failed
[ERROR] ------------------------------------------------------
[ERROR] SQL State : 42P01
[ERROR] Error Code : 0
[ERROR] Message : ERROR: relation "public.teacher" does not exist为什么会发生这种情况?如何修复?
发布于 2020-10-26 19:43:07
Flyway基线将用于非空数据库。在这种情况下,假设第一次迁移表示将数据库创建到其当前状态所需的sql。因此,它假设您的V1迁移不打算执行,只是将其标记为baseline。
如果您只是迁移,跳过基线步骤,它应该工作得很好。
https://stackoverflow.com/questions/64524395
复制相似问题