Project member management

This commit is contained in:
Takeshi Kimata
2024-05-29 23:12:38 +09:00
parent 4b46944440
commit abf2d48bee
20 changed files with 588 additions and 9 deletions

View File

@@ -0,0 +1,52 @@
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('members', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
userId: {
type: Sequelize.INTEGER,
references: {
model: 'users',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
projectId: {
type: Sequelize.INTEGER,
references: {
model: 'projects',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
role: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex('members', ['userId', 'projectId'], {
unique: true,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('members');
},
};