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

Keep migrations consistent after Rails upgrades #68

Merged

Conversation

thoughtbot-summer
Copy link
Contributor

We recently upgraded a project from Rails v6.1 to v7.0, which changed the default precision for datetime columns from nil to 6. PgParty currently calls ActiveRecord::ConnectionAdapters::SchemaStatements#create_table (and #change_column_null) directly, which doesn't include the backwards compatibility provided by ActiveRecord::Migration::Compatibility. Thus, re-running our existing migrations generated those datetime columns with precision: 6 instead of precision: nil.

This change uses Proc#binding/Binding#receiver to call those methods on the ActiveRecord::Migration instance instead, which includes that backwards compatibility.

Thank you!

@rkrage
Copy link
Owner

rkrage commented Aug 15, 2022

Thanks for the PR and all the context!

It seems like this should work but it feels a little strange. I'm going to dig into this a bit to see if maybe there's an alternative approach. I should probably write some migration compatibility tests too. Seems like a pretty big miss on my end...

@rkrage
Copy link
Owner

rkrage commented Dec 21, 2022

Sorry, haven't really had time to look into this. Gonna go ahead and merge

@rkrage rkrage merged commit 2d20b28 into rkrage:master Dec 21, 2022
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

2 participants