how do i create same tables in different schemes using liquibase

Imagine i had a table 'some-table' that i want to create in multiple schemas. File called 'create-some-table.yaml'

 databaseChangeLog:
      - changeSet:
          id: create-some-table
          runOnChange: true
          author: gimazov (generated)
          preConditions:
            - onFail: MARK_RAN
              not:
                tableExists:
                  tableName: some-table
          changes:
            - createTable:
                columns:
                  - column:
                      autoIncrement: true
                      constraints:
                        nullable: false
                        primaryKey: true
                        primaryKeyName: some-table_pkey
                      name: id
                      type: BIGINT
                tableName: some-table
                schemaName: ${schema}

Then there's a yaml file 'schema1.yaml' that includes the previous file and sets schema

 databaseChangeLog:
  - property:
      name: schema
      value: schema1
  - include:
      file: classpath:/db/changelog/create-some-table.yaml

Then the same file as the above one just named 'schema2.yaml' with corresponding schema name

The last thing is changelog-master which is pretty simple

databaseChangeLog:
    - include:
        file: classpath:/db/changelog/schema1.yaml
    - include:
        file: classpath:/db/changelog/schema2.yaml

Is there any way i can do something similar to this, thanks :)



Read more here: https://stackoverflow.com/questions/65077678/how-do-i-create-same-tables-in-different-schemes-using-liquibase

Content Attribution

This content was originally published by Bulat Gimazov at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: