Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ module.exports = {
NO_OF_ATTEMPTS: 3,
materializedViewsPrefix: 'm_',
DELETED_STATUS: 'DELETED',
DEFAULT_ORG_VISIBILITY: 'PUBLIC',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
const defaultOrgId = queryInterface.sequelize.options.defaultOrgId
await queryInterface.addColumn('user_roles', 'visiblity', {
type: Sequelize.STRING,
allowNull: false,
defaultValue: 'PUBLIC',
})
await queryInterface.addColumn('user_roles', 'organization_id', {
type: Sequelize.STRING,
allowNull: false,
defaultValue: defaultOrgId,
})
},

async down(queryInterface, Sequelize) {
await queryInterface.removeColumn('user_roles', 'visiblity')
await queryInterface.removeColumn('user_roles', 'organization_id')
},
}
11 changes: 10 additions & 1 deletion src/database/models/userRole.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
const common = require('@constants/common')
module.exports = (sequelize, DataTypes) => {
const UserRole = sequelize.define(
'UserRole',
Expand All @@ -20,7 +21,15 @@ module.exports = (sequelize, DataTypes) => {
},
status: {
type: DataTypes.STRING,
defaultValue: 'ACTIVE',
defaultValue: common.ACTIVE_STATUS,
},
visiblity: {
type: DataTypes.STRING,
defaultValue: common.DEFAULT_ORG_VISIBILITY,
},
organization_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
},
{ sequelize, modelName: 'UserRole', tableName: 'user_roles', freezeTableName: true, paranoid: true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
let rolesData = []
const defaultOrgId = queryInterface.sequelize.options.defaultOrgId
const roleArray = ['user', 'mentor', 'mentee', 'admin']
//user_type denotes the role is system user or not 1: system user, 0: non system user
roleArray.forEach(async function (role) {
Expand All @@ -12,6 +13,8 @@ module.exports = {
let eachRow = {
title: role,
user_type: user_type,
visiblity: 'PUBLIC',
organization_id: defaultOrgId,
updated_at: new Date(),
created_at: new Date(),
}
Expand Down