flexxnn / sequelize-auto-migrations

Migration generator && runner for sequelize
MIT License
258 stars 166 forks source link

Get empty params when makemigration #65

Closed nvcken closed 5 years ago

nvcken commented 5 years ago

I got

var migrationCommands = [{
        fn: "createTable",
        params: [
            "account",
            {

            },
            {}
        ]
    },

with account models

/* eslint-disable key-spacing, no-multi-spaces */

module.exports = function (DB, { INTEGER, BIGINT, DATE, STRING, ENUM, BOOLEAN, DATEONLY, NOW }) {
  const Model = DB.define('account',
    {
      id:             { type: INTEGER,  allowNull: false, primaryKey: true, autoIncrement: true },
      test_param:     { type: BIGINT,  allowNull: false, defaultValue: 1000 },
      first_name:     { type: STRING,   allowNull: true, defaultValue: 'abc', field: 'first-name' },
      last_name:      { type: STRING,   allowNull: false, defaultValue: '' },
      nickname:       { type: STRING,   allowNull: false, defaultValue: '' },
      gender:         { type: ENUM,     allowNull: false, values: ['male', 'female', 'unknown'], defaultValue: 'unknown' },
      birth_date:     { type: DATEONLY, allowNull: true },
      last_login_dt:  { type: DATE,     allowNull: true },
      created_at:      { type: DATE,     allowNull: true, defaultValue: NOW },
      email:          { type: STRING,   allowNull: false, unique: true },
      password:       { type: STRING,   allowNull: false },
      is_deleted:     { type: BOOLEAN,  allowNull: false, defaultValue: false },
      is_blocked:     { type: BOOLEAN,  allowNull: false, defaultValue: false },
      // city_id -> city.id
    },
    {
      timestamps: false,
      underscored: true,
      tableName: 'account'
    }
  )

  Model.associate = (models) => {
    Model.belongsTo(models.city)
    // Model.hasMany(models.team, { foreignKey: { allowNull: false } })
  }

  return Model
}

occurs with "sequelize": "5.16.0" version

nvcken commented 5 years ago

it works fine with "sequelize": "4.42.0"

devanshug commented 5 years ago

The issue should get fixed if the @flexxnn releases a new version in NPM. As this is solved in new merges.

edrose commented 5 years ago

You can also install directly from git in the meantime.

npm i -D https://github.com/flexxnn/sequelize-auto-migrations.git

nvcken commented 5 years ago

Thanks, It works


"devDependencies": {
    "sequelize-auto-migrations": "flexxnn/sequelize-auto-migrations",