Skip to content
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

Add detailed error message to IrreversibleMigration #21412

Merged

Conversation

yui-knk
Copy link
Contributor

@yui-knk yui-knk commented Aug 28, 2015

No description provided.

@@ -69,7 +69,7 @@ def record(*command, &block)
# invert the +command+.
def inverse_of(command, args, &block)
method = :"invert_#{command}"
raise IrreversibleMigration unless respond_to?(method, true)
raise IrreversibleMigration, "#{method} is not defined, so #{command} is not reversible" unless respond_to?(method, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should talk about the method here. It is something internal to Rails, users don't need to care about it. Maybe something like: "This migration uses #{command} that is not automatically reversible, please ensure you have a down method"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thank you I will rewrite later !

@yui-knk
Copy link
Contributor Author

yui-knk commented Aug 28, 2015

Updated and I add Gemfile.lock mistakenly. I will remove Gemfile.lock when I squash these commits.

@@ -69,7 +69,7 @@ def record(*command, &block)
# invert the +command+.
def inverse_of(command, args, &block)
method = :"invert_#{command}"
raise IrreversibleMigration unless respond_to?(method, true)
raise IrreversibleMigration, "This migration uses #{command} that is not automatically reversible, please define down method" unless respond_to?(method, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we suggest defining a down method, this means that the user also needs to change def change to def up.

Another option would be a reversible do |dir| block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot reversible do |dir| 😢
I will rewrite once more :)

@senny
Copy link
Member

senny commented Aug 28, 2015

It's a good idea to make the exception message more descriptive. At the same time we should improve the rDocs of IrreversibleMigration. Let's put some examples there how you can mitigate the problem.

  1. by using up and down
  2. by using reversible do |dir|

@yui-knk
Copy link
Contributor Author

yui-knk commented Aug 30, 2015

@senny updated!

@yui-knk yui-knk closed this Aug 30, 2015
@yui-knk yui-knk reopened this Aug 30, 2015
@rafaelfranca
Copy link
Member

r? @senny

nokogiri (1.6.6.2-x64-mingw32)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this belongs into the patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove now this

@senny senny merged commit 4ca27c2 into rails:master Sep 4, 2015
senny added a commit that referenced this pull request Sep 4, 2015
…_error_msg

Add detailed error message to `IrreversibleMigration`
@senny
Copy link
Member

senny commented Sep 4, 2015

@yui-knk thanks 💛 I made some minor modifications in the merge commit.

Sadly I forgot to check wether the commits are squashed 😓, please amend review changes directly to keep the PR in a mergable state at all times. This helps reviewers a lot.

@yui-knk
Copy link
Contributor Author

yui-knk commented Sep 4, 2015

@senny Thanks for your review and merge. And sorry to my mistake 😢
I confused rails way with this.

Do not squash until the branch is ready to merge. Reviewers should be able to read individual updates based on their earlier feedback.

I will be careful from now on :)

@senny
Copy link
Member

senny commented Sep 4, 2015

@yui-knk could you point me to the place where you found that sentence?

@yui-knk
Copy link
Contributor Author

yui-knk commented Sep 4, 2015

@senny
6th of list item of "Having Your Code Reviewed".
But this is thoughtbot/guides (not rails guide).

I found nothing related with "Do not squash" in Rails Guide.

@jbilbo
Copy link

jbilbo commented Sep 4, 2015

@senny @yui-knk It makes sense for big PRs but I don't think it's practical with small ones like this.
But yeah... @rails-bot also recommends it, for example: #21502 (comment)

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants