Quantcast
Viewing all articles
Browse latest Browse all 2993

Liquibase not applying changesets in expected order

I have a Spring Boot 1 application running on PostgreSQL where I've setup my changelog.xml file as follows:
  1. <?xml version="1.1" encoding="UTF-8" standalone="no"?>
    <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.7.xsd">
        <include file="schema.sql" relativeToChangelogFile="true"/>
        <include file="insert_user_local.sql" relativeToChangelogFile="true"/>
    </databaseChangeLog>

In the schema.sql file I have my create table statements, and in the insert_user_local.sql I have the a insert statement to populate the user_detail table with a user for development purposes.

When I boot the server I'm getting an error saying the insert user statement failed because the relation user_detail doesn't exist. 

  1. Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set /db/changelog/insert_user_local.sql::2::user1:
         Reason: liquibase.exception.DatabaseException: ERROR: relation "user_detail" does not exist

If I query the database at this point I can see that the schema.sql was executed and all the tables exist in the db.

  1. select * from databasechangelog;
    -[ RECORD 1 ]-+-----------------------------------
    id            | 1
    author        | user1
    filename      | classpath:/db/changelog/schema.sql
    dateexecuted  | 2020-04-30 20:03:46.771527
    orderexecuted | 1
    exectype      | EXECUTED
    md5sum        | 8:d3c3aed234be3b66182833f56d1febe3
    description   | sql
    comments      | Initial schema
    tag           |
    liquibase     | 3.8.9
    contexts      |
    labels        |
    deployment_id | 8302226596


My understanding is that the <include> files would be executed in order from top to bottom, but it doesn't appear to be the case for me. 

What am I missing here?  Thanks

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>