Setup and run go linters

This commit is contained in:
2024-09-29 22:12:58 +02:00
parent b20c66d257
commit a8da48b557
5 changed files with 57 additions and 16 deletions

View File

@@ -48,13 +48,17 @@ func (db *DB) Migrate() error {
_, err = tx.Exec(migration.SQL)
if err != nil {
tx.Rollback()
if rbErr := tx.Rollback(); rbErr != nil {
return fmt.Errorf("migration %d failed: %v, rollback failed: %v", migration.Version, err, rbErr)
}
return fmt.Errorf("migration %d failed: %v", migration.Version, err)
}
_, err = tx.Exec("INSERT INTO migrations (version) VALUES (?)", migration.Version)
if err != nil {
tx.Rollback()
if rbErr := tx.Rollback(); rbErr != nil {
return fmt.Errorf("failed to update migration version: %v, rollback failed: %v", err, rbErr)
}
return fmt.Errorf("failed to update migration version: %v", err)
}