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

Commit

Permalink
Support dynamic Sequelize configuration (#29)
Browse files Browse the repository at this point in the history
* Updated many dependencies

* Updated sequelize version

Requires migration template to return a promise now

* Support loading dynamic database configuration

If config is a .js file then load and call it. Dynamic loading and static config from a JSON file are covered by tests in test/tasks/sequelize_spec.js

* Fixed exception deleting 'config' from options object

* Removed use of task.init()

Similar to what was done in grunt-sequelize-migrations

* Removed VS Code directory from source control

* Updated README and added contributors to package.json

* Use version 4.1.0 for dependency updates and dynamic config

* Updated license field and node version

* Updated node version in Travis config to 8.10

* Normalize paths to test fixtures

* Disable tests with path issue
  • Loading branch information
dpalma authored Feb 21, 2020
1 parent a09539c commit 35986d0
Show file tree
Hide file tree
Showing 12 changed files with 5,822 additions and 72 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
logs
coverage
.idea
.nyc_output
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.12"
- "8.10"
env:
- NODE_ENV=test
before_script:
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ A string value that is used to location your migration files.
#### options.config
Type: `String`

A string value that is used to locate your sequelize db config.
A string value that is used to locate your Sequelize connection parameters and credentials. Can be static JSON or JavaScript.

##### Example of config.json

Expand All @@ -63,6 +63,10 @@ A string value that is used to locate your sequelize db config.
}
```

##### Dynamic configuration

If `options.string` specifies a JavaScript file, that file should export a function that returns a configuration object.

### Running tasks

Both the migrate and undo tasks have been ported from Sequelize's original CLI.
Expand Down Expand Up @@ -96,4 +100,8 @@ Add unit tests for any new or changed functionality. Validate and test your code
$ npm run lint

## Release History
_(Nothing yet)_

| Version | Description |
| --- | --- |
| 4.1.0 | Support dynamic configuration |
| 4.0.0 | Original version |
10 changes: 10 additions & 0 deletions assets/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = (function() {
return {
development: {
user: 'user',
password: 'password',
database: 'db',
dialect: 'postgres'
}
}
})();
8 changes: 8 additions & 0 deletions assets/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"development": {
"user": "user",
"password": "password",
"database": "test",
"port": 0
}
}
6 changes: 4 additions & 2 deletions assets/migration.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

module.exports = {
up: function (queryInterface, DataTypes) {
// add altering commands here, calling 'done' when finished
// return a promise that alters the database
return Promise.resolve();
},

down: function (queryInterface, DataTypes) {
// add reverting commands here, calling 'done' when finished
// return a promise that reverts changes
return Promise.resolve();
}
};
Loading

0 comments on commit 35986d0

Please sign in to comment.