lbruun-net / Pre-Liquibase

Spring Boot add-on to Liquibase
Apache License 2.0
49 stars 9 forks source link

The schema is not created even though logs says the sql script is executed #3

Closed itstannus closed 3 years ago

itstannus commented 3 years ago

Below is the log, the right file is picked up but when i check in the database the schema is not created. Log: INFO 16:04:05.093 main n.l.s.preliquibase.PreLiquibase> PreLiquibase: Executing SQL script : URL [file:/home/tanvi/Documents/projects/om-order/om-order-service/target/classes/preliquibase/postgresql.sql]

postgresql.sql contents : CREATE SCHEMA IF NOT EXISTS tanvi;

using :

        <dependency>
            <groupId>net.lbruun.springboot</groupId>
            <artifactId>preliquibase-spring-boot-starter</artifactId>
            <version>1.1.1</version>
        </dependency>
lbruun commented 3 years ago

Try the troubleshooting section. (i.e. enable debugging)

If that doesn't give you a clue then you need to attach a full log to this ticket.

Thx.

itstannus commented 3 years ago

@Ibrunn the troubleshooting section helped.

DEBUG 20:19:48.687 main liquibase.database> Not adjusting the auto commit mode; it is already false

basically I had to mention commit in postgresql.sql

CREATE SCHEMA IF NOT EXISTS ${spring.liquibase.default-schema};
COMMIT;
lbruun commented 3 years ago

I'm guessing you must have explicitly turned off auto-commit? From what I know auto-commit is the default in JDBC, so perhaps you had/have something like this in your config? :

spring.datasource.hikari.auto-commit=false

This would explain it.

What I'm saying is that in general it should not be necessary to add commit statements in the SQL scripts that Pre-Liquibase uses regardless of database platform. However, whatever the auto-commit setting such commit in the SQL script will never hurt.

I'm glad you solved it.

itstannus commented 3 years ago

Hey Ibrunn, yes you are right , the property mentioned does exist in my application : spring.datasource.hikari.auto-commit=false

Thanks :)