【问题标题】:Liquibase start script from another scriptLiquibase 从另一个脚本启动脚本
【发布时间】:2022-08-22 21:48:28
【问题描述】:

我有两个脚本,一个创建表,一个填充它,它们看起来像这样。

    databaseChangeLog:
  - changeSet:
      id: \"0\"
      author: author
      changes:
        - createTable:
            columns:
              - column:
                  constraints:
                    nullable: false
                    primaryKey: true
                    primaryKeyName: board_id
                  name: id
                  type: integer
              - column:
                  constraints:
                    nullable: false
                  name: engines
                  type: varchar(45)
//more code



    databaseChangeLog:
  - changeSet:
      id: board_table_fill
      author: 777
      changes:
        - insert:
            tableName: boards
            columns:
              - column:
                  name: id
                  value: 777
              - column:
                  name: engines
                  value: stock
              - column:
                  name: markets
                  value: index
//more code

我需要启动两个脚本,我该怎么做?那\的应用程序属性:

    spring:
  application:
    name: 777
  datasource:
    driverClassName: org.postgresql.Driver
    username: 777
    password: 777
    url: 777
  jpa:
    hibernate:
      ddl-auto: validate
  liquibase:
    change-log: \"classpath:db/changelog/db.changelog-777.yml\"

在我的情况下,只有创建表的脚本启动,但我需要两者。我是 liquibase 的新手,很抱歉提出一个愚蠢的问题。

标签: postgresql liquibase


【解决方案1】:

CT Liv 在 cmets 中提供的答案:

您需要创建一个包含其他两个的主变更日志。

见这里:https://docs.liquibase.com/concepts/changelogs/attributes/include.html

该示例采用 XML 格式,但 YAML 版本很简单。 这是一个例子:https://github.com/thombergs/code-examples/blob/master/spring-boot/data-migration/liquibase/src/main/resources/db/changelog/db.changelog-master.yaml

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-22
    • 1970-01-01
    相关资源
    最近更新 更多