MCPcopy Create free account
hub / github.com/bytebase/bytebase / writeSchemaDiff

Function writeSchemaDiff

backend/plugin/schema/pg/metadata_migration.go:1463–1482  ·  view source on GitHub ↗
(out *strings.Builder, schemaDiff *schema.SchemaDiff)

Source from the content-addressed store, hash-verified

1461}
1462
1463func writeSchemaDiff(out *strings.Builder, schemaDiff *schema.SchemaDiff) error {
1464 switch schemaDiff.Action {
1465 case schema.MetadataDiffActionCreate:
1466 if skipPostgresSchemaDDL(schemaDiff.SchemaName) {
1467 return nil
1468 }
1469 return writeSchema(out, schemaDiff.NewSchema)
1470 case schema.MetadataDiffActionDrop:
1471 if skipPostgresSchemaDDL(schemaDiff.SchemaName) {
1472 return nil
1473 }
1474 if err := writeDropSchemaObjects(out, schemaDiff.SchemaName, schemaDiff.OldSchema); err != nil {
1475 return err
1476 }
1477 _, err := fmt.Fprintf(out, "DROP SCHEMA IF EXISTS \"%s\";\n\n", schemaDiff.SchemaName)
1478 return err
1479 default:
1480 return nil
1481 }
1482}
1483
1484func skipPostgresSchemaDDL(schemaName string) bool {
1485 return schemaName == "pg_catalog" || schemaName == "public"

Callers 2

writeDropPhaseFunction · 0.85
writeCreateOrAlterPhaseFunction · 0.85

Calls 3

skipPostgresSchemaDDLFunction · 0.85
writeSchemaFunction · 0.85
writeDropSchemaObjectsFunction · 0.85

Tested by

no test coverage detected