Skip to content

Commit

Permalink
Incremental removal of FatalIfError()
Browse files Browse the repository at this point in the history
  • Loading branch information
williammoran committed May 6, 2024
1 parent 3fe16c7 commit fde2173
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/format/pgsql8/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion lib/format/pgsql8/diff_constraints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pgsql8

import (
"fmt"
"log/slog"

"github.com/dbsteward/dbsteward/lib"
Expand All @@ -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)
Expand Down

0 comments on commit fde2173

Please sign in to comment.