MCPcopy Create free account
hub / github.com/dolthub/doltgresql / CreateDatabaseSchema

Method CreateDatabaseSchema

core/rootvalue.go:60–82  ·  view source on GitHub ↗

CreateDatabaseSchema implements the interface doltdb.RootValue.

(ctx context.Context, dbSchema schema.DatabaseSchema)

Source from the content-addressed store, hash-verified

58
59// CreateDatabaseSchema implements the interface doltdb.RootValue.
60func (root *RootValue) CreateDatabaseSchema(ctx context.Context, dbSchema schema.DatabaseSchema) (doltdb.RootValue, error) {
61 existingSchemas, err := root.st.GetSchemas(ctx)
62 if err != nil {
63 return nil, err
64 }
65
66 err = validateSchemaForCreate(existingSchemas, dbSchema)
67 if err != nil {
68 return nil, err
69 }
70
71 existingSchemas = append(existingSchemas, dbSchema)
72 sort.Slice(existingSchemas, func(i, j int) bool {
73 return existingSchemas[i].Name < existingSchemas[j].Name
74 })
75
76 r, err := root.st.SetSchemas(ctx, existingSchemas)
77 if err != nil {
78 return nil, err
79 }
80
81 return root.withStorage(r), nil
82}
83
84// DropDatabaseSchema implements the interface doltdb.RootValue.
85func (root *RootValue) DropDatabaseSchema(ctx context.Context, dbSchema schema.DatabaseSchema) (doltdb.RootValue, error) {

Callers

nothing calls this directly

Calls 4

withStorageMethod · 0.95
validateSchemaForCreateFunction · 0.85
GetSchemasMethod · 0.80
SetSchemasMethod · 0.80

Tested by

no test coverage detected