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

Receive context in migrations #534

Merged
merged 4 commits into from
Jun 29, 2023

Conversation

ori-shalom
Copy link
Contributor

@ori-shalom ori-shalom commented Jun 11, 2023

This PR is a follow-up to PR #517.
It's currently based on top of piiano:feat/allow-setting-context so when #517 will get merged I'll rebase it.

This PR allows defining migrations that receive context.
Old migrations that don't receive context.Context will still continue to work for backward compatibility.
The generation of new Go migrations changed to generate migrations that receive context.

@ori-shalom ori-shalom mentioned this pull request Jun 11, 2023
@ori-shalom
Copy link
Contributor Author

Hi @mfridman, by any chance can you review this PR too so adding context support to v3 will be complete?

if err != nil {
return -1, err
}

return version, nil
}

// withContext changes the signature of a function that receives one argument to receive a context and the argument.
func withContext[T any](fn func(T) error) func(context.Context, T) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@mfridman
Copy link
Collaborator

Hi @mfridman, by any chance can you review this PR too so adding context support to v3 will be complete?

@ori-shalom Sure, can you please rebase this PR?

@mfridman
Copy link
Collaborator

Actually, I'll merge this and make a few comment updates. Thanks for a clean implementation, looks sane to me!

Copy link
Collaborator

@mfridman mfridman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@mfridman mfridman merged commit e18fac6 into pressly:master Jun 29, 2023
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