From d236e4c57a7f71589764efccd0cb36337d551055 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Sat, 4 Aug 2018 23:42:49 +0000 Subject: [permissions] add permission management Add Roles Table with Delete Roles and Create Roles possibilities Add Users Table with Grant Roles and Revoke Roles possibilities --- server/migrations/20180726033100-create-role.js | 22 ++++++++++++++++ .../20180726033400-create-user_x_role.js | 30 ++++++++++++++++++++++ .../migrations/20180726171200-create-permission.js | 25 ++++++++++++++++++ .../20180726173100-create-role_x_permission.js | 30 ++++++++++++++++++++++ .../20180804234000-create-role_x_group.js | 30 ++++++++++++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 server/migrations/20180726033100-create-role.js create mode 100644 server/migrations/20180726033400-create-user_x_role.js create mode 100644 server/migrations/20180726171200-create-permission.js create mode 100644 server/migrations/20180726173100-create-role_x_permission.js create mode 100644 server/migrations/20180804234000-create-role_x_group.js (limited to 'server/migrations') diff --git a/server/migrations/20180726033100-create-role.js b/server/migrations/20180726033100-create-role.js new file mode 100644 index 0000000..c930148 --- /dev/null +++ b/server/migrations/20180726033100-create-role.js @@ -0,0 +1,22 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('roles', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + name: { + type: Sequelize.STRING + }, + descr: { + type: Sequelize.STRING + } + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('roles') + } +} diff --git a/server/migrations/20180726033400-create-user_x_role.js b/server/migrations/20180726033400-create-user_x_role.js new file mode 100644 index 0000000..d82bc9a --- /dev/null +++ b/server/migrations/20180726033400-create-user_x_role.js @@ -0,0 +1,30 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('user_x_role', { + userId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'users', + key: 'id' + } + }, + roleId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'roles', + key: 'id' + } + } + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('user_x_role') + } +} \ No newline at end of file diff --git a/server/migrations/20180726171200-create-permission.js b/server/migrations/20180726171200-create-permission.js new file mode 100644 index 0000000..822e47c --- /dev/null +++ b/server/migrations/20180726171200-create-permission.js @@ -0,0 +1,25 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('permissions', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + name: { + type: Sequelize.STRING + }, + descr: { + type: Sequelize.STRING + }, + groupdependent: { + type: Sequelize.BOOLEAN + } + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('permissions') + } +} diff --git a/server/migrations/20180726173100-create-role_x_permission.js b/server/migrations/20180726173100-create-role_x_permission.js new file mode 100644 index 0000000..edfcb8e --- /dev/null +++ b/server/migrations/20180726173100-create-role_x_permission.js @@ -0,0 +1,30 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('role_x_permission', { + roleId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'roles', + key: 'id' + } + }, + permissionId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'permissions', + key: 'id' + } + } + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('role_x_permission') + } +} \ No newline at end of file diff --git a/server/migrations/20180804234000-create-role_x_group.js b/server/migrations/20180804234000-create-role_x_group.js new file mode 100644 index 0000000..d9024be --- /dev/null +++ b/server/migrations/20180804234000-create-role_x_group.js @@ -0,0 +1,30 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('role_x_group', { + roleId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'roles', + key: 'id' + } + }, + groupId: { + primaryKey: true, + allowNull: false, + type: Sequelize.INTEGER, + onDelete: "cascade", + references: { + model: 'groups', + key: 'id' + } + } + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('role_x_group') + } +} \ No newline at end of file -- cgit v1.2.3-55-g7522