1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00
unleash.unleash/src/migrations/20241119103819-make-potentially-stale-non-nullable.js
Thomas Heartman 82e752be45
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.
2024-11-19 12:27:22 +01:00

30 lines
636 B
JavaScript

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