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

Wrapping migration files in transactions #60

Closed
lzap opened this issue Jun 15, 2022 · 2 comments
Closed

Wrapping migration files in transactions #60

lzap opened this issue Jun 15, 2022 · 2 comments

Comments

@lzap
Copy link
Contributor

lzap commented Jun 15, 2022

Hello,

since tern use transactions for each migration, is it safe to wrap each migration file between BEGIN/COMMIT statements? We are migrating from golang-migrate to tern and we have these, so I wonder if I need to remove them. It appears to work just fine, but would love to hear an official word :)

Thanks!

@jackc
Copy link
Owner

jackc commented Jun 15, 2022

The begin would be ignored as you are already in a transaction. But the commit would actually commit the transaction.

The only problem is a failure that occurred in the tiny window between finishing your migration and tern updating the version table would mean your migration would have been applied but that fact didn't get recorded. Hence a subsequent migration run would attempt to rerun the same migration.

@lzap
Copy link
Contributor Author

lzap commented Jun 17, 2022

Ok so the recommendation is not to have these BEGIN/COMMIT statements in migration files. Removed, thanks!

@lzap lzap closed this as completed Jun 17, 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

No branches or pull requests

2 participants