Skip to content

Commit

Permalink
GlobalSchema is not longer global: update the name to represent that …
Browse files Browse the repository at this point in the history
…and not export it
  • Loading branch information
williammoran committed May 10, 2024
1 parent 7058e81 commit 2ca63ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/format/pgsql8/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (d *diff) updatePermissions(stage1 output.OutputFileSegmenter, stage3 outpu
}
for _, newGrant := range newSchema.Grants {
if oldSchema == nil || !ir.HasPermissionsOf(oldSchema, newGrant, ir.SqlFormatPgsql8) {
s, err := GlobalSchema.GetGrantSql(d.ops.dbsteward, newDoc, newSchema, newGrant)
s, err := commonSchema.GetGrantSql(d.ops.dbsteward, newDoc, newSchema, newGrant)
if err != nil {
return err
}
Expand Down Expand Up @@ -509,13 +509,13 @@ func (d *diff) updateData(ofs output.OutputFileSegmenter, deleteMode bool) error
// DropSchemaSQL this implementation is a bit hacky as it's a
// transitional step as I factor away global variables
func (d *diff) DropSchemaSQL(s *ir.Schema) ([]output.ToSql, error) {
return GlobalSchema.GetDropSql(s), nil
return commonSchema.GetDropSql(s), nil
}

// CreateSchemaSQL this implementation is a bit hacky as it's a
// transitional step as I factor away global variables
func (d *diff) CreateSchemaSQL(s *ir.Schema) ([]output.ToSql, error) {
return GlobalSchema.GetCreationSql(d.ops.dbsteward, s)
return commonSchema.GetCreationSql(d.ops.dbsteward, s)
}

func (diff *diff) DiffDoc(oldFile, newFile string, oldDoc, newDoc *ir.Definition, upgradePrefix string) error {
Expand Down
4 changes: 2 additions & 2 deletions lib/format/pgsql8/diff_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func diffTypes(dbs *lib.DBSteward, differ *diff, ofs output.OutputFileSegmenter,
}

// TODO(feat) what about functions in other schemas?
for _, oldFunc := range GlobalSchema.GetFunctionsDependingOnType(oldSchema, oldType) {
for _, oldFunc := range commonSchema.GetFunctionsDependingOnType(oldSchema, oldType) {
ofs.WriteSql(sql.NewComment(
"Type migration of %s.%s requires recreating dependent function %s.%s",
newSchema.Name, newType.Name, oldSchema.Name, oldFunc.Name,
Expand Down Expand Up @@ -62,7 +62,7 @@ func diffTypes(dbs *lib.DBSteward, differ *diff, ofs output.OutputFileSegmenter,
}

// functions are only recreated if they changed elsewise, so need to create them here
for _, newFunc := range GlobalSchema.GetFunctionsDependingOnType(newSchema, newType) {
for _, newFunc := range commonSchema.GetFunctionsDependingOnType(newSchema, newType) {
s, err := getFunctionCreationSql(dbs, newSchema, newFunc)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions lib/format/pgsql8/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,15 +957,15 @@ func (ops *Operations) buildSchema(doc *ir.Definition, ofs output.OutputFileSegm
// TODO(go,3) roll this into diffing nil -> doc
// schema creation
for _, schema := range doc.Schemas {
s, err := GlobalSchema.GetCreationSql(ops.dbsteward, schema)
s, err := commonSchema.GetCreationSql(ops.dbsteward, schema)
if err != nil {
return err
}
ofs.WriteSql(s...)

// schema grants
for _, grant := range schema.Grants {
s, err := GlobalSchema.GetGrantSql(ops.dbsteward, doc, schema, grant)
s, err := commonSchema.GetGrantSql(ops.dbsteward, doc, schema, grant)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion lib/format/pgsql8/pgsql8.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/dbsteward/dbsteward/lib/ir"
)

var GlobalSchema = NewSchema()
var commonSchema = NewSchema()

func init() {
lib.RegisterFormat(ir.SqlFormatPgsql8, NewOperations)
Expand Down

0 comments on commit 2ca63ce

Please sign in to comment.