From 16cff285701fae849a8a0d902c4f91e288d08453 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 19 Nov 2024 11:57:34 +0100 Subject: [PATCH] 1-3131: db migration to make potentially stale non-nullable This change adds a db migration to make the potentially_stale column non-nullable. It'll set any NULL values to `false`. In the down-migration, make the column nullable again. --- ...819-make-potentially-stale-non-nullable.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/migrations/20241119103819-make-potentially-stale-non-nullable.js diff --git a/src/migrations/20241119103819-make-potentially-stale-non-nullable.js b/src/migrations/20241119103819-make-potentially-stale-non-nullable.js new file mode 100644 index 000000000000..3e83078322b3 --- /dev/null +++ b/src/migrations/20241119103819-make-potentially-stale-non-nullable.js @@ -0,0 +1,21 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + ` + UPDATE features SET potentially_stale = FALSE WHERE potentially_stale IS NULL; + ALTER TABLE features ALTER COLUMN potentially_stale SET NOT NULL; + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + ALTER TABLE features ALTER COLUMN potentially_stale DROP NOT NULL; + `, + cb, + ); +}; +