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

feat: add support for *sql.DB-registered Go migration #450

Merged
merged 7 commits into from
Jan 25, 2023

Conversation

mfridman
Copy link
Collaborator

@mfridman mfridman commented Jan 22, 2023

Fixes #201 #386 #324

Most of this code is ported over from the large provider branch #378.

This PR adds logic to support *sql.DB-registered Go migrations. We technically do not need the function types, but I found these extremely useful. This should be backwards-compatible.

type GoMigration func(tx *sql.Tx) error
type GoMigrationNoTx func(db *sql.DB) error

The new functions to add/register migrations are:

func AddMigrationNoTx(up, down GoMigrationNoTx) { ... } 
func AddNamedMigrationNoTx(filename string, up, down GoMigrationNoTx) { ... }
  • Add tests for both *sql.DB and *sql.Tx-style Go migrations

@mfridman mfridman added this to the v3.9.0 milestone Jan 22, 2023
@mfridman mfridman mentioned this pull request Jan 22, 2023
Copy link

@cbodonnell cbodonnell left a comment

Choose a reason for hiding this comment

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

looks good 👍

@mfridman
Copy link
Collaborator Author

looks good 👍

Thanks for your help @cbodonnell, if I find some time I'll try and capture this in a blog post over on the goose docs.

@mfridman mfridman merged commit 2032773 into master Jan 25, 2023
@mfridman mfridman deleted the go-migrations-no-tx branch January 25, 2023 13:15
@VojtechVitek
Copy link
Collaborator

Nice work. Thanks @mfridman @cbodonnell 🎉

@mcosta74
Copy link

cool thanks. Any ETA for v3.9.0 ?

@mfridman
Copy link
Collaborator Author

Likely by the end of next week (if not earlier), I'd like to get a few other PR's into that release.

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.

Go Migrations w/ No Transaction
4 participants