migration-manager
v1.1.2
Published
Simple migration manager based on sequelize.
Downloads
11
Readme
migration-manager
This is a migration manager base on sequelize.
It is not auto diff generated migration tool which I am looking for but can't find.
This package only do two things.
- auto generate "migrate"-{{Date}}-{{RandomString}} file.
- Execute migration file created on step 1 and record on table
migration
inside database.
Only support mysql now.
How to use
You have to install nodejs at least 8 which native support async/await.
> npm install -g migration-manager
Inside your project, you have to create ./config/config.json
and ./migrations
../config/config.json
is Sequelize configuration format( option attributes please consult sequelizejs doc). You can consult this repo for example../migrations
folder would store all migration files. Currently doesn't support custom path.
Then execute migration-manager inside your project. The path matters.> migration-manager a <type>
would copy template based on type. Currently support sql
which you can write multi raw queries and js
which support Sequelize migration file format(slightly different).
> migration-manager e
to execute migrations. All migrations would be wrapped into one big transactions for data integrity!
After successfully executed, the migrations file would be record inside db table migration
to avoid repeat execution.
Test
Using docker as test environments tool.
You have to install docker first and run docker run --name my-
mysql -e MYSQL_ROOT_PASSWORD=my-password -d -p 3306:3306 mysql
to start mysql locally.
Then run
> docker build test .
> docker run --link my-mysql:mysql --rm test ./test/test.sh
TODO
~~1. Add fully test.~~
2. Support other db, at least compat all Sequelize support list.