【问题标题】:Liquibase date_trunc postgresql function error while JHipster Prod version buildJHipster Prod 版本构建时 Liquibase date_trunc postgresql 函数错误
【发布时间】:2018-08-18 05:52:56
【问题描述】:

我正在尝试在 Liquibase 中为我的 JHipster 应用程序构建 View PostgreSQL 表。因此,我尝试了createViewsqlFile 方法。 我的查询具有 date_trunc() 功能如下:

CREATE OR REPLACE VIEW periodical_statistics AS
 SELECT tran.id, date_trunc('day', tran.pub_date) as, ...
  FROM transaction tran
  ...(LEFT JOINS - not relative)...
  WHERE ...(condtions - not relative)...

当我在 maven(./mvnw) 中以 Dev 模式运行我的 JHispster 应用程序时。它工作得很好。

但是当我在 maven(./mvnw -Pprod package) 中以 Prod 模式运行它时。它给出了以下错误。

    20180817101122-1::liquibase-docs failed.  Error: Function "DATE_TRUNC" not found; 
SQL statement: CREATE OR REPLACE VIEW periodical_statistics AS ....

有没有办法解决这个错误问题?

【问题讨论】:

  • 我没有提到我的事务表结构。很明显,有 pub_date(dateTimeWithTimeZone) 列,我想把它截断到一天
  • 哪个 maven 阶段失败了?运行./mvnw -Pprod package -DskipTests时也会失败吗?
  • 您是否使用相同的用户进行开发/生产?

标签: postgresql maven jhipster liquibase


【解决方案1】:

dbms='postgresql' 添加到变更集后。 Liquibase 识别出“date_trunc”函数。如下:

    <changeSet author="sanatbek" id="20180904094713" dbms="postgresql">
            <createView replaceIfExists="true"
                        schemaName="public"
                        viewName="periodical_statistics">
                SELECT
                tran.id
                date_trunc('day', tran.pub_date) as truncated_date,
                ....
                ...(LEFT JOINS - not relative)...
                WHERE ...(condtions - not relative)...
            </createView>
        </changeSet>

【讨论】:

    猜你喜欢
    • 2019-01-10
    • 2023-04-11
    • 2019-01-12
    • 1970-01-01
    • 2017-07-14
    • 2018-12-26
    • 2019-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多