This commit is contained in:
@@ -205,7 +205,9 @@ func (i *Installer) ApplyMigrations(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if err := execStatements(ctx, tx, string(content)); err != nil {
|
||||
tx.Rollback()
|
||||
if rbErr := tx.Rollback(); rbErr != nil {
|
||||
i.logger.Error("failed to rollback migration transaction", "version", m.version, "error", rbErr)
|
||||
}
|
||||
return fmt.Errorf("failed to apply migration %s: %w", m.name, err)
|
||||
}
|
||||
|
||||
@@ -213,7 +215,9 @@ func (i *Installer) ApplyMigrations(ctx context.Context) error {
|
||||
"INSERT INTO broker.broker_schema_migrations (version, name) VALUES ($1, $2)",
|
||||
m.version, m.name,
|
||||
); err != nil {
|
||||
tx.Rollback()
|
||||
if rbErr := tx.Rollback(); rbErr != nil {
|
||||
i.logger.Error("failed to rollback migration transaction", "version", m.version, "error", rbErr)
|
||||
}
|
||||
return fmt.Errorf("failed to record migration %s: %w", m.name, err)
|
||||
}
|
||||
|
||||
@@ -293,7 +297,9 @@ func (i *Installer) InstallRoles(ctx context.Context, passwords RolePasswords) e
|
||||
rendered := replacer.Replace(string(content))
|
||||
|
||||
if err := execStatements(ctx, tx, rendered); err != nil {
|
||||
tx.Rollback()
|
||||
if rbErr := tx.Rollback(); rbErr != nil {
|
||||
i.logger.Error("failed to rollback roles script transaction", "name", name, "error", rbErr)
|
||||
}
|
||||
return fmt.Errorf("failed to apply roles script %s: %w", name, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user