Skip to content

Commit

Permalink
Remove GlobalDiffFunctions, refactor it into standalone functions, an…
Browse files Browse the repository at this point in the history
…d some general cleanup of that code
  • Loading branch information
williammoran committed Apr 25, 2024
1 parent 841a805 commit 3d00aa3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/format/pgsql8/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (self *Diff) updateStructure(stage1 output.OutputFileSegmenter, stage3 outp
for _, newSchema := range dbsteward.NewDatabase.Schemas {
oldSchema := dbsteward.OldDatabase.TryGetSchemaNamed(newSchema.Name)
GlobalDiffTypes.DiffTypes(stage1, oldSchema, newSchema)
GlobalDiffFunctions.DiffFunctions(stage1, stage3, oldSchema, newSchema)
diffFunctions(stage1, stage3, oldSchema, newSchema)
GlobalDiffSequences.DiffSequences(stage1, oldSchema, newSchema)
// remove old constraints before table constraints, so the sql statements succeed
dropConstraints(stage1, oldSchema, newSchema, sql99.ConstraintTypeConstraint)
Expand Down Expand Up @@ -205,7 +205,7 @@ func (self *Diff) updateStructure(stage1 output.OutputFileSegmenter, stage3 outp

if !processedSchemas[newSchema.Name] {
GlobalDiffTypes.DiffTypes(stage1, oldSchema, newSchema)
GlobalDiffFunctions.DiffFunctions(stage1, stage3, oldSchema, newSchema)
diffFunctions(stage1, stage3, oldSchema, newSchema)
processedSchemas[newSchema.Name] = true
}
}
Expand Down
9 changes: 1 addition & 8 deletions lib/format/pgsql8/diff_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ import (
"github.com/dbsteward/dbsteward/lib/output"
)

type DiffFunctions struct {
}

func NewDiffFunctions() *DiffFunctions {
return &DiffFunctions{}
}

func (self *DiffFunctions) DiffFunctions(stage1 output.OutputFileSegmenter, stage3 output.OutputFileSegmenter, oldSchema *ir.Schema, newSchema *ir.Schema) {
func diffFunctions(stage1 output.OutputFileSegmenter, stage3 output.OutputFileSegmenter, oldSchema *ir.Schema, newSchema *ir.Schema) {
// drop functions that no longer exist in stage 3
if oldSchema != nil {
for _, oldFunction := range oldSchema.Functions {
Expand Down
1 change: 0 additions & 1 deletion lib/format/pgsql8/pgsql8.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "github.com/dbsteward/dbsteward/lib/format"

var GlobalOperations = NewOperations()
var GlobalSchema = NewSchema()
var GlobalDiffFunctions = NewDiffFunctions()
var GlobalDiffIndexes = NewDiffIndexes()
var GlobalDiffLanguages = NewDiffLanguages()
var GlobalDiffSequences = NewDiffSequences()
Expand Down

0 comments on commit 3d00aa3

Please sign in to comment.