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:
parent
5028bb6c60
commit
561c3d22e9
37
src/migrations/20210907124058-add-dbcritic-indices.js
Normal file
37
src/migrations/20210907124058-add-dbcritic-indices.js
Normal 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,
|
||||
};
|
25
src/migrations/20210907124850-add-dbcritic-primary-keys.js
Normal file
25
src/migrations/20210907124850-add-dbcritic-primary-keys.js
Normal 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,
|
||||
};
|
Loading…
Reference in New Issue
Block a user