找不到迁移方法:up [英] Could not find migration method: up
问题描述
我无法将我的模型迁移到 MySQL 数据库.它向我抛出以下错误:
<块引用>加载的配置文件config\config.json".使用环境开发".(节点:5828)[SEQUELIZE0004] 弃用警告:一个布尔值被传递给 options.operatorsAliases.这是 v5 的空操作,应该删除.== 20191218125700-mig_admin_roles:迁移 ========
错误:找不到迁移方法:向上
模型- admin_user.js
<预><代码>module.exports = (sequelize, DataTypes) =>{{var admin_users = sequelize.define("adminUser", {ID: {类型:DataTypes.INTEGER(22),allowNull: 假,主键:真,自动增量:真,字段:身份证"},名称:{类型:DataTypes.STRING(20),allowNull: 假,字段:fname"},名称:{类型:DataTypes.STRING(20),allowNull: 真,字段:名称"},电话号码: {类型:DataTypes.STRING(20),allowNull: 假,字段:电话号码"},电子邮件ID: {类型:DataTypes.STRING(20),allowNull: 假,独特:真实,字段:电子邮件ID"},活跃: {类型:DataTypes.BOOLEAN,allowNull: 假,默认值:0",字段:isActive"},密码: {类型:DataTypes.STRING(128),允许空值:假,字段:密码"}});admin_users.associate = 模型 =>{admin_users.hasMany(models.adminRole, {外键:角色ID"});};返回 admin_users;}};迁移:mig-admin_user.js
"使用严格";模块.出口 = {up: (queryInterface, Sequelize) =>{返回 queryInterface.createTable("adminUser", {ID: {类型:Sequelize.INTEGER(22),allowNull: 假,主键:真,自动增量:真,字段:身份证"},名称:{类型:Sequelize.STRING(20),allowNull: 假,字段:fname"},名称:{类型:Sequelize.STRING(20),allowNull: 真,字段:名称"},电话号码: {类型:Sequelize.STRING(20),allowNull: 假,字段:电话号码"},电子邮件ID: {类型:Sequelize.STRING(20),allowNull: 假,独特:真实,字段:电子邮件ID"},活跃: {类型:Sequelize.BOOLEAN,allowNull: 假,默认值:0",字段:isActive"},密码: {类型:Sequelize.STRING(128),允许空值:假,字段:密码"}});},向下: (queryInterface, Sequelize) =>{/*在此处添加恢复命令.返回一个正确处理异步的承诺.例子:return queryInterface.dropTable('users');*/}};
我尝试查找此特定错误,但找不到任何内容.谁能告诉我哪里出错了?
你需要一个 .sequelizerc
在你的项目的根目录中,它包含如下内容:
module.exports = {'配置':'数据库/config.js','迁移路径':'数据库/迁移','播种机路径':'数据库/播种机'}
并且您必须指出您的迁移位于何处.
I am unable to migrate my models to MySQL db. It's throwing me the below error:
Loaded configuration file "config\config.json". Using environment "development". (node:5828) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed. == 20191218125700-mig_admin_roles: migrating =======
ERROR: Could not find migration method: up
models- admin_user.js
module.exports = (sequelize, DataTypes) => {
{
var admin_users = sequelize.define("adminUser", {
id: {
type: DataTypes.INTEGER(22),
allowNull: false,
primaryKey: true,
autoIncrement: true,
field: "id"
},
fname: {
type: DataTypes.STRING(20),
allowNull: false,
field: "fname"
},
lname: {
type: DataTypes.STRING(20),
allowNull: true,
field: "lname"
},
phoneNo: {
type: DataTypes.STRING(20),
allowNull: false,
field: "phoneNo"
},
emailId: {
type: DataTypes.STRING(20),
allowNull: false,
unique: true,
field: "emailId"
},
isActive: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: "0",
field: "isActive"
},
password: {
type: DataTypes.STRING(128),
allownull: false,
field: "password"
}
});
admin_users.associate = models => {
admin_users.hasMany(models.adminRole, {
foreignKey: "roleId"
});
};
return admin_users;
}
};
migration: mig-admin_user.js
"use strict";
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable("adminUser", {
id: {
type: Sequelize.INTEGER(22),
allowNull: false,
primaryKey: true,
autoIncrement: true,
field: "id"
},
fname: {
type: Sequelize.STRING(20),
allowNull: false,
field: "fname"
},
lname: {
type: Sequelize.STRING(20),
allowNull: true,
field: "lname"
},
phoneNo: {
type: Sequelize.STRING(20),
allowNull: false,
field: "phoneNo"
},
emailId: {
type: Sequelize.STRING(20),
allowNull: false,
unique: true,
field: "emailId"
},
isActive: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: "0",
field: "isActive"
},
password: {
type: Sequelize.STRING(128),
allownull: false,
field: "password"
}
});
},
down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
}
};
I tried looking for this particular error, but couldn't find anything. could anyone please tell where i might be going wrong?
You need a .sequelizerc
in the root of your project and it contains something like this :
module.exports = {
'config': 'database/config.js',
'migrations-path': 'database/migrations',
'seeders-path': 'database/seeders'
}
And you have to point where are your migrations been located.
这篇关于找不到迁移方法:up的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!