fix(my-todos): use *sql.Conn instead of *sql.DB for migrations

mymigrate.New now requires *sql.Conn. Add replace directives to
use local (unreleased) backend modules.
This commit is contained in:
AJ ONeal 2026-04-09 13:50:30 -06:00
parent 14e08c321a
commit 2bf5102c32
No known key found for this signature in database
3 changed files with 14 additions and 5 deletions

View File

@ -10,3 +10,8 @@ require (
) )
require filippo.io/edwards25519 v1.1.0 // indirect require filippo.io/edwards25519 v1.1.0 // indirect
replace (
github.com/therootcompany/golib/database/sqlmigrate => ../../../../database/sqlmigrate
github.com/therootcompany/golib/database/sqlmigrate/mymigrate => ../../../../database/sqlmigrate/mymigrate
)

View File

@ -4,7 +4,3 @@ github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/therootcompany/golib/database/sqlmigrate v1.0.2 h1:hcmhYyUFVj/GqyChP+0Ry2WZCHnoruFMbsy+2KVzsfA=
github.com/therootcompany/golib/database/sqlmigrate v1.0.2/go.mod h1:7PQUjwT78Hx+SftcIKI2PH4zSFlrSO0V9h618PJqC38=
github.com/therootcompany/golib/database/sqlmigrate/mymigrate v1.0.2 h1:VLJbyDrACQYISfFLMZHn5b8Q8ywVjswtDjy+8Et8HBY=
github.com/therootcompany/golib/database/sqlmigrate/mymigrate v1.0.2/go.mod h1:zr+08WaGE+2V1dgrDUzrST7EuiJ4L+0XNNyMpqdl9CE=

View File

@ -70,8 +70,16 @@ func main() {
} }
defer func() { _ = db.Close() }() defer func() { _ = db.Close() }()
// migrations require a single connection, not a pool
conn, err := db.Conn(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: acquiring connection for migrations: %v\n", err)
os.Exit(1)
}
defer func() { _ = conn.Close() }()
migrations := mustCollectMigrations() migrations := mustCollectMigrations()
runner := mymigrate.New(db) runner := mymigrate.New(conn)
subcmd := args[0] subcmd := args[0]
subArgs := args[1:] subArgs := args[1:]