4
votes

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.

1

1 Answers

11
votes

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