JujaLabs / itevents

Resource to subscribe on it events
Apache License 2.0
7 stars 5 forks source link

Wrong execution order of liquibase changsets #165

Open romach opened 8 years ago

romach commented 8 years ago

Must be: during liquibaseUpdate changesets must be executed according their chengeset numbers. What is wrong: instead of that they are executed according directory structure: first - files in create directory (000, 001, 003, ...), then - in data directory (002, 005, 007, ...); How to reproduce: run liquibaseUpdate task with --logLevel=debug property (add it in build.gradle)

vaa25 commented 8 years ago

@romach why do you think it must execute first in create then in data directory?

romach commented 8 years ago

@vaa25 changesets must be executed according their chengeset numbers (000, 001, 002, 003)

alex-anakin commented 8 years ago

@romach, @vaa25: there is an approach for dividing executing of changesets. Master changeset includes 2 sub-master changesets - create-tables and add-data. Order of executing and main idea is understand, I hope. Numbers are independent in every directory in that case.

romach commented 8 years ago

@alex-anakin do you mean that initially changesets from create-tables will be executed and then from add-data according to your approach?

alex-anakin commented 8 years ago

@romach exactly )

romach commented 8 years ago

@vaa25 @alex-anakin Consider the case: We have following directory structure:

└── liquibase
    └── create
        ├── table-1.sql
        ├── table-2.sql
    └── data
        ├── insert-to-itable-1.sql
        └── insert-to-itable-2.sql

Execution order will be table-1.sql > table-2.sql > insert-to-table-1.sql > insert-to-table-2.sql

Then we decide to change or delete column in table-2. So, now we have next directory structure:

└── liquibase
    └── create
        ├── table-1.sql
        ├── table-2.sql
        └── alter-column-in-table-2.sql
    └── data
        ├── insert-in-table-1.sql
        └── insert-in-table-2.sql

Execution order on the clean database will be table-1.sql > table-2.sql > alter-column-in-table-2.sql > insert-to-table-1.sql > insert-to-table-2.sql

But because we changed column in table-2 the errors will occur when we try to execute insert-in-table-2.sql because of new table-2 structure.

vaa25 commented 8 years ago

@romach One of decisions of this situation is replacing changeset insert-in-table-2.sql with new changeset insert-in-altered-table-2, suitable to new table-2 structure after alter-column-in-table-2.sql appplies

romach commented 8 years ago

@AndriyBaibak this issue is not actual now

IgorMaksymov commented 8 years ago

@romach if we will need to do this in future, i dont think that we must close this issue