Could not find migration method: up

拟墨画扇 提交于 2021-01-29 11:07:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/59406974/could-not-find-migration-method-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!