【发布时间】:2016-01-21 10:20:43
【问题描述】:
我在创建时使用命令 yo jhipster:entity event 创建了一个名为“event”的实体,我忘记添加一列让我们说“event_title" 所以,我在 liquibase changelog xml 中手动添加了这个(event_tile)列。现在如何使用新添加的列更新 event 表?
【问题讨论】:
我在创建时使用命令 yo jhipster:entity event 创建了一个名为“event”的实体,我忘记添加一列让我们说“event_title" 所以,我在 liquibase changelog xml 中手动添加了这个(event_tile)列。现在如何使用新添加的列更新 event 表?
【问题讨论】:
您需要在 src/main/resources/config/liquibase/master.xml 文件中包含新的变更日志文件。
<include file="classpath:config/liquibase/changelog/my_new_changelog.xml"
relativeToChangelogFile="false"/>
下次运行应用程序时,将应用更改。
您还可以使用以下 maven 任务更新数据库:
mvn liquibase:update.
【讨论】:
pom.xml 文件中设置您的数据库信息。它在liquibase-maven-plugin 的插件标签中指定。
我在
上创建了一个文件src/main/resources/config/liquibase
例如:
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet author="lazaro" id="altertable-02">
<addColumn catalogName="mySchema"
schemaName="public"
tableName="myTableName">
<column name="atributeName" type="bigint"/>
</addColumn>
</changeSet>
并添加上
src/main/resources/config/liquibase/master.xml
包含标签:
<include file="classpath:config/liquibase/changelog/add_column_quantity_entity_Item.xml" relativeToChangelogFile="false"/>
【讨论】: