2021-03-04 12:54:13 +01:00
|
|
|
'use strict';
|
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
exports.up = function (db, cb) {
|
2021-03-04 12:54:13 +01:00
|
|
|
db.runSql(
|
|
|
|
`
|
2021-03-19 11:54:12 +01:00
|
|
|
DELETE FROM client_instances a USING client_instances b WHERE a.app_name = b.app_name AND a.instance_id = b.instance_id AND a.created_at < b.created_at;
|
2021-03-04 12:54:13 +01:00
|
|
|
ALTER TABLE client_instances ADD PRIMARY KEY (app_name, instance_id);
|
|
|
|
`,
|
|
|
|
cb,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
exports.down = function (db, cb) {
|
2021-03-04 12:54:13 +01:00
|
|
|
db.runSql(
|
|
|
|
`
|
|
|
|
ALTER TABLE client_instances DROP CONSTRAINT client_instances_pkey;
|
2021-03-19 11:54:12 +01:00
|
|
|
DROP INDEX IF EXISTS client_instance_pkey
|
2021-03-04 12:54:13 +01:00
|
|
|
`,
|
|
|
|
cb,
|
|
|
|
);
|
|
|
|
};
|