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

fix: Added indices and primary key to feature_tag (#936)

* fix: Added indices and primary key as recommended by dbcritic
This commit is contained in:
Christopher Kolstad 2021-09-10 12:27:20 +02:00 committed by GitHub
parent 5028bb6c60
commit 561c3d22e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,37 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE INDEX feature_environments_feature_name_idx ON feature_environments(feature_name);
CREATE INDEX feature_strategies_environment_idx ON feature_strategies(environment);
CREATE INDEX feature_strategies_feature_name_idx ON feature_strategies(feature_name);
CREATE INDEX feature_tag_tag_type_and_value_idx ON feature_tag(tag_type, tag_value);
CREATE INDEX project_environments_environment_idx ON project_environments(environment_name);
CREATE INDEX reset_tokens_user_id_idx ON reset_tokens(user_id);
CREATE INDEX role_permission_role_id_idx ON role_permission(role_id);
CREATE INDEX role_user_user_id_idx ON role_user(user_id);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX feature_environments_feature_name_idx;
DROP INDEX feature_strategies_environment_idx;
DROP INDEX feature_strategies_feature_name_idx;
DROP INDEX feature_tag_tag_type_and_value_idx;
DROP INDEX project_environments_environment_idx;
DROP INDEX reset_tokens_user_id_idx;
DROP INDEX role_permission_role_id_idx;
DROP INDEX role_user_user_id_idx;
`,
cb,
);
};
exports._meta = {
version: 1,
};

View File

@ -0,0 +1,25 @@
exports.up = function (db, cb) {
db.runSql(
`
ALTER TABLE feature_tag
DROP CONSTRAINT feature_tag_feature_name_tag_type_tag_value_key;
ALTER TABLE feature_tag
ADD PRIMARY KEY (feature_name, tag_type, tag_value);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`ALTER TABLE feature_tag
DROP constraint feature_tag_pkey;
ALTER TABLE feature_tag
ADD CONSTRAINT feature_tag_feature_name_tag_type_tag_value_key UNIQUE (feature_name, tag_type, tag_value)`,
cb,
);
};
exports._meta = {
version: 1,
};