Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sakulstra/mongo-migration
Highly inspired by mongration
https://github.com/sakulstra/mongo-migration
Last synced: 11 days ago
JSON representation
Highly inspired by mongration
- Host: GitHub
- URL: https://github.com/sakulstra/mongo-migration
- Owner: sakulstra
- License: mit
- Created: 2018-05-15T17:21:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:16:02.000Z (almost 2 years ago)
- Last Synced: 2024-10-20T06:27:53.409Z (19 days ago)
- Language: JavaScript
- Size: 3.18 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Greenkeeper badge](https://badges.greenkeeper.io/sakulstra/mongo-migration.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.com/sakulstra/mongo-migration.svg?branch=master)](https://travis-ci.com/sakulstra/mongo-migration)
[![codecov](https://codecov.io/gh/sakulstra/mongo-migration/branch/master/graph/badge.svg)](https://codecov.io/gh/sakulstra/mongo-migration)#
Simple, yet powerful mongo migration package
### Features
* tested right fromm the beginning
* mongo-v3### Usage
Sample migration
```js
const config = {
url: "mongodb://localhost/",
database: "migrationTest",
migrationCollection: "migrations"
};const testMigration = new Migration(testConfig);
testMigration.addFile(path.join(__dirname, "./migrations/a.js"));
testMigration.addFile(path.join(__dirname, "./migrations/b.js"));
const result = await testMigration.migrate();
```Migration cleanup
Removes non existent migrations from the migrations database and refreshes the hashes of already executed migrations. **It doesn't actually run any migrations.**:warning: This is a feature you shouldn't be required to use, but there might be rare cases where it get's useful.:warning:
```js
const config = {
url: "mongodb://localhost/",
database: "migrationTest",
migrationCollection: "migrations"
};const testMigration = new Migration(testConfig);
testMigration.addFile(path.join(__dirname, "./migrations/a.js"));
testMigration.addFile(path.join(__dirname, "./migrations/b.js"));
const result = await testMigration.cleanup();
```