CreateDatabaseSchema implements the interface doltdb.RootValue.
(ctx context.Context, dbSchema schema.DatabaseSchema)
| 58 | |
| 59 | // CreateDatabaseSchema implements the interface doltdb.RootValue. |
| 60 | func (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. |
| 85 | func (root *RootValue) DropDatabaseSchema(ctx context.Context, dbSchema schema.DatabaseSchema) (doltdb.RootValue, error) { |
nothing calls this directly
no test coverage detected