From 7a71f01e83e038d3be736571345e1c53eafc98ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Tue, 11 Jan 2022 13:32:46 +0100 Subject: [PATCH] fix: roles should have unique name --- .../20220111120346-roles-unique-name.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/migrations/20220111120346-roles-unique-name.js diff --git a/src/migrations/20220111120346-roles-unique-name.js b/src/migrations/20220111120346-roles-unique-name.js new file mode 100644 index 0000000000..43b2d1ac55 --- /dev/null +++ b/src/migrations/20220111120346-roles-unique-name.js @@ -0,0 +1,17 @@ +exports.up = function (db, cb) { + db.runSql( + ` + ALTER TABLE roles ADD CONSTRAINT unique_name UNIQUE (name); + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + ALTER TABLE roles DROP CONSTRAINT unique_name; +`, + cb, + ); +};