Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't generate field information #69

Open
ghost opened this issue Oct 20, 2019 · 7 comments
Open

Doesn't generate field information #69

ghost opened this issue Oct 20, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Oct 20, 2019

I have a model generated by Sequelize with the following information:

module.exports = (sequelize, DataTypes) => {
  const user = sequelize.define('test', {
    firstName: DataTypes.STRING,
    lastName: DataTypes.STRING,
    email: DataTypes.STRING,
    testField: DataTypes.STRING,
    anotherTest: DataTypes.STRING
  }, {});
  user.associate = function(models) {
    // associations can be defined here
  };
  return user;
};

Running makemigration generates the following:

'use strict';

var Sequelize = require('sequelize');

/**
 * Actions summary:
 *
 * createTable "users", deps: []
 *
 **/

var info = {
    "revision": 1,
    "name": "user",
    "created": "2019-10-20T04:47:04.496Z",
    "comment": ""
};

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

        },
        {}
    ]
}];

module.exports = {
    pos: 0,
    up: function(queryInterface, Sequelize)
    {
        var index = this.pos;
        return new Promise(function(resolve, reject) {
            function next() {
                if (index < migrationCommands.length)
                {
                    let command = migrationCommands[index];
                    console.log("[#"+index+"] execute: " + command.fn);
                    index++;
                    queryInterface[command.fn].apply(queryInterface, command.params).then(next, reject);
                }
                else
                    resolve();
            }
            next();
        });
    },
    info: info
};

Doesn't look like there is any code related to the fields. Running runmigration confirms this since it only creates the table with no fields in it.

Is it something I'm just doing wrong?

@shawn246
Copy link

Same problem. Only table generated, no columns.

@moda20
Copy link

moda20 commented Jan 5, 2020

This is still a problem

@moda20
Copy link

moda20 commented Jan 5, 2020

if you can check, please check my pull request that fixes this specific issue, it is just that sequelize 5.x changed some attributes

@mgbiedma
Copy link

mgbiedma commented Jan 13, 2020

@flexxnn please accept @moda20 's PR, we are stuck in Sequelize 4.x

@Naddyson
Copy link

Naddyson commented Mar 11, 2020

@moda20 I had an issue with your fix. I changed property path to models and it's worked fine with autogenerated models/index.js

This pull request fix this issue #75

@Naddyson
Copy link

If you faced this problem you can download my fork fixing this issue.

https://github.com/Naddyson/sequelize-auto-migrations

@prabhatCH
Copy link

This repo is dead and not being maintained anymore.
Head over to https://github.com/MRVMV/sequelize-mig fork which is being actively maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants