Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,41 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
async up(queryInterface, Sequelize) {
|
|
||||||
const createdAt = new Date();
|
|
||||||
const updatedAt = new Date();
|
|
||||||
|
|
||||||
const [roles] = await queryInterface.sequelize.query(
|
|
||||||
`SELECT id FROM "roles" WHERE name = 'Public' LIMIT 1;`
|
|
||||||
);
|
|
||||||
const publicRoleId = roles[0]?.id;
|
|
||||||
|
|
||||||
if (!publicRoleId) return;
|
|
||||||
|
|
||||||
const [permissions] = await queryInterface.sequelize.query(
|
|
||||||
`SELECT id, name FROM "permissions" WHERE name IN ('READ_CASINO_HOTELS', 'READ_AMENITIES');`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (permissions.length === 0) return;
|
|
||||||
|
|
||||||
const rolePermissions = permissions.map(p => ({
|
|
||||||
createdAt,
|
|
||||||
updatedAt,
|
|
||||||
roles_permissionsId: publicRoleId,
|
|
||||||
permissionId: p.id
|
|
||||||
}));
|
|
||||||
|
|
||||||
await queryInterface.bulkInsert('rolesPermissionsPermissions', rolePermissions);
|
|
||||||
},
|
|
||||||
|
|
||||||
async down(queryInterface, Sequelize) {
|
|
||||||
const [roles] = await queryInterface.sequelize.query(
|
|
||||||
`SELECT id FROM "roles" WHERE name = 'Public' LIMIT 1;`
|
|
||||||
);
|
|
||||||
const publicRoleId = roles[0]?.id;
|
|
||||||
|
|
||||||
if (!publicRoleId) return;
|
|
||||||
|
|
||||||
await queryInterface.sequelize.query(
|
|
||||||
`DELETE FROM "rolesPermissionsPermissions" WHERE "roles_permissionsId" = '${publicRoleId}';`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Loading…
x
Reference in New Issue
Block a user