Node.js 续集迁移节点
我不熟悉续集和迁移。 我想从另一张桌子上取外键,但我做错了,我不知道为什么 有什么建议吗Node.js 续集迁移节点,node.js,sequelize.js,Node.js,Sequelize.js,我不熟悉续集和迁移。 我想从另一张桌子上取外键,但我做错了,我不知道为什么 有什么建议吗 *module.exports = { up: async (queryInterface, Sequelize) => { return queryInterface.createTable('comments',{ topicid : { type:Sequelize.INTEGER, foreignKey : true },
*module.exports = {
up: async (queryInterface, Sequelize) => {
return queryInterface.createTable('comments',{
topicid : {
type:Sequelize.INTEGER,
foreignKey : true
},
commentid : {
type : Sequelize.INTEGER,
primaryKey:true,
autoIncrement:true,
},
comment : {
type : Sequelize.STRING
}
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
};*
“严格使用”;
module.exports={
up:(查询接口,续集)=>{
返回queryInterface.createTable('注释'{
评论ID:{
自动递增:真,
primaryKey:没错,
类型:Sequelize.INTEGER
},
主题:{
外键:没错,
参考资料:{
型号:'',
键:“”
},
类型:Sequelize.INTEGER
},
评论:{
类型:Sequelize.STRING
}
});
},
向下:(查询接口,续集)=>{
返回queryInterface.dropTable('Products');
}
};
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('comments', {
commentid: {
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
topicid: {
foreignKey: true,
references: {
model: '<name_of_the_model>',
key: '<name_of_the_key>'
},
type: Sequelize.INTEGER
},
comment: {
type: Sequelize.STRING
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Products');
}
};