后端-创建对应表的迁移脚本
User - 用户Board - 任务面板BoardList - 任务列表BoardListCard - 任务卡片Attachment - 附件CardAttachment - 卡片附件关联Comment - 评论
User - 用户
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementnameSTRING(50)passwordSTRING(32)createdAtDATEupdatedAtDATE
终端输入 --> /node_modules/.bin/sequelize migration:create --name initUser
'use strict';
module
.exports
= {
up
: async (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('User',{
id
:{
type
:Sequelize
.INTEGER.UNSIGNED,
autoIncrement
:true,
primaryKey
:true,
},
name
:{
type
:Sequelize
.STRING(50),
allowNull
:false
},
password
:{
type
:Sequelize
.STRING(32),
allowNull
:false
},
createdAt
:{
type
:Sequelize
.DATE,
allowNull
:false
},
updatedAt
:{
type
:Sequelize
.DATE,
allowNull
:false
},
}, {
charset
:'utf8mp4'
});
},
down
: async (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('User');
}
};
Board - 任务面板
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idboardIdINTEGER.UNSIGNEDBoard.idnameSTRING(255)orderFLOATcreatedAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initBoard
module
.exports
= {
up
: async (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('Board',{
id
:{
type
:Sequelize
.INTEGER.UNSIGNED,
autoIncrement
:true,
primaryKey
:true,
},
userId
:{
type
:Sequelize
.INTEGER.UNSIGNED,
allowNull
: false,
},
boardId
:{
type
:Sequelize
.INTEGER.UNSIGNED,
allowNull
: false,
},
name
:{
type
:Sequelize
.STRING(255),
allowNull
: false
},
order
:{
type
:Sequelize
.FLOAT,
allowNull
: false
},
createdAt
:{
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
:{
type
: Sequelize
.DATE,
allowNull
: false
},
},{
charset
: 'utf8mb4'
})
},
down
: async (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('Board');
}
};
BoardList - 任务列表
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idboardIdINTEGER.UNSIGNEDBoard.idnameSTRING(255)orderFLOATcreatedAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initBoardList
module
.exports
= {
up
: (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('BoardList', {
id
: {
type
: Sequelize
.INTEGER.UNSIGNED,
autoIncrement
: true,
primaryKey
: true,
},
userId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
boardId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
name
: {
type
: Sequelize
.STRING(255),
allowNull
: false
},
order
: {
type
: Sequelize
.FLOAT,
allowNull
: false,
defaultValue
: 0
},
createdAt
: {
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
: {
type
: Sequelize
.DATE,
allowNull
: false
}
}, {
charset
: 'utf8mb4'
});
},
down
: (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('BoardList');
}
};
BoardListCard - 任务卡片
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idboardListIdINTEGER.UNSIGNEDBoardList.idnameSTRING(255)descriptionSTRING(2000)‘’orderFLOATcreatedAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initBoardListCard
module
.exports
= {
up
: (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('BoardListCard', {
id
: {
type
: Sequelize
.INTEGER.UNSIGNED,
autoIncrement
: true,
primaryKey
: true,
},
userId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
boardListId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
name
: {
type
: Sequelize
.STRING(255),
allowNull
: false
},
description
: {
type
: Sequelize
.STRING(2000),
allowNull
: false,
defaultValue
: ''
},
order
: {
type
: Sequelize
.FLOAT,
allowNull
: false,
defaultValue
: 0
},
createdAt
: {
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
: {
type
: Sequelize
.DATE,
allowNull
: false
}
}, {
charset
: 'utf8mb4'
});
},
down
: (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('BoardListCard');
}
};
Attachment - 附件
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idoriginNameSTRING(255)‘’nameSTRING(255)typeSTRING(50)sizeINTEGER.UNSIGNED0createdAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initAttachment
module
.exports
= {
up
: (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('Attachment', {
id
: {
type
: Sequelize
.INTEGER.UNSIGNED,
autoIncrement
: true,
primaryKey
: true,
},
userId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
originName
: {
type
: Sequelize
.STRING(255),
defaultValue
: '',
allowNull
: false
},
name
: {
type
: Sequelize
.STRING(255),
defaultValue
: '',
allowNull
: false
},
type
: {
type
: Sequelize
.STRING(50),
allowNull
: false
},
size
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false,
defaultValue
: 0
},
createdAt
: {
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
: {
type
: Sequelize
.DATE,
allowNull
: false
}
}, {
charset
: 'utf8mb4'
});
},
down
: (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('Attachment');
}
};
CardAttachment - 卡片附件关联
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idboardListCardIdINTEGER.UNSIGNEDBoardListCard.idattachmentIdINTEGER.UNSIGNEDAttachment.idisCoverBOOLEAN0createdAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initCardAttachment
module
.exports
= {
up
: (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('CardAttachment', {
id
: {
type
: Sequelize
.INTEGER.UNSIGNED,
autoIncrement
: true,
primaryKey
: true,
},
userId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
boardListCardId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
attachmentId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
isCover
: {
type
: Sequelize
.BOOLEAN
},
createdAt
: {
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
: {
type
: Sequelize
.DATE,
allowNull
: false
}
}, {
charset
: 'utf8mb4'
});
},
down
: (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('CardAttachment');
}
};
Comment - 评论
名称类型是否主键外键关联默认值其它
idINTEGER.UNSIGNEDtrueautoIncrementuserIdINTEGER.UNSIGNEDUser.idboardListCardIdINTEGER.UNSIGNEDBoardListCard.idcontentSTRING(2000)createdAtDATEupdatedAtDATE
终端输入 --> ./node_modules/.bin/sequelize migration:create --name initComment
module
.exports
= {
up
: (queryInterface
, Sequelize
) => {
return queryInterface
.createTable('Comment', {
id
: {
type
: Sequelize
.INTEGER.UNSIGNED,
autoIncrement
: true,
primaryKey
: true,
},
userId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
boardListCardId
: {
type
: Sequelize
.INTEGER.UNSIGNED,
allowNull
: false
},
content
: {
type
: Sequelize
.STRING(2000),
allowNull
: false
},
createdAt
: {
type
: Sequelize
.DATE,
allowNull
: false
},
updatedAt
: {
type
: Sequelize
.DATE,
allowNull
: false
}
}, {
charset
: 'utf8mb4'
});
},
down
: (queryInterface
, Sequelize
) => {
return queryInterface
.dropTable('Comment');
}
};