-
Notifications
You must be signed in to change notification settings - Fork 176
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
Helper Methods #111
Comments
Personally, I'd prefer suffix methods as it is obvious what is the difference, while I will always forget what is the difference between bang/nobang methods. And this won't change behavior of existing Rails methods. As for To solve mentioned trade-offs, maybe it will be better to expand a little existing warning messages, something like this:
So, having 2 logical blocks: 1) general theory and 2) some notes on how process can be simplified by available methods, if available. |
Any interest in doing it in a separate gem? I feel like that would keep the focus of this one small and clear. It also makes it easy to opt-in or out via Bundler rather than gem configuration. |
Hey @Skipants, that sounds like the best approach. The gem could include the helpers as well as override Strong Migration's error messages to use the helpers. @fatkodima Is this something you're interested in creating and running? |
Hey. I'm more on the side of mine approach. |
No worries. However, I think it's better as a separate gem at this point. Going to close out the existing PRs, but I appreciate the contributions. |
Has anyone started on this separate gem, @ankane ? |
Hey @kkumler, not that I'm aware of. |
@kkumler There's https://github.com/doctolib/safe-pg-migrations that provides some helper methods. |
@pirj Thanks for the consideration to mention me after so long. |
Thanks, @pirj! |
Beware, |
@mvz @pirj @Skipants @kkumler I created a separate gem with helpers 🎉 Aka It has helpers for renaming tables/columns, changing columns types (including changing primary keys from Just need to make a release. |
I think helper methods can be very powerful for Strong Migrations (shout-out to @fatkodima for lots of work on this and GitLab for popularizing the concept), but it's a fundamental change from the approach Strong Migrations has taken in the past, so I wanted to discuss it here and get feedback from the community.
Trade-offs
Currently, Strong Migrations is focused on keeping the migration experience consistent with vanilla Rails and educating users on what's not safe. The advantages are:
Helper methods change this by introducing new methods that make it less obvious about what's going on behind-the-scenes. The advantages are:
Choice
The good news is we can give teams a choice.
This will:
If one is overwhelmingly preferred, we can consider removing the other in the future.
The drawbacks of a choice are:
Implementation
Two options that come to mind are:
Prefix or suffix methods
Override existing methods (eliminates need for
safety_assured
)This doesn't require users to learn new methods, but it's more invasive, as it changes the behavior of existing Rails methods.
Would love to hear everyone's thoughts.
The text was updated successfully, but these errors were encountered: