JohanObrink / rethink-migrate

A migration tool for rethink db
MIT License
47 stars 24 forks source link

patch to run one up migration #27

Open jordanh opened 8 years ago

jordanh commented 8 years ago

After reading README.md I'm not sure if this feature was intentionally omitted or not. But, we'd like it.

Closes #26.

JohanObrink commented 8 years ago

Thanks for the PR. Unfortunately I cannot merge it since it would break existing functionality. It would mean all existing users (including me) would have to update their build scripts to add the --all flag.

Since the default behaviour in a build environment is to run all up migrations, the flag really shouldn't have to be added there. On the other hand running migrate down on one, failed migration in the build environment is inadequate as well.

image

What I think is the correct solution is this:

  1. rethink-migrate up runs all outstanding up migrations
  2. If rethink-migrate up fails, it automatically rolls back all completed up migrations
  3. rethink-migrate up --one runs only one up migration - this is primarily for testing locally
  4. rethink-migrate down runs all down migrations
  5. If rethink-migrate down fails, no action needs to be taken since it's a recoverable failure
  6. rethink-migrate down --one runs only one down migration - this is primarily for testing locally

What do you think?

If you agree with this idea, I (or you if you want 😄 ) can start by adding a --one flag so that one up migration can be run.

jordanh commented 8 years ago

Sure. That sounds just peachy. 🍑

I implemented the easy part of this: --all or --one without rollback. If you like it, it can serve as a starting point for the more robust version.

xfg commented 8 years ago

@JohanObrink I like your decision. Is there any progress on this issue?

jordanh commented 8 years ago

@xfg - I think think this is ready to merge. After merging, we should create a new issue to later enhance rethink-migrate to apply migrations atomically. That was a good suggestion from @JohanObrink.