Allow configuration to skip the execute_inline! call#137
Open
nevinera wants to merge 4 commits intoShopify:masterfrom
Open
Allow configuration to skip the execute_inline! call#137nevinera wants to merge 4 commits intoShopify:masterfrom
execute_inline! call#137nevinera wants to merge 4 commits intoShopify:masterfrom
Conversation
5ddc99f to
8accd92
Compare
…ation default to 'allowed', since that matches existing behavior
8accd92 to
39a6fa9
Compare
nevinera
commented
Apr 27, 2023
| **Note:** When developing locally or running tests, LHM runs 'inline' by default, meaning that the | ||
| extra table is not used and the original table is not replaced. If this behavior is not desirable | ||
| for your project, you can disable it by setting `Lhm.disallow_inline!` in the appropriate | ||
| environment file or initializer. |
Author
There was a problem hiding this comment.
Let me know if you think more explanation (of why it does that, or why you might want to opt out of it) is warranted here.
Author
|
Any chance of a review? I'd be happy to make other changes, but this repo feels somewhat forgotten :-/ |
fmichaut-diff
approved these changes
Jan 10, 2025
fmichaut-diff
left a comment
There was a problem hiding this comment.
This has definitively tripped us a dozen times, but for a different reason
LHM does not support virtual columns / foreign keys, and if we forget to temporarily remove the foreign keys at the beginning of the migration, the migration will pass on Dev, but fail on Prod.
We would also like to be able to not run LHM inline on Dev because of theses difference of behavior, and catch errors early instead of catching them when they reach Prod...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Since updating to lhm-shopify, we had a recurring issue where people would write a migration using LHM (we have it in our generator templates), but fill it with normal calls to migration methods like
add_column(:tablename, :colname, :string).Before the upgrade, these calls would get caught immediately, because the schema file wouldn't get the intended changes, and any staging stack based on that branch would not have the column present. But after the upgrade, these calls worked fine locally, and since our staging stacks are based on the schema file (not by running migrations from scratch), we only end up catching these problems in production.
When we realized what was happening, we tracked it to here - the explanations on the change make total sense, but in our case we'd much rather exclude
developmentfrom inlining, so this problem will get caught locally. (You should probably consider dropping thedevelopment?condition entirely - I expect other people are getting surprised here occasionally as well).Implementation
bundle exec rake specsto run all specs)Lhm.disallow_inline!andLhm.inline_allowed?to the base module for configuration purposesLhm.inline_allowed?to the Railtie. Didn't see any tests on this thing, but I'm happy to go learn how to make one if you'd like.Verification
Confirmed locally that with the setting not supplied migrations run inline, and with
Lhm.disallow_inline!called, they do not.Note
If you'd rather drop the 'auto-inline in development' part, that's a smaller change, and I'd be happy to update the PR :-)