Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

options for development, without an extern config file? #18

Closed
ErikvdVen opened this issue Oct 29, 2014 · 3 comments
Closed

options for development, without an extern config file? #18

ErikvdVen opened this issue Oct 29, 2014 · 3 comments

Comments

@ErikvdVen
Copy link

According to the grunt documentation http://gruntjs.com/configuring-tasks#options, something like this should work:

    sequelize:{
      options: {
        migrationsPath: __dirname + '/migrations',
        dialect:  'postgres',
        username: '<%= env_config_live.db.postgres.user %>',
        password: '<%= env_config_live.db.postgres.password %>',
        port: '<%= env_config_live.db.postgres.port %>',
        database: '<%= env_config_live.db.postgres.database %>',
        host:     '<%= env_config_live.db.postgres.host %>'
      },

      dev:{
        options: {
          migrationsPath: __dirname + '/migrations',
          dialect:  'postgres',
          username: '<%= env_config_dev.db.postgres.user %>',
          password: '<%= env_config_dev.db.postgres.password %>',
          port: '<%= env_config_dev.db.postgres.port %>',
          database: '<%= env_config_dev.db.postgres.database %>',
          host:     '<%= env_config_dev.db.postgres.host %>'
        }
      }
    }

But it doesn't. After executing grunt sequelize:dev:migrate I receive this error:

Running "sequelize:dev:migrate" (sequelize) task
Warning: Unknown grunt-sequelize command: dev Use --force to continue.
Error: Unknown grunt-sequelize command: dev
@maxmalov
Copy link
Collaborator

Hi. All configurations in examples are for tasks that actually do one thing (concat, uglify etc.). That kind of tasks are also called multi tasks. In other words they have 2 level nesting. So your example should describe the sequelize:dev task. But sequelize task do more than one thing.

I think environment specific configuration should be based on the NODE_ENV variable and config file (like in RoR and original sequelize-cli tool). It allows you share the configuration settings between your applications and other helper tools (grunt, gulp etc) for all environments. For example if we want to run migrations for tests, then it should looks like NODE_ENV=test grunt sequelize:migrate.

I've recently bumped an issue in the CLI tool. They also stick with RoR ideology with environment variable and configuration file. I think in future we'll reuse theirs code base for migrations and other sequelize related things, so now I'm trying to be on the same wave with them.

@ErikvdVen
Copy link
Author

Ok, thank you for your response. I'll try to use the node environment variable to specify the right settings, as you told...

@maxmalov
Copy link
Collaborator

maxmalov commented Nov 1, 2014

You also can use sequelize-cli to generate config file, ex:

npm i -g sequelize-cli
sequelize init:config --config [path where you want to store it]

Then modify it according to your database settings.

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

No branches or pull requests

2 participants