Hello all,
Im currently testing liquibase to track and apply changes to a MSSQL database. For this purpose I want to create a changeset file for the difference between two different database versions.
So I used “diff-changelog” to create a changeset for changes between the two DB versions. This worked fine, but when applying the changes, liquibase doesn’t seem to have put it in the right sequence.
There are some fields added to tables and these fields have foreign key constraints to other tables. And it appers that in the generated changelog,xml generated, the foreign key constraints are added before the column is added to the table itself. So when trying the “update”, it fails because the FK can’t be added before the column.
- Should I expect that liquibase would follow the right sequence here?
- If yes, what could be the reason that it doesnt?
<changeSet author="tok (generated)" id="1721037144683-532">
<addForeignKeyConstraint baseColumnNames="serverinst" baseTableName="restcom" constraintName="restcom_pgminst_FKNA2" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="inst" referencedTableName="pgminst" validate="true"/>
</changeSet>
....
....
<changeSet author="tok (generated)" id="1721037144683-565">
<addColumn tableName="restcom">
<column name="serverinst" type="nvarchar(30)"/>
</addColumn>
</changeSet>