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

Method CreateSchema

backend/store/model/database.go:272–302  ·  view source on GitHub ↗
(schemaName string)

Source from the content-addressed store, hash-verified

270}
271
272func (d *DatabaseMetadata) CreateSchema(schemaName string) *SchemaMetadata {
273 // Create new schema proto
274 newSchemaProto := &storepb.SchemaMetadata{
275 Name: schemaName,
276 Tables: []*storepb.TableMetadata{},
277 Views: []*storepb.ViewMetadata{},
278 }
279
280 // Add to proto's schema list
281 d.proto.Schemas = append(d.proto.Schemas, newSchemaProto)
282
283 // Create SchemaMetadata wrapper
284 schemaMeta := &SchemaMetadata{
285 isObjectCaseSensitive: d.isObjectCaseSensitive,
286 isDetailCaseSensitive: d.isDetailCaseSensitive,
287 internalTables: make(map[string]*TableMetadata),
288 internalExternalTable: make(map[string]*ExternalTableMetadata),
289 internalViews: make(map[string]*storepb.ViewMetadata),
290 internalMaterializedView: make(map[string]*storepb.MaterializedViewMetadata),
291 internalProcedures: make(map[string]*storepb.ProcedureMetadata),
292 internalPackages: make(map[string]*storepb.PackageMetadata),
293 internalSequences: make(map[string]*storepb.SequenceMetadata),
294 proto: newSchemaProto,
295 }
296
297 // Add to internal map
298 schemaID := normalizeNameByCaseSensitivity(schemaName, d.isObjectCaseSensitive)
299 d.internal[schemaID] = schemaMeta
300
301 return schemaMeta
302}
303
304func (d *DatabaseMetadata) DropSchema(schemaName string) error {
305 // Check if schema exists

Callers 5

WalkThroughFunction · 0.80
tidbRenameTableFunction · 0.80
tidbFindTableStateFunction · 0.80
tidbDropTableFunction · 0.80
tidbCreateTableFunction · 0.80

Calls 1

Tested by

no test coverage detected