Liquibase preconditions are more advanced elements of changeset. However, they may help when there are discrepancies between databases on different environments. Check fifty eighth question of full-stack dev quiz to check if you understand preconditions.
Below code is a Liquibase changeset, that will be applied to a database that already have test_table table by using an update command. Look at it and choose the sentences, that are true about it.
<changeSet id="Changeset 1" author="DBA presents">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="test_table" columnName="test" />
</not>
</preConditions>
<addColumn tableName="test_table">
<column name="test" type="int" />
</addColumn>
</changeSet>
Choose all valid answers.
- It will add a test column to a table if the column does not exist, yet.
- If a test column already exists, the update operation will fail.
- It will try to apply addColumn change no matter if a test column exists or not.
- If a test column already exists, the update operation will succeed.
- After the database update, Changeset 1 will be marked as executed no matter if a test column existed or not.
For the correct answer scroll down
.
.
.
.
.
.
The correct answer is: a, d, e. If you would like to read more, check Add column if not exists with Liquibase article or more basic one about preconditions.