From fde217333ebba8f22d50894921c24c964d7abdbb Mon Sep 17 00:00:00 2001 From: Bill Moran Date: Mon, 6 May 2024 12:11:26 -0400 Subject: [PATCH] Incremental removal of FatalIfError() --- lib/format/pgsql8/constraint.go | 4 +++- lib/format/pgsql8/diff_constraints.go | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/format/pgsql8/constraint.go b/lib/format/pgsql8/constraint.go index 5b05033..599fcd4 100644 --- a/lib/format/pgsql8/constraint.go +++ b/lib/format/pgsql8/constraint.go @@ -298,7 +298,9 @@ func constraintDependsOnRenamedTable(l *slog.Logger, doc *ir.Definition, constra if !isRenamed { var err error isRenamed, err = lib.GlobalDBSteward.OldDatabase.IsRenamedTable(slog.Default(), refSchema, refTable) - lib.GlobalDBSteward.FatalIfError(err, "while checking if constraint depends on renamed table") + if err != nil { + return false, fmt.Errorf("while checking if constraint depends on renamed table: %w", err) + } } if isRenamed { l.Info(fmt.Sprintf("Constraint %s.%s.%s references renamed table %s.%s", constraint.Schema.Name, constraint.Table.Name, constraint.Name, refSchema.Name, refTable.Name)) diff --git a/lib/format/pgsql8/diff_constraints.go b/lib/format/pgsql8/diff_constraints.go index 5e48e07..36b8e18 100644 --- a/lib/format/pgsql8/diff_constraints.go +++ b/lib/format/pgsql8/diff_constraints.go @@ -1,6 +1,7 @@ package pgsql8 import ( + "fmt" "log/slog" "github.com/dbsteward/dbsteward/lib" @@ -22,7 +23,9 @@ func createConstraints(l *slog.Logger, ofs output.OutputFileSegmenter, oldSchema func createConstraintsTable(l *slog.Logger, ofs output.OutputFileSegmenter, oldSchema *ir.Schema, oldTable *ir.Table, newSchema *ir.Schema, newTable *ir.Table, constraintType sql99.ConstraintType) error { isRenamed, err := lib.GlobalDBSteward.OldDatabase.IsRenamedTable(slog.Default(), newSchema, newTable) - lib.GlobalDBSteward.FatalIfError(err, "while checking if table was renamed") + if err != nil { + return fmt.Errorf("while checking if table was renamed: %w", err) + } if isRenamed { // remove all constraints and recreate with new table name conventions constraints, err := getTableConstraints(lib.GlobalDBSteward.OldDatabase, oldSchema, oldTable, constraintType)