Fix role permissions migration order

This commit is contained in:
Flatlogic Bot 2026-05-06 10:15:38 +00:00
parent 26313d01f3
commit 04aa6e9598
4 changed files with 35 additions and 2 deletions

View File

@ -7,6 +7,17 @@ module.exports = {
const updatedAt = new Date();
const entity = 'workers_comp_classes';
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")
);
`);
const permissions = [
{ id: uuid(), name: `CREATE_${entity.toUpperCase()}`, createdAt, updatedAt },
{ id: uuid(), name: `READ_${entity.toUpperCase()}`, createdAt, updatedAt },

View File

@ -3,6 +3,18 @@ module.exports = {
up: async (queryInterface, Sequelize) => {
const createdAt = new Date();
const updatedAt = new Date();
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")
);
`);
// Find all roles
const roles = await queryInterface.sequelize.query(
`SELECT id, name FROM roles WHERE name != 'Public';`,

View File

@ -3,6 +3,17 @@ module.exports = {
up: async (queryInterface, Sequelize) => {
const createdAt = new Date();
const updatedAt = new Date();
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")
);
`);
const roles = await queryInterface.sequelize.query(
`SELECT id, name FROM roles WHERE name != 'Public';`,

View File

@ -68,7 +68,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,
@ -1143,4 +1143,3 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [
}
};