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

Does not recognize custom folder position #55

Open
Mixermachine opened this issue Jun 16, 2019 · 3 comments
Open

Does not recognize custom folder position #55

Mixermachine opened this issue Jun 16, 2019 · 3 comments

Comments

@Mixermachine
Copy link

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

@Scimonster
Copy link

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

@Mixermachine
Copy link
Author

@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",
            {

            },
            {}
        ]
    },

@peterdee
Copy link

peterdee commented Jul 3, 2019

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',
  },
});

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

3 participants