diff --git a/src/migrations/20240118093611-missing-primary-keys.js b/src/migrations/20240118093611-missing-primary-keys.js new file mode 100644 index 000000000000..a632a361000c --- /dev/null +++ b/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); + 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, + ); +};