gpt4 book ai didi

java - liquibase 不生成表 DATABASECHANGELOG

转载 作者:搜寻专家 更新时间:2023-11-01 03:57:01 25 4
gpt4 key购买 nike

我是 liquibase 的新手,我想在生产中的数据库上使用它。这是一个小型应用程序,但我不想手动创建模式,而是想使用像 liquibase 这样更专业的东西。

我打算做的是在生产中的当前模式和为新应用程序准备好的新模式之间创建一个变更日志。我已经学习了很多教程,但仍然缺少一些东西。输出 changelog.xml 始终导入所有模式,并且与现有模式没有区别。我看到 liquibase 必须创建表 DATABASECHANGELOG,但我在我的计算机上看不到它们。

我做了什么:

  • 在开发计算机上生产和导入当前数据库的转储
  • 从核心项目添加 liquibase.properties 并启动以下命令:mvn clean resources:resources liquibase:generateChangeLog
  • 这生成了包含所有模式的 master.xml,但没有在数据库中创建表 DATABASECHANGELOGLOCK(表 DATABASECHANGELOGLOCK 是在注释 outputChangeLogFile 时创建的,LOCKED 值为 0)
  • http://www.liquibase.org/databases.html 手动创建了 DATABASECHANGELOG
  • 重新运行命令 mvn liquibase:generateChangeLog。还是什么都没有

pom.xml :

<dependencies>
...
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>

<!-- edited build after 1st comment. Still got the problem -->
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
<changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
</plugin>
</plugins>
</build>

<!--- old section build, left for history purpose --->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
<changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

liquibase.properties :

url=jdbc:mysql://localhost:3306/my_db
username=user
password=pass
driver=com.mysql.jdbc.Driver
outputChangeLogFile=src/main/resources/liquibase/master.xml

注意:注释 outputChangeLogFile 使 liquibase 创建表 DATABASECHANGELOGLOCK,但只有这个。

maven 输出:

[INFO] ------------------------------------------------------------------------
[INFO] Building -CORE 0.0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.5.3:generateChangeLog (default-cli) @ EDI-CORE ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:mysql://localhost:3306/my_db
[INFO] Generating Change Log from database root@localhost @ jdbc:mysql://localhost:3306/my_db (Default Schema: edi)
INFO 17/01/17 15:01: liquibase: src\main\resources\liquibase\master.xml exists, appending
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
[INFO] Output written to Change Log file, src/main/resources/liquibase/master.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

最佳答案

据我所知(我也是新手),表 DATABASECHAGELOG 和 DATABASECHANGELOGLOCK 是由更新选项创建的:mvn liquibase:update

关于java - liquibase 不生成表 DATABASECHANGELOG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41699394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com