@buttersolutions/phanti
v0.2.0
Published
Utilitary CLI to run mongo migrations using mongoose and typrescript
Downloads
988
Readme
Phanti
Phanti is an online migration tool for MongoDB using typescript. Currenty, it only supports migration, but later it will also support seeding.
Installation
To install our CLI, you can run:
npm install --global @buttersolutions/phanti ts-node
Migration
Migration are used to track the schema changes in our database. Although MongoDB is a document based database, not having track to what were the schema changes and possible reverts to those could lead to errors.
How to create a migration
NOTE: First you need to create a migration directory on the root of your project
To create a migration, simply run:
phanti migration create <name>
For example
phanti migration create add-users-surname
The command above will create the file migrations/<timestamp>-add-users-surname.ts
with a
template so you can write your migrations.
How to run migrations
NOTE: An example on how to write migration is in the examples
directory on this repostitory
To run all available migrations, simply run:
phanti migration run -d "<database_url>"
The command above will run all migrations that haven't been run yet according to the MetadataMigration collection in your database, which are all the migrations created after the last saved date on the collection metioned above.