-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra Ecto Mix tasks for migrations #131
Conversation
Updating the integrations tests. |
To fix the warnings we need to purge the modules before running migrations on the same module again. You can add a function like this: https://github.com/elixir-lang/elixir/blob/master/lib/mix/test/test_helper.exs#L52 to one of the test helper files in test/support/. Don't add questions to commits, rather post them as comments on the PR or ask on IRC. So please rebase the two last comments so the commit messages are nicer. The rest looks really good, great work! |
Im not sure of the usefulness of running or reverting a single migration, maybe we should have a parameter that allows you to run/revert up until a given migration version/name. |
I have to agree I based I'm open to renaming I like the idea of extending the 'single' versions to accept a version/name or cardinal integer of how far to go, with the latest/pending as a default, but I'm not sure how to reconcile the syntax for I'll rebase, purge, and drop |
I agree, being able to go back and forth until it sits right is important to me, too! —Kai On Dec 11, 2013, at 9:33, Christopher Keele notifications@github.com wrote:
|
What do you think of the following tasks:
If we want to be able to run a single up migration, we can make This is just a proposal, I would love your inputs. /cc @josevalim |
Hi Eric, I love it. —Kai On Dec 11, 2013, at 14:28, Eric Meadows-Jönsson notifications@github.com wrote:
|
I like it. My only objection would be with
That means the migrate task isn't consistent about always moving the schema
|
Here is another proposal to get the best of both so far:
My only question is if |
@josevalim's proposal is good. I think just Should we support "inexact" versions? For example say i have pending migrations 1, 3 and 5. If i do |
I would say that is fine. It could just work. |
^ This is a force push rebase of my feature branch; there was enough churn to merit it. |
The main remaining issue is that my integration tests are still stomping on existing migrations. I've tried a number of things to try and resolve this, to little avail. The naive bumping version numbers + changing migration names doesn't work, for some reason no matter what the migration module is called 5 particular I also tried the purge reccommended by @ericmj, wherein
I'd love help with this: I have no idea what's going on, I'd like to see this out the door, and my brain is a little fried tonight. 😁 |
In some tests you are running the same migration multiple times. Every time you run a migration it will be loaded. Purging in a teardown doesn't help much because you are already naming the migrations differently. If you run the same migration multiple times you need to purge between runs. |
Note, you can use this syntax to purge: test "..." do
# actual test
after
purge [Migration1, Migration2]
end I plan to review this pull request later today and give more insight. Thanks a lot @christhekeele! :D |
Of course, I see it now.
I didn't know that syntax existed! Cool. |
Enum.filter(fn { version, _file } -> | ||
version in versions | ||
end) | ||
|> :lists.reverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum.reverse/1
This looks fantastic, excellent code, docs and tests! I have added minor notes, thank you @christhekeele! |
I've moved all option munging into the task level in a series of 4 commits. The reason why I didn't start off with the logic there is because (linguistically) we have certain expectations when talking about running migrations:
This is clearly insane. The inconsistency is an artifact of what operations we perform with migrations most often. Each of the four commits moves responsibility for deciding how to run migrations further into the tasks. The result, as can be seen by browsing updated tests, is the I'm quite fine with that, but wasn't sure how you felt about the trade-off. You should be able to merge any of the four commits to suite your taste. I'll push them one-by-one to my feature branch so that travis makes sure each one is green. |
Exposes new task `ecto.rollback` for reverting migrations, and adds options `--all`, `--step n`, and `--to version` to both `ecto.rollback` and `ecto.migrate`. Deprecates calls to Migrator.run_all, which will for now warn, delegate to Migrator.run, and behave identically to the old implementation.
- Direction is an explicit parameter - Defaults are now handled by function clauses - Allows non-strategy options to be consumed - Deprecation warning removed - Docs follow conventions - 'strategies' vs 'strategy_types' no longer conflated
Whoops, travis went dark because elixir got updated! Bad timing. On the other hand, I got to know about the release 18 minutes before anyone else! I rebased off of master trying to figure out if the update to |
@christhekeele superb work. Thanks for splitting it in commits! This is on my plate now, I will merge it soon. :) ❤️ 💚 💙 💛 💜 |
Re: https://groups.google.com/forum/#!topic/elixir-lang-talk/jg9jA9WC5f8