quiz

Full-stack dev quiz question #58

Full-stack dev quiz question #58quiz

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.

  1. It will add a test column to a table if the column does not exist, yet.
  2. If a test column already exists, the update operation will fail.
  3. It will try to apply addColumn change no matter if a test column exists or not.
  4. If a test column already exists, the update operation will succeed.
  5. 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.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.