From 6d10baf5eab25dc731030954c976db335953d22d Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 30 Dec 2023 23:47:44 -0500 Subject: Fix error handling around transcation --- internal/repositories/migration.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/repositories/migration.go b/internal/repositories/migration.go index 562b2e5..8fb8033 100644 --- a/internal/repositories/migration.go +++ b/internal/repositories/migration.go @@ -154,13 +154,23 @@ func (mr *MigrationRepo) Apply(migration *models.Migration) error { return err } - tx.Exec(string(contents)) - tx.Exec( + _, err = tx.Exec(string(contents)) + if err != nil { + return err + } + + _, err = tx.Exec( `INSERT INTO bolt_migrations(version) VALUES ($1);`, migration.Version, ) + if err != nil { + return err + } migration.Applied = true - tx.Commit() + err = tx.Commit() + if err != nil { + return err + } return nil } -- cgit v1.2.3