sequelize-auto-migrations icon indicating copy to clipboard operation
sequelize-auto-migrations copied to clipboard

Does not recognize custom folder position

Open Mixermachine opened this issue 5 years ago • 3 comments

Hy there,

I use sequelize in an existing project which forces me to put everything that is not configuration in a src folder.

- package.json
+ config
-- config_sequelize.json
-- sequelize_init.json
+ src
++ models
++ migrations
++ models
++ routes
++ seeders
...

(+ for folders, - for files)

For sequelize I define this in the package.json "sequelize": "sequelize --options-path=config/sequelize_init.js",

sequelize_init.json:

const path = require('path');
module.exports =  {

  config: path.join(__dirname, '/config_sequelize.json'),
  'migrations-path': path.join(__dirname, '../src/migrations'),
  'seeders-path': path.join(__dirname, '../src/seeders'),
  'models-path': path.join(__dirname, '../src/models')
};

Is this possible with sequelize-auto-migrations? Passing the sequelize_init.js failed.

Would be great as a feature :)

Greetings from Munich

Mixermachine avatar Jun 16 '19 07:06 Mixermachine

If you have a .sequelizerc file it will respect that and load from there.

Scimonster avatar Jun 17 '19 09:06 Scimonster

@Scimonster Thanks, after renaming my config js to .sequelizerc it starts. Sadly sequelize-auto-migrations does not seem to like my database model. I only get empty tables.

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

            },
            {}
        ]
    },
    {
        fn: "createTable",
        params: [
            "Participants",
            {

            },
            {}
        ]
    },
    {
        fn: "createTable",
        params: [
            "Payees",
            {

            },
            {}
        ]
    },
    {
        fn: "createTable",
        params: [
            "PaymentMethods",
            {

            },
            {}
        ]
    },

Mixermachine avatar Jun 19 '19 06:06 Mixermachine

Having the same issue as @Mixermachine. Generated migrations file has empty tables.

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

            },
            {}
        ]
    },
    {
        fn: "createTable",
        params: [
            "Table2",
            {

            },
            {}
        ]
    },
    {
        fn: "createTable",
        params: [
            "Table3",
            {

            },
            {}
        ]
    },

    ...

This is the model file example:

module.exports = (Sequelize, {
  BOOLEAN, DOUBLE, INTEGER, STRING,
}) => Sequelize.define('Data', {
  // some data
  data: {
    type: BOOLEAN,
    defaultValue: false,
  },

  // mark record as deleted
  isDeleted: {
    type: BOOLEAN,
    defaultValue: false,
  },
  // 10 digits timestamp
  created: {
    type: INTEGER,
  },
  // 10 digits timestamp
  updated: {
    type: INTEGER,
  },
  // model name
  entity: {
    type: STRING,
    defaultValue: 'modelName',
  },
});

peterdee avatar Jul 03 '19 12:07 peterdee