【问题标题】:How to update existing table JHipster sample app?如何更新现有表 JHipster 示例应用程序?
【发布时间】:2016-01-21 10:20:43
【问题描述】:

我在创建时使用命令 yo jhipster:entity event 创建了一个名为“event”的实体,我忘记添加一列让我们说“event_title" 所以,我在 liquibase changelog xml 中手动添加了这个(event_tile)列。现在如何使用新添加的列更新 event 表?

【问题讨论】:

    标签: maven liquibase jhipster


    【解决方案1】:

    您需要在 src/main/resources/config/liquibase/master.xml 文件中包含新的变更日志文件。

    <include file="classpath:config/liquibase/changelog/my_new_changelog.xml" 
        relativeToChangelogFile="false"/>
    

    下次运行应用程序时,将应用更改。

    您还可以使用以下 maven 任务更新数据库: mvn liquibase:update.

    这里是doc about using jhipster in development

    【讨论】:

    • 如果尝试执行 mvn liquibase:update 无法在项目 ubweb 上执行目标 org.liquibase:liquibase-maven-plugin:3.3.2:update (default-cli),则会出现以下异常:设置或运行 Liquibase 时出错:liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) -> [Help 1]
    • pom.xml 文件中设置您的数据库信息。它在liquibase-maven-plugin 的插件标签中指定。
    【解决方案2】:

    我在

    上创建了一个文件
    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"/>
    

    【讨论】:

      猜你喜欢
      • 2014-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多