53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
'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) => {
|
|
await queryInterface.dropTable('members');
|
|
},
|
|
};
|