【问题标题】:Generation of UUID in yaml liquibase script在 yaml liquibase 脚本中生成 UUID
【发布时间】:2022-08-09 13:07:52
【问题描述】:

我想将我的 liquibase 脚本从这种 OLD 格式转换为 NEW 格式。但是在新格式中, uuid_in(md5(random()::text || clock_timestamp()::text)::cstring) 函数不起作用,它将 uuid 生成器作为字符串。有什么办法可以解决这个问题?

OLD- 
 changeSet:
    id: fulfillment-seed-data-1
    author: sas
    preConditions:
      onFail: MARK_RAN
      sqlCheck:
        expectedResult: 0
        sql: select count(*) from ${schema}.global_setting;
    changes:
    - sql:
      dbms: PostgreSQL
      splitStatements: true
      stripComments: true
      sql: INSERT INTO ${schema}.global_setting (global_setting_id, spec_nm, app_nm, spec_value_txt, spec_desc) VALUES(uuid_in(md5(random()::text || clock_timestamp()::text)::cstring), \'PROD_DIMENSION_TYPE_ID\', \'FULFILLMENT\', \'\', \'\');

NEW-
changeSet:
    id: fulfillment-seed-data-1
    author: sas
    preConditions:
      - dbms:
          type: PostgreSQL
      - onFail: MARK_RAN
    changes:
    - insert:
        columns:
        - column:
            name: global_setting_id
            value: 
              - uuid_in(md5(random()::text || clock_timestamp()::text)::cstring)
        - column:
            name: spec_nm
            value: PROD_DIMENSION_TYPE_ID
        - column:
            name: app_nm
            value: FULFILLMENT
        - column:
            name: spec_value_txt
            value:
        - column:
            name: spec_desc
            value:
        tableName: global_setting

    标签: mysql yaml liquibase uuid changeset


    【解决方案1】:

    您可以将 valueComputed 用于您试图用来计算列值的函数调用吗? https://docs.liquibase.com/concepts/changelogs/attributes/column.html 在旧情况下,您使用直接 sql 进行更新。 在新格式中,您正在对更改进行建模,因此您需要告诉 Liquibase 执行该函数/sp 而不是填充列值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 2023-04-03
      • 2016-10-23
      • 2017-06-25
      • 2013-11-16
      相关资源
      最近更新 更多