Demo showing multi-schema does not work with Liquibase SQL change sets.
In order to run this example you will need a local MySQL database running.
You must then create new databases demoDbA
and demoDbB
. demoDb
will be auto-created as the default database.
The changelog included should create a new persons
table in each of the three databases.
The table will be created in the default database, but error on the second. The third will not be touched.
022-09-04 18:29:52.196 WARN 26507 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multiTenantSpringLiquibase' defined in class path resource [uk/co/mark/liquibase/demo/LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set changelog/1.0.0/tables/create_persons_table.xml::createPersonsTable::mark:
Reason: liquibase.exception.DatabaseException: Table 'persons' already exists [Failed SQL: (1050) CREATE TABLE persons
(
personId int,
lastName varchar(255),
firstName varchar(255),
address varchar(255),
city varchar(255)
);]
It appears that when a changeset contains a pure SQL instruction the default schema is always used in error.