1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: project mode can not be set to null anymore (#5145)

This commit is contained in:
Jaanus Sellin 2023-10-25 14:09:34 +03:00 committed by GitHub
parent 705ca1514e
commit 7039160af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -277,11 +277,11 @@ class ProjectStore implements IProjectStore {
feature_limit: data.featureLimit,
});
} else {
// What happens with project mode in this case?
await this.db(SETTINGS_TABLE).insert({
project: data.id,
default_stickiness: data.defaultStickiness,
feature_limit: data.featureLimit,
project_mode: 'open',
});
}
}

View File

@ -0,0 +1,32 @@
'use strict';
exports.up = function (db, cb) {
db.runSql(`
ALTER TABLE project_settings
ALTER COLUMN project_mode SET DEFAULT 'open';
UPDATE project_settings
SET project_mode = 'open'
WHERE project_mode NOT IN ('open', 'protected', 'private') OR project_mode IS NULL;
ALTER TABLE project_settings
ALTER COLUMN project_mode SET NOT NULL;
ALTER TABLE project_settings
ADD CONSTRAINT project_settings_project_mode_values
CHECK (project_mode IN ('open', 'protected', 'private'));
`, cb);
};
exports.down = function (db, cb) {
db.runSql(`
ALTER TABLE project_settings
ALTER COLUMN project_mode DROP DEFAULT;
ALTER TABLE project_settings
ALTER COLUMN project_mode DROP NOT NULL;
ALTER TABLE project_settings
DROP CONSTRAINT project_settings_project_mode_values;
`, cb);
};