From 73cbd2f17149c5ed1b7b0cb7c5997bbb5723a887 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 22 Jan 2026 11:26:11 +0000 Subject: [PATCH] fix migrations --- .../20260121000000-grant-public-permissions.js | 13 ++++++++++++- backend/src/db/seeders/20200430130760-user-roles.js | 6 ++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/db/migrations/20260121000000-grant-public-permissions.js b/backend/src/db/migrations/20260121000000-grant-public-permissions.js index e4137f1..33e225e 100644 --- a/backend/src/db/migrations/20260121000000-grant-public-permissions.js +++ b/backend/src/db/migrations/20260121000000-grant-public-permissions.js @@ -1,5 +1,16 @@ module.exports = { async up(queryInterface, Sequelize) { + // Ensure the table exists before trying to insert + await queryInterface.sequelize.query(` + CREATE TABLE IF NOT EXISTS "rolesPermissionsPermissions" ( + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + "roles_permissionsId" uuid NOT NULL, + "permissionId" uuid NOT NULL, + PRIMARY KEY ("roles_permissionsId", "permissionId") + ); + `); + await queryInterface.sequelize.query(` INSERT INTO "rolesPermissionsPermissions" ("createdAt", "updatedAt", "roles_permissionsId", "permissionId") SELECT NOW(), NOW(), r.id, p.id @@ -16,4 +27,4 @@ module.exports = { AND "permissionId" IN (SELECT id FROM permissions WHERE name IN ('READ_COURSES', 'READ_USERS', 'READ_CATEGORIES', 'READ_LESSONS')); `); } -}; \ No newline at end of file +}; diff --git a/backend/src/db/seeders/20200430130760-user-roles.js b/backend/src/db/seeders/20200430130760-user-roles.js index e35d597..696f92f 100644 --- a/backend/src/db/seeders/20200430130760-user-roles.js +++ b/backend/src/db/seeders/20200430130760-user-roles.js @@ -1,4 +1,3 @@ - const { v4: uuid } = require("uuid"); module.exports = { @@ -68,7 +67,7 @@ await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), cr await queryInterface.bulkInsert("permissions", [{ id: getId(`CREATE_SEARCH`), createdAt, updatedAt, name: `CREATE_SEARCH`}]); -await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions" +await queryInterface.sequelize.query(`create table IF NOT EXISTS "rolesPermissionsPermissions" ( "createdAt" timestamp with time zone not null, "updatedAt" timestamp with time zone not null, @@ -880,5 +879,4 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [ } -}; - +}; \ No newline at end of file