MCPcopy Index your code
hub / github.com/bytebase/bytebase / DropSchema

Method DropSchema

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

Source from the content-addressed store, hash-verified

302}
303
304func (d *DatabaseMetadata) DropSchema(schemaName string) error {
305 // Check if schema exists
306 if d.GetSchemaMetadata(schemaName) == nil {
307 return errors.Errorf("schema %q does not exist in database %q", schemaName, d.proto.GetName())
308 }
309
310 // Remove from internal map
311 schemaID := normalizeNameByCaseSensitivity(schemaName, d.isObjectCaseSensitive)
312 delete(d.internal, schemaID)
313
314 // Remove from proto's schema list
315 newSchemas := make([]*storepb.SchemaMetadata, 0, len(d.proto.Schemas)-1)
316 for _, schema := range d.proto.Schemas {
317 if d.isObjectCaseSensitive {
318 if schema.Name != schemaName {
319 newSchemas = append(newSchemas, schema)
320 }
321 } else {
322 if !strings.EqualFold(schema.Name, schemaName) {
323 newSchemas = append(newSchemas, schema)
324 }
325 }
326 }
327 d.proto.Schemas = newSchemas
328
329 return nil
330}
331
332// GetTable gets the schema by name.
333func (s *SchemaMetadata) GetTable(name string) *TableMetadata {

Callers

nothing calls this directly

Calls 4

GetSchemaMetadataMethod · 0.95
ErrorfMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected