Skip to main content
edited tags
Link
Fathah Rehman P
  • 8.8k
  • 4
  • 43
  • 42
Source Link
Barracuda
  • 607
  • 1
  • 9
  • 27

Liquibase postgres create schema

I am writing multitenant application using spring,hibernate and liquibase. I am using schema per tenant approach.

Since I wanted to automate the table creation for each tenant with application startup, I thought I could use spring's liquibase integration to create the schemas and then use MultiTenantSpringLiquibase bean to run the same changelog for each schema.

I create this changelog file in xml to create schemas for postgres but when I run it,no schema is created.

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd"> <changeSet id="1" author="Kalaitsidis Arslan"> <sql dbms="postgres" endDelimiter=";"> CREATE SCHEMA v1 </sql> </changeSet> <changeSet id="2" author="Kalaitsidis Arslan"> <sql dbms="postgres" endDelimiter=";"> CREATE SCHEMA v2 </sql> </changeSet> 

I checked databasechangelog table in the public schema(where liquibase stores information about run commands) and the two commands were inserted and marked as executed. Yet when I check the schemas, no schema was created.

What could be the problem of this? And is there a better solution to my problem: automatic schema creation with liquibase used to create all the required database objects(tables,indexes etc)?