Skip to content

Commit

Permalink
[finishes #187354254] permissions and role implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanIrad committed May 1, 2024
1 parent 6de33c7 commit 1d9e6bd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/database/migrations/20240501104514-create-permissions-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('permissions', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: 'read',
unique: true,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

async down(queryInterface, Sequelize) {
await queryInterface.dropTable('permissions');
},
};
21 changes: 21 additions & 0 deletions src/database/seeders/20240501105101-permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.bulkInsert(
'permissions',
[
{ name: 'read', createdAt: new Date(), updatedAt: new Date() },
{ name: 'write', createdAt: new Date(), updatedAt: new Date() },
{ name: 'delete', createdAt: new Date(), updatedAt: new Date() },
// Add more permissions as needed
],
{}
);
},

async down(queryInterface, Sequelize) {
await queryInterface.bulkDelete('permissions', null, {});
},
};

0 comments on commit 1d9e6bd

Please sign in to comment.