Skip to content

Add context support to Exec methods#247

Merged
rubenv merged 2 commits intorubenv:masterfrom
sarajmunjal:saraj/ctx
Jun 5, 2023
Merged

Add context support to Exec methods#247
rubenv merged 2 commits intorubenv:masterfrom
sarajmunjal:saraj/ctx

Conversation

@sarajmunjal
Copy link
Copy Markdown
Contributor

What
This PR allows passing Go native context to Exec/ExecMax methods declared globally and on the MigrationSet struct.

Why
Golang contexts are an elegant way to control program flow. With Exec methods, contexts will enable timing out while running large migrations. In production, long-running DDL migration queries on large tables can obtain exclusive locks and cause downtime.
Behavior can be seen in the newly added test TestContextTimeout.

@rubenv
Copy link
Copy Markdown
Owner

rubenv commented Jun 5, 2023

Would have added context parameters in the first place if I were to start sql-migrate nowadays, but sadly it predates it.

Adding them with extra methods feels consistent with the rest of the standard library. Also really like the added unit test.

Good stuff!

@rubenv rubenv merged commit 61ee1bf into rubenv:master Jun 5, 2023
@sarajmunjal
Copy link
Copy Markdown
Contributor Author

@rubenv sorry if this is the wrong place to ask, but what's the process to get a new version released with this PR?

@rubenv
Copy link
Copy Markdown
Owner

rubenv commented Jun 23, 2023

@sarajmunjal I just pushed version 1.5.0!

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