General improvements for --chdir #14

Closed
wants to merge 4 commits into from

4 participants

@slajax

New Usage

Usage: migrate [options] [command]

Options:

   -e, --env <name>   change the environment

Commands:

   down             migrate down
   up               migrate up (the default command)
   create [title]   create a new migration file with optional [title]
   copy [to, from]  copy migrations from one environment context to another

Running Migrations with Environment Context

  $ migrate -e dev create
    create : migrations/dev/001.js

  $ migrate -e dev up
    up : migrations/dev/001.js
    migration : complete

  $ migrate -e dev down
    down : migrations/dev/001.js
    migration : complete

  $ migrate copy dev prod
    copying : migrations/dev/001.js to migrations/prod/001.js

  $ migrate -e prod up
    up : migrations/prod/001.js
    migration : complete

  $ migrate -e prod down
    down : migrations/prod/001.js
    migration : complete
@slajax slajax Changed --chdir to --env, which creates migration sub dirs with indiv…
…idual .migrate context. Also added copy command for copying migrations upstream logically.
0266b23
@Laboratory

Why need to copy all files between environments?
I can change the connection to the database
I suggest:
$ migrate -env=production
and migrate will created file by name .migrate_production
What do you think?

@slajax

What if the migrations need to change between environments?

Actually it's more then just environment. This allows you to organize your migrations by any context you wish.

$ migrate create --env mysql 
$ migrate create --env mongo
$ migrate up --env mysql
$ migrate up --env mongo

Copy is probably pointless but it was an easy feature ;)

@Laboratory

This is abnormal situation if you have different db structure between environment, i think.
DB in production and development env must be identical.
I suggest use -env param for migration on different db and created migration files
For example:

$migration -env dev -> create file .migration_dev

change db connection

$ migration -env prod -> create file .migration_prod

@slajax

That's an entirely different pull request all together, so I will let you submit that one @Laboratory.

@slajax slajax closed this Jul 28, 2012
@c4milo

+1 I like this PR!. I need it too.

@slajax slajax reopened this Jul 29, 2012
@slajax slajax closed this Nov 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment