Fix role permissions migration order
This commit is contained in:
parent
26313d01f3
commit
04aa6e9598
@ -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 },
|
||||
|
||||
@ -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';`,
|
||||
|
||||
@ -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';`,
|
||||
|
||||
@ -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", [
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user