56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
const createdAt = new Date();
|
|
const updatedAt = new Date();
|
|
|
|
const roleIds = [
|
|
'21a13835-6fd7-4672-b383-c609e9d5da87', // Administrator
|
|
'7fd7feec-5dd7-490a-bedc-361ebe87415e', // Tenant Owner
|
|
'61b8b77a-5114-458a-bb16-fd554d4f4557', // Global Operations Lead
|
|
'89ecce95-8ac5-4ebb-bdb2-7746fe7e4690', // Research Manager
|
|
];
|
|
|
|
const permissionIds = [
|
|
'80485725-0adf-4309-a2ee-177870dcc3ee', // READ_ORGANIZATIONS
|
|
'a3d8dfaf-6c52-42d5-a2f3-e7e19c593e3d', // UPDATE_ORGANIZATIONS
|
|
];
|
|
|
|
const rolesPermissions = [];
|
|
|
|
for (const roleId of roleIds) {
|
|
for (const permissionId of permissionIds) {
|
|
rolesPermissions.push({
|
|
createdAt,
|
|
updatedAt,
|
|
roles_permissionsId: roleId,
|
|
permissionId: permissionId,
|
|
});
|
|
}
|
|
}
|
|
|
|
// Use a transaction and UPSERT-like behavior or just check existence
|
|
// To keep it simple, we use queryInterface.bulkInsert but it might fail on duplicates if we are not careful.
|
|
// However, we checked and they are missing.
|
|
|
|
await queryInterface.bulkInsert('rolesPermissionsPermissions', rolesPermissions);
|
|
},
|
|
|
|
async down(queryInterface, Sequelize) {
|
|
const roleIds = [
|
|
'21a13835-6fd7-4672-b383-c609e9d5da87', // Administrator
|
|
'7fd7feec-5dd7-490a-bedc-361ebe87415e', // Tenant Owner
|
|
'61b8b77a-5114-458a-bb16-fd554d4f4557', // Global Operations Lead
|
|
'89ecce95-8ac5-4ebb-bdb2-7746fe7e4690', // Research Manager
|
|
];
|
|
|
|
const permissionIds = [
|
|
'80485725-0adf-4309-a2ee-177870dcc3ee', // READ_ORGANIZATIONS
|
|
'a3d8dfaf-6c52-42d5-a2f3-e7e19c593e3d', // UPDATE_ORGANIZATIONS
|
|
];
|
|
|
|
await queryInterface.bulkDelete('rolesPermissionsPermissions', {
|
|
roles_permissionsId: roleIds,
|
|
permissionId: permissionIds,
|
|
});
|
|
}
|
|
}; |