0

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)?

1 Answer 1

1

You need to set dbms=postgresql instead of dbms=postgres on your changesets. I just ran this in my sandbox and it worked:

<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="postgresql" endDelimiter=";"> CREATE SCHEMA v1 </sql> </changeSet> <changeSet id="2" author="Kalaitsidis Arslan"> <sql dbms="postgresql" endDelimiter=";"> CREATE SCHEMA v2 </sql> </changeSet> </databaseChangeLog> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.