Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify schema location for changelog tables

Is there a way to specify the schema where liquibase creates the database changelog tables (databasechangelog and databasechangeloglock)?

I'm using postgresql and gradle. I defined a schema for my application (e.g. myapplication).

When I run the liquibase update task from gradle, the application specific tables are correctly created inside the 'myapplication' schema, but the liquibase changelog stuff is created in the 'public' schema.

like image 964
Florian Maier Avatar asked Dec 14 '22 09:12

Florian Maier


1 Answers

Not covered in the documentation, but available in current versions of Liquibase (I'm not sure how far back that applies) are the command line arguments

--liquibaseCatalogName

and

--liquibaseSchemaName

Using these will allow you to keep your "managed schema" and your "liquibase schema" separate.

For gradle, I think you would specify these in you configuration block:

liquibase {
  activities { 
    main {
      changeLogFile 'changelog.groovy'
      url 'jdbc:h2:db/liquibase_workshop;FILE_LOCK=NO'
      username 'sa'
      password ''
      changeLogParameters([ myToken: 'myvalue',
                            second: 'secondValue'])
      liquibaseSchemaName 'myLiquibaseSchema'
      defaultSchemaName   'myApplicationSchema'
    }
    second {
      changeLogFile 'second.groovy'
      url 'jdbc:h2:db/liquibase_workshop;FILE_LOCK=NO'
      username 'sa'
      password ''
      changeLogParameters([ myToken: 'myvalue',
                            second: 'secondValue'])
    }
  }

  // runList = project.ext.runList
  // runList = 'main'
  runList = 'main, second'
}

If you are using a properties file, the properties you set are the same names as the command line options, so you would have something like this:

liquibaseSchemaName=myLiquibaseSchema
like image 86
SteveDonie Avatar answered Jan 14 '23 09:01

SteveDonie