Skip to content

Commit

Permalink
1-3131: db migration to make potentially stale non-nullable (#8796)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasheartman authored Nov 19, 2024
1 parent 9d96052 commit 82e752b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'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 DEFAULT FALSE;
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 DEFAULT;
ALTER TABLE features
ALTER COLUMN potentially_stale DROP NOT NULL;
`,
cb
);
};

0 comments on commit 82e752b

Please sign in to comment.