goose icon indicating copy to clipboard operation
goose copied to clipboard

[FEATURE REQUEST] Allow to use sqlx.Tx in Go migrations

Open mcosta74 opened this issue 2 years ago • 3 comments

Would be nice if we could allow sqlx.Tx in the go migrations

mcosta74 avatar Mar 22 '22 10:03 mcosta74

Do you mean this package? https://github.com/jmoiron/sqlx

I think if we went down this path it'll bloat the API and we might get additional requests to add other "wrapper" libraries around database/sql.

Something we did discuss was adding ability to support Go migrations without transactions. https://github.com/pressly/goose/issues/201

mfridman avatar Apr 14 '22 01:04 mfridman

Agree, better to stay wrapper agnostic. I like the idea to expose a *sql. Db instead of Tx: it will make easier use some wrapper if needed.

The rationale of my request is that, in case of complex data migrations, the utility functions provided by sqlx (or other wrappers) might help to reduce the code (for instance advanced struct binding)

mcosta74 avatar Apr 14 '22 06:04 mcosta74

You're absolutely right. We've done something similar where Go migrations called an orm tool (https://github.com/upper/db) to simplify writing migrations.

mfridman avatar Apr 15 '22 01:04 mfridman

This functionality has been added in https://github.com/pressly/goose/pull/450. Marking as done.

mfridman avatar Jan 25 '23 13:01 mfridman