fix migrations

This commit is contained in:
Flatlogic Bot 2026-01-22 11:26:11 +00:00
parent f721c4b74c
commit 73cbd2f171
2 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,16 @@
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { 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(` await queryInterface.sequelize.query(`
INSERT INTO "rolesPermissionsPermissions" ("createdAt", "updatedAt", "roles_permissionsId", "permissionId") INSERT INTO "rolesPermissionsPermissions" ("createdAt", "updatedAt", "roles_permissionsId", "permissionId")
SELECT NOW(), NOW(), r.id, p.id SELECT NOW(), NOW(), r.id, p.id

View File

@ -1,4 +1,3 @@
const { v4: uuid } = require("uuid"); const { v4: uuid } = require("uuid");
module.exports = { 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.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, "createdAt" timestamp with time zone not null,
"updatedAt" timestamp with time zone not null, "updatedAt" timestamp with time zone not null,
@ -881,4 +880,3 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
} }
}; };