Skip to content

Commit

Permalink
feat: add primary keys to missing tables (#5943)
Browse files Browse the repository at this point in the history
Follow up of #4303

We are adding primary keys to all tables missing them, currently
**role_permission**, **api_token_project**, and **project_stats**.
By adding primary keys, the issue with migrations failing during
upgrades in replicated database setups will be resolved.
  • Loading branch information
sjaanus committed Jan 18, 2024
1 parent 5b56fac commit 605125f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/migrations/20240118093611-missing-primary-keys.js
@@ -0,0 +1,24 @@
'use strict';

exports.up = function (db, callback) {
db.runSql(
`
ALTER TABLE project_stats ADD PRIMARY KEY (project);
ALTER TABLE api_token_project ADD PRIMARY KEY (secret, project);
ALTER TABLE role_permission ADD COLUMN id SERIAL PRIMARY KEY;
`,
callback,
);
};

exports.down = function (db, callback) {
db.runSql(
`
ALTER TABLE project_stats DROP CONSTRAINT project_stats_pkey;
ALTER TABLE api_token_project DROP CONSTRAINT api_token_project_pkey;
ALTER TABLE role_permission DROP CONSTRAINT role_permission_pkey;
ALTER TABLE role_permission DROP COLUMN id;
`,
callback,
);
};

0 comments on commit 605125f

Please sign in to comment.