rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.16k stars 269 forks source link

Add context support to Exec methods #247

Closed sarajmunjal closed 1 year ago

sarajmunjal commented 1 year ago

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 commented 1 year ago

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!

sarajmunjal commented 1 year ago

@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 commented 1 year ago

@sarajmunjal I just pushed version 1.5.0!