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

Wrap each migration into its own transaction #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kruszczynski
Copy link

Hi!

I appreciate postgres-shift a lot! It's a wonderful, small, single purpose library. Thanks for creating it!

I come here with a suggestion to wrap each migration into its own transaction.

I grew up in Ruby on Rails universe and their transactions do this. As do the transactions in Ecto, Elixir's ORM.

I learned why it might be a good idea this week. I was extending a postgres Enum and then creating backfill records that used the newly created value. Instinctively I did that in separate migrations.

I didn't notice any issues in development because I ran each migration as I was writing it. Only once I shipped both migration in one PR I learned on our staging environment that one cannot create records referencing enum values added in the same transaction.

So please let me know if you'd consider adding this and releasing an updated version.

All the best,
Bartek

@kruszczynski kruszczynski force-pushed the each-migration-in-its-own-transaction branch from ef4a683 to 57bf965 Compare September 23, 2024 16:21
@porsager
Copy link
Owner

Thanks :)

It's fine if you put it behind an option.

@kruszczynski kruszczynski force-pushed the each-migration-in-its-own-transaction branch from 57bf965 to 14586d2 Compare December 31, 2024 13:33
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.

2 participants