Maven Liquibase plugin executing previous changesets
我希望能够通过Maven将最新的更改应用到liquibase控制的数据库中。 我的POM包含:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <plugin> <groupId>org.liquibase</groupId> liquibase-maven-plugin</artifactId> <version>3.3.5</version> <dependencies> <dependency> <groupId>mysql</groupId> mysql-connector-java</artifactId> <version>5.1.23</version> </dependency> </dependencies> <configuration> <changeLogFile>src/main/resources/config/database/db-changelog-master.xml</changeLogFile> <driver>com.mysql.jdbc.Driver</driver> <url>jdbc:mysql://localhost:3306/myDb</url> <username>${db.user}</username> <password>${db.password}</password> <verbose>true</verbose> </configuration> <executions> <execution> <goals> <goal>update</goal> </goals> </execution> </executions> </plugin> |
当我运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [INFO] driver: com.mysql.jdbc.Driver [INFO] url: jdbc:mysql://localhost:3306/myDb [INFO] username: dbUser [INFO] password: ***** [INFO] use empty password: false [INFO] properties file: null [INFO] properties file will override? false [INFO] prompt on non-local database? true [INFO] clear checksums? false [INFO] changeLogFile: src/main/resources/config/database/db-changelog-master.xml [INFO] context(s): null [INFO] label(s): null [INFO] number of changes to apply: 0 [INFO] drop first? false [INFO] ------------------------------------------------------------------------ [INFO] Executing on Database: jdbc:mysql://localhost:3306/myDb INFO 23/07/15 13:09: liquibase: Successfully acquired change log lock INFO 23/07/15 13:09: liquibase: Reading from DATABASECHANGELOG SEVERE 23/07/15 13:09: liquibase: src/main/resources/config/database/db-changelog-master.xml: src/main/resources/config/database/changesets-001.xml::1000::gavin: Change S et src/main/resources/config/database/changesets-001.xml::1000::gavin failed. Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'tc_configuration' already exists liquibase.exception.DatabaseException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'tc_configuration' already exists |
似乎Liquibase正在尝试重新运行已经执行的变更集。
有没有办法只运行新的变更集?
Liquibase会跟踪已经在自己的表中执行的内容。 在决定是否运行创建它的sql语句之前,不会查看表tc_configuration是否存在。 相反,如果已经执行了具有给定id的变更集,它将检查自己的表。 所以在你的情况下,显然,tc_configuration表是在liquibase之外创建的,或者liquibase表已被操作。
如果您从空数据库开始并仅使用liquibase:update更新它,liquibase将始终只运行最新的更改一次。