Reorder SQL to avoid race conditions (Liquibase #8) 00/141500/3
authordanielhanrahan <daniel.hanrahan@est.tech>
Thu, 24 Jul 2025 12:50:06 +0000 (13:50 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Wed, 30 Jul 2025 09:27:52 +0000 (10:27 +0100)
commit2230c408ca771fe9510e721bf70bd41be0a48cb6
tree1b23732f3914f78828a3dc83a138a3fdf70e82b0
parent1af1ca8dced13601f573625a35de46617d016a1d
Reorder SQL to avoid race conditions (Liquibase #8)

This commit rearranges SQL statements to minimize race conditions
once the SQL is converted to seperate Liquibase steps.

When adding default values & not-null constraints, do it like this:
1. Set default value for the column, so any new data will not be NULL
2. Update any existing NULLs to that same default value
3. Add the NOT NULL constraint to the column

If DEFAULT is set after NOT NULL, it's possible new rows could be
added with NULL, causing the SET NOT NULL to fail.

Issue-ID: POLICY-5398
Change-Id: Ia9b10340fbd6a856d5e4b2aa059f0c8d59a2f070
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
runtime-acm/src/main/resources/db/changelog/changelog-1701.yaml