https://github.com/clems71/migrate.js
https://github.com/clems71/migrate.js
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/clems71/migrate.js
- Owner: clems71
- Created: 2016-10-03T12:52:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-07T15:09:55.000Z (almost 9 years ago)
- Last Synced: 2025-08-09T10:52:51.462Z (10 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Migrate.js
## Introduction
This is a minimalist MongoDB only (for the moment) migration framework. It comes with a basic CLI tool to help you manage your database migrations.
## Installation
### Locally
`npm i --save migrate.js`
The CLI tool is available in `./node_modules/migrate.js/migrate.js` or as `migrate.js` if accessed in your scripts section of your package.json file.
### Globally
`npm i -g migrate.js`
The CLI tool is available as migrate.js. Simply execute it from your base project directory, where the migrations folder resides.
## Migration files
Create a folder named `migrations` in your project and store your migration files here. The files should be named with the following pattern : `xxxx-this-is-an-updater.js`.
### Example migration file
```js
// 0001-add-new-field.js
exports.up = function * () {
yield this.updateCollection('products', function * (doc) {
doc.newField = 'this is the extra field'
return doc
})
}
exports.down = function * () {
yield this.updateCollection('products', function * (doc) {
delete doc.newField
return doc
})
}
```