1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

1-3131: db migration to make potentially stale non-nullable (#8796)

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.
This commit is contained in:
Thomas Heartman 2024-11-19 12:27:22 +01:00 committed by GitHub
parent 9d96052a3b
commit 82e752be45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
);
};