1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/src/migrations/20211011094226-add-environment-to-client-instances.js
2021-10-12 10:39:28 +02:00

30 lines
887 B
JavaScript

'use strict';
exports.up = function (db, cb) {
db.runSql(
`
ALTER TABLE client_instances DROP CONSTRAINT client_instances_pkey;
ALTER TABLE client_instances ADD COLUMN environment varchar(255) NOT NULL DEFAULT 'default';
ALTER TABLE client_instances ADD CONSTRAINT client_instances_pkey PRIMARY KEY (app_name, environment, instance_id);
CREATE INDEX client_instances_environment_idx ON client_instances(environment);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX client_instances_environment_idx;
ALTER TABLE client_instances DROP CONSTRAINT client_instances_pkey;
ALTER TABLE client_instances ADD CONSTRAINT client_instances_pkey PRIMARY KEY (app_name, instance_id);
ALTER TABLE client_instances DROP COLUMN environment;
`,
cb,
);
};
exports._meta = {
version: 1,
};