Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: move the schema metadata proto to omni (#21425)
Danny Xu9c60e3d80352
diff --git a/backend/api/v1/database_catalog_service.go b/backend/api/v1/database_catalog_service.goindex 57f0820326..e4f8a9bac4 100644--- a/backend/api/v1/database_catalog_service.go+++ b/backend/api/v1/database_catalog_service.go@@ -5,6 +5,7 @@ import ("strings""connectrpc.com/connect"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -236,7 +237,7 @@ func convertDatabaseCatalog(catalog *v1pb.DatabaseCatalog) *storepb.DatabaseConf// validateCatalogSchemaNames rejects empty schema names for engines that use// named schemas. Engines like Cassandra/MySQL where metadata has empty schema// names are allowed through.-func validateCatalogSchemaNames(config *storepb.DatabaseConfig, metadata *storepb.DatabaseSchemaMetadata) error {+func validateCatalogSchemaNames(config *storepb.DatabaseConfig, metadata *metadatapb.DatabaseSchemaMetadata) error {if !hasEmptySchemaName(config.Schemas) {return nil}diff --git a/backend/api/v1/database_catalog_service_test.go b/backend/api/v1/database_catalog_service_test.goindex 4e4651bed6..6953c20469 100644--- a/backend/api/v1/database_catalog_service_test.go+++ b/backend/api/v1/database_catalog_service_test.go@@ -3,6 +3,7 @@ package v1import ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -13,7 +14,7 @@ func TestValidateCatalogSchemaNames(t *testing.T) {tests := []struct {name stringconfig *storepb.DatabaseConfig- metadata *storepb.DatabaseSchemaMetadata+ metadata *metadatapb.DatabaseSchemaMetadatawantErr bool}{{@@ -23,9 +24,9 @@ func TestValidateCatalogSchemaNames(t *testing.T) {{Name: "public", Tables: []*storepb.TableCatalog{{Name: "users"}}},},},- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{- {Name: "public", Tables: []*storepb.TableMetadata{{Name: "users"}}},+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "public", Tables: []*metadatapb.TableMetadata{{Name: "users"}}},},},wantErr: false,@@ -37,9 +38,9 @@ func TestValidateCatalogSchemaNames(t *testing.T) {{Name: "", Tables: []*storepb.TableCatalog{{Name: "users"}}},},},- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{- {Name: "public", Tables: []*storepb.TableMetadata{{Name: "users"}}},+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "public", Tables: []*metadatapb.TableMetadata{{Name: "users"}}},},},wantErr: true,@@ -51,9 +52,9 @@ func TestValidateCatalogSchemaNames(t *testing.T) {{Name: "", Tables: []*storepb.TableCatalog{{Name: "users"}}},},},- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{- {Name: "", Tables: []*storepb.TableMetadata{{Name: "users"}}},+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "", Tables: []*metadatapb.TableMetadata{{Name: "users"}}},},},wantErr: false,diff --git a/backend/api/v1/database_converter.go b/backend/api/v1/database_converter.goindex 3399a730a1..0dae4ae48e 100644--- a/backend/api/v1/database_converter.go+++ b/backend/api/v1/database_converter.go@@ -3,11 +3,12 @@ package v1import ("strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata"+v1pb "github.com/bytebase/bytebase/backend/generated-go/v1")-func convertStoreDatabaseMetadata(metadata *storepb.DatabaseSchemaMetadata, filter *metadataFilter, limit int) *v1pb.DatabaseMetadata {+func convertStoreDatabaseMetadata(metadata *metadatapb.DatabaseSchemaMetadata, filter *metadataFilter, limit int) *v1pb.DatabaseMetadata {m := &v1pb.DatabaseMetadata{CharacterSet: metadata.CharacterSet,Collation: metadata.Collation,@@ -314,7 +315,7 @@ func convertStoreDatabaseMetadata(metadata *storepb.DatabaseSchemaMetadata, filtreturn m}-func convertStoreIndexMetadata(index *storepb.IndexMetadata) *v1pb.IndexMetadata {+func convertStoreIndexMetadata(index *metadatapb.IndexMetadata) *v1pb.IndexMetadata {return &v1pb.IndexMetadata{Name: index.Name,Expressions: index.Expressions,@@ -336,7 +337,7 @@ func convertStoreIndexMetadata(index *storepb.IndexMetadata) *v1pb.IndexMetadata}}-func convertStoreTableMetadata(table *storepb.TableMetadata) *v1pb.TableMetadata {+func convertStoreTableMetadata(table *metadatapb.TableMetadata) *v1pb.TableMetadata {t := &v1pb.TableMetadata{Name: table.Name,Engine: table.Engine,@@ -404,7 +405,7 @@ func convertStoreTableMetadata(table *storepb.TableMetadata) *v1pb.TableMetadatareturn t}-func convertStoreTriggerMetadata(trigger *storepb.TriggerMetadata) *v1pb.TriggerMetadata {+func convertStoreTriggerMetadata(trigger *metadatapb.TriggerMetadata) *v1pb.TriggerMetadata {return &v1pb.TriggerMetadata{Name: trigger.Name,Timing: trigger.Timing,@@ -418,7 +419,7 @@ func convertStoreTriggerMetadata(trigger *storepb.TriggerMetadata) *v1pb.Trigger}}-func convertStoreExternalTableMetadata(externalTable *storepb.ExternalTableMetadata) *v1pb.ExternalTableMetadata {+func convertStoreExternalTableMetadata(externalTable *metadatapb.ExternalTableMetadata) *v1pb.ExternalTableMetadata {t := &v1pb.ExternalTableMetadata{Name: externalTable.Name,ExternalServerName: externalTable.ExternalServerName,@@ -434,7 +435,7 @@ func convertStoreExternalTableMetadata(externalTable *storepb.ExternalTableMetadreturn t}-func convertStoreTablePartitionMetadata(partition *storepb.TablePartitionMetadata) *v1pb.TablePartitionMetadata {+func convertStoreTablePartitionMetadata(partition *metadatapb.TablePartitionMetadata) *v1pb.TablePartitionMetadata {metadata := &v1pb.TablePartitionMetadata{Name: partition.Name,Expression: partition.Expression,@@ -442,21 +443,21 @@ func convertStoreTablePartitionMetadata(partition *storepb.TablePartitionMetadatUseDefault: partition.UseDefault,}switch partition.Type {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:metadata.Type = v1pb.TablePartitionMetadata_RANGE- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:metadata.Type = v1pb.TablePartitionMetadata_RANGE_COLUMNS- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:metadata.Type = v1pb.TablePartitionMetadata_LIST- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:metadata.Type = v1pb.TablePartitionMetadata_LIST_COLUMNS- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:metadata.Type = v1pb.TablePartitionMetadata_HASH- case storepb.TablePartitionMetadata_LINEAR_HASH:+ case metadatapb.TablePartitionMetadata_LINEAR_HASH:metadata.Type = v1pb.TablePartitionMetadata_LINEAR_HASH- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:metadata.Type = v1pb.TablePartitionMetadata_KEY- case storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_LINEAR_KEY:metadata.Type = v1pb.TablePartitionMetadata_LINEAR_KEYdefault:metadata.Type = v1pb.TablePartitionMetadata_TYPE_UNSPECIFIED@@ -476,7 +477,7 @@ func convertStoreTablePartitionMetadata(partition *storepb.TablePartitionMetadatreturn metadata}-func convertStoreColumnMetadata(column *storepb.ColumnMetadata) *v1pb.ColumnMetadata {+func convertStoreColumnMetadata(column *metadatapb.ColumnMetadata) *v1pb.ColumnMetadata {metadata := &v1pb.ColumnMetadata{Name: column.Name,Position: column.Position,@@ -499,9 +500,9 @@ func convertStoreColumnMetadata(column *storepb.ColumnMetadata) *v1pb.ColumnMetaIsInvisible: column.IsInvisible,}switch column.IdentityGeneration {- case storepb.ColumnMetadata_ALWAYS:+ case metadatapb.ColumnMetadata_ALWAYS:metadata.IdentityGeneration = v1pb.ColumnMetadata_ALWAYS- case storepb.ColumnMetadata_BY_DEFAULT:+ case metadatapb.ColumnMetadata_BY_DEFAULT:metadata.IdentityGeneration = v1pb.ColumnMetadata_BY_DEFAULTdefault:metadata.IdentityGeneration = v1pb.ColumnMetadata_IDENTITY_GENERATION_UNSPECIFIED@@ -509,7 +510,7 @@ func convertStoreColumnMetadata(column *storepb.ColumnMetadata) *v1pb.ColumnMetareturn metadata}-func convertStoreGenerationMetadata(generation *storepb.GenerationMetadata) *v1pb.GenerationMetadata {+func convertStoreGenerationMetadata(generation *metadatapb.GenerationMetadata) *v1pb.GenerationMetadata {if generation == nil {return nil}@@ -517,9 +518,9 @@ func convertStoreGenerationMetadata(generation *storepb.GenerationMetadata) *v1pExpression: generation.Expression,}switch generation.Type {- case storepb.GenerationMetadata_TYPE_VIRTUAL:+ case metadatapb.GenerationMetadata_TYPE_VIRTUAL:meta.Type = v1pb.GenerationMetadata_VIRTUAL- case storepb.GenerationMetadata_TYPE_STORED:+ case metadatapb.GenerationMetadata_TYPE_STORED:meta.Type = v1pb.GenerationMetadata_STOREDdefault:meta.Type = v1pb.GenerationMetadata_TYPE_UNSPECIFIED@@ -527,8 +528,8 @@ func convertStoreGenerationMetadata(generation *storepb.GenerationMetadata) *v1preturn meta}-func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.DatabaseSchemaMetadata {- m := &storepb.DatabaseSchemaMetadata{+func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *metadatapb.DatabaseSchemaMetadata {+ m := &metadatapb.DatabaseSchemaMetadata{Name: metadata.Name,CharacterSet: metadata.CharacterSet,Collation: metadata.Collation,@@ -538,7 +539,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif schema == nil {continue}- s := &storepb.SchemaMetadata{+ s := &metadatapb.SchemaMetadata{Name: schema.Name,Owner: schema.Owner,Comment: schema.Comment,@@ -554,7 +555,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif view == nil {continue}- storeView := &storepb.ViewMetadata{+ storeView := &metadatapb.ViewMetadata{Name: view.Name,Definition: view.Definition,Comment: view.Comment,@@ -570,7 +571,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasfor _, dependencyColumn := range view.DependencyColumns {storeView.DependencyColumns = append(storeView.DependencyColumns,- &storepb.DependencyColumn{+ &metadatapb.DependencyColumn{Schema: dependencyColumn.Schema,Table: dependencyColumn.Table,Column: dependencyColumn.Column,@@ -590,7 +591,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif materializedView == nil {continue}- storeMaterializedView := &storepb.MaterializedViewMetadata{+ storeMaterializedView := &metadatapb.MaterializedViewMetadata{Name: materializedView.Name,Definition: materializedView.Definition,Comment: materializedView.Comment,@@ -601,7 +602,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databascontinue}storeMaterializedView.DependencyColumns = append(storeMaterializedView.DependencyColumns,- &storepb.DependencyColumn{+ &metadatapb.DependencyColumn{Schema: dependencyColumn.Schema,Table: dependencyColumn.Table,Column: dependencyColumn.Column,@@ -628,7 +629,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif function == nil {continue}- storeFunc := &storepb.FunctionMetadata{+ storeFunc := &metadatapb.FunctionMetadata{Name: function.Name,Definition: function.Definition,Signature: function.Signature,@@ -640,7 +641,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.DatabasSkipDump: function.SkipDump,}for _, dep := range function.DependencyTables {- storeFunc.DependencyTables = append(storeFunc.DependencyTables, &storepb.DependencyTable{+ storeFunc.DependencyTables = append(storeFunc.DependencyTables, &metadatapb.DependencyTable{Schema: dep.Schema,Table: dep.Table,})@@ -651,7 +652,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif procedure == nil {continue}- storeProcedure := &storepb.ProcedureMetadata{+ storeProcedure := &metadatapb.ProcedureMetadata{Name: procedure.Name,Definition: procedure.Definition,Signature: procedure.Signature,@@ -668,7 +669,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif p == nil {continue}- storePackage := &storepb.PackageMetadata{+ storePackage := &metadatapb.PackageMetadata{Name: p.Name,Definition: p.Definition,}@@ -678,7 +679,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif task == nil {continue}- storeTask := &storepb.TaskMetadata{+ storeTask := &metadatapb.TaskMetadata{Name: task.Name,Id: task.Id,Owner: task.Owner,@@ -686,7 +687,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.DatabasWarehouse: task.Warehouse,Schedule: task.Schedule,Predecessors: task.Predecessors,- State: storepb.TaskMetadata_State(task.State),+ State: metadatapb.TaskMetadata_State(task.State),Condition: task.Condition,Definition: task.Definition,}@@ -696,14 +697,14 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif stream == nil {continue}- storeStream := &storepb.StreamMetadata{+ storeStream := &metadatapb.StreamMetadata{Name: stream.Name,TableName: stream.TableName,Owner: stream.Owner,Comment: stream.Comment,- Type: storepb.StreamMetadata_Type(stream.Type),+ Type: metadatapb.StreamMetadata_Type(stream.Type),Stale: stream.Stale,- Mode: storepb.StreamMetadata_Mode(stream.Mode),+ Mode: metadatapb.StreamMetadata_Mode(stream.Mode),Definition: stream.Definition,}s.Streams = append(s.Streams, storeStream)@@ -712,7 +713,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif event == nil {continue}- storeEvent := &storepb.EventMetadata{+ storeEvent := &metadatapb.EventMetadata{Name: event.Name,TimeZone: event.TimeZone,Definition: event.Definition,@@ -727,7 +728,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif enum == nil {continue}- storeEnum := &storepb.EnumTypeMetadata{+ storeEnum := &metadatapb.EnumTypeMetadata{Name: enum.Name,Values: enum.Values,Comment: enum.Comment,@@ -739,7 +740,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif composite == nil {continue}- storeComposite := &storepb.CompositeTypeMetadata{+ storeComposite := &metadatapb.CompositeTypeMetadata{Name: composite.Name,Comment: composite.Comment,}@@ -747,7 +748,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif attribute == nil {continue}- storeComposite.Attributes = append(storeComposite.Attributes, &storepb.CompositeTypeAttribute{+ storeComposite.Attributes = append(storeComposite.Attributes, &metadatapb.CompositeTypeAttribute{Name: attribute.Name,Type: attribute.Type,Collation: attribute.Collation,@@ -760,7 +761,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif sequence == nil {continue}- storeSequence := &storepb.SequenceMetadata{+ storeSequence := &metadatapb.SequenceMetadata{Name: sequence.Name,DataType: sequence.DataType,Start: sequence.Start,@@ -783,7 +784,7 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasif extension == nil {continue}- m.Extensions = append(m.Extensions, &storepb.ExtensionMetadata{+ m.Extensions = append(m.Extensions, &metadatapb.ExtensionMetadata{Name: extension.Name,Schema: extension.Schema,Version: extension.Version,@@ -793,8 +794,8 @@ func convertV1DatabaseMetadata(metadata *v1pb.DatabaseMetadata) *storepb.Databasreturn m}-func convertV1IndexMetadata(index *v1pb.IndexMetadata) *storepb.IndexMetadata {- return &storepb.IndexMetadata{+func convertV1IndexMetadata(index *v1pb.IndexMetadata) *metadatapb.IndexMetadata {+ return &metadatapb.IndexMetadata{Name: index.Name,Expressions: index.Expressions,KeyLength: index.KeyLength,@@ -813,7 +814,7 @@ func convertV1IndexMetadata(index *v1pb.IndexMetadata) *storepb.IndexMetadata {}}-func convertStoreSpatialIndexConfig(spatial *storepb.SpatialIndexConfig) *v1pb.SpatialIndexConfig {+func convertStoreSpatialIndexConfig(spatial *metadatapb.SpatialIndexConfig) *v1pb.SpatialIndexConfig {if spatial == nil {return nil}@@ -825,11 +826,11 @@ func convertStoreSpatialIndexConfig(spatial *storepb.SpatialIndexConfig) *v1pb.S}}-func convertV1SpatialIndexConfig(spatial *v1pb.SpatialIndexConfig) *storepb.SpatialIndexConfig {+func convertV1SpatialIndexConfig(spatial *v1pb.SpatialIndexConfig) *metadatapb.SpatialIndexConfig {if spatial == nil {return nil}- return &storepb.SpatialIndexConfig{+ return &metadatapb.SpatialIndexConfig{Method: spatial.Method,Tessellation: convertV1TessellationConfig(spatial.Tessellation),Storage: convertV1StorageConfig(spatial.Storage),@@ -837,7 +838,7 @@ func convertV1SpatialIndexConfig(spatial *v1pb.SpatialIndexConfig) *storepb.Spat}}-func convertStoreTessellationConfig(tessellation *storepb.TessellationConfig) *v1pb.TessellationConfig {+func convertStoreTessellationConfig(tessellation *metadatapb.TessellationConfig) *v1pb.TessellationConfig {if tessellation == nil {return nil}@@ -856,18 +857,18 @@ func convertStoreTessellationConfig(tessellation *storepb.TessellationConfig) *v}}-func convertV1TessellationConfig(tessellation *v1pb.TessellationConfig) *storepb.TessellationConfig {+func convertV1TessellationConfig(tessellation *v1pb.TessellationConfig) *metadatapb.TessellationConfig {if tessellation == nil {return nil}- gridLevels := make([]*storepb.GridLevel, len(tessellation.GridLevels))+ gridLevels := make([]*metadatapb.GridLevel, len(tessellation.GridLevels))for i, level := range tessellation.GridLevels {- gridLevels[i] = &storepb.GridLevel{+ gridLevels[i] = &metadatapb.GridLevel{Level: level.Level,Density: level.Density,}}- return &storepb.TessellationConfig{+ return &metadatapb.TessellationConfig{Scheme: tessellation.Scheme,GridLevels: gridLevels,CellsPerObject: tessellation.CellsPerObject,@@ -875,7 +876,7 @@ func convertV1TessellationConfig(tessellation *v1pb.TessellationConfig) *storepb}}-func convertStoreBoundingBox(bbox *storepb.BoundingBox) *v1pb.BoundingBox {+func convertStoreBoundingBox(bbox *metadatapb.BoundingBox) *v1pb.BoundingBox {if bbox == nil {return nil}@@ -887,11 +888,11 @@ func convertStoreBoundingBox(bbox *storepb.BoundingBox) *v1pb.BoundingBox {}}-func convertV1BoundingBox(bbox *v1pb.BoundingBox) *storepb.BoundingBox {+func convertV1BoundingBox(bbox *v1pb.BoundingBox) *metadatapb.BoundingBox {if bbox == nil {return nil}- return &storepb.BoundingBox{+ return &metadatapb.BoundingBox{Xmin: bbox.Xmin,Ymin: bbox.Ymin,Xmax: bbox.Xmax,@@ -899,7 +900,7 @@ func convertV1BoundingBox(bbox *v1pb.BoundingBox) *storepb.BoundingBox {}}-func convertStoreStorageConfig(storage *storepb.StorageConfig) *v1pb.StorageConfig {+func convertStoreStorageConfig(storage *metadatapb.StorageConfig) *v1pb.StorageConfig {if storage == nil {return nil}@@ -921,11 +922,11 @@ func convertStoreStorageConfig(storage *storepb.StorageConfig) *v1pb.StorageConf}}-func convertV1StorageConfig(storage *v1pb.StorageConfig) *storepb.StorageConfig {+func convertV1StorageConfig(storage *v1pb.StorageConfig) *metadatapb.StorageConfig {if storage == nil {return nil}- return &storepb.StorageConfig{+ return &metadatapb.StorageConfig{Fillfactor: storage.Fillfactor,Buffering: storage.Buffering,Tablespace: storage.Tablespace,@@ -943,7 +944,7 @@ func convertV1StorageConfig(storage *v1pb.StorageConfig) *storepb.StorageConfig}}-func convertStoreDimensionalConfig(dimensional *storepb.DimensionalConfig) *v1pb.DimensionalConfig {+func convertStoreDimensionalConfig(dimensional *metadatapb.DimensionalConfig) *v1pb.DimensionalConfig {if dimensional == nil {return nil}@@ -955,11 +956,11 @@ func convertStoreDimensionalConfig(dimensional *storepb.DimensionalConfig) *v1pb}}-func convertV1DimensionalConfig(dimensional *v1pb.DimensionalConfig) *storepb.DimensionalConfig {+func convertV1DimensionalConfig(dimensional *v1pb.DimensionalConfig) *metadatapb.DimensionalConfig {if dimensional == nil {return nil}- return &storepb.DimensionalConfig{+ return &metadatapb.DimensionalConfig{Dimensions: dimensional.Dimensions,DataType: dimensional.DataType,// Note: OperatorClass field exists only in store proto@@ -967,8 +968,8 @@ func convertV1DimensionalConfig(dimensional *v1pb.DimensionalConfig) *storepb.Di}}-func convertV1TableMetadata(table *v1pb.TableMetadata) *storepb.TableMetadata {- t := &storepb.TableMetadata{+func convertV1TableMetadata(table *v1pb.TableMetadata) *metadatapb.TableMetadata {+ t := &metadatapb.TableMetadata{Name: table.Name,Engine: table.Engine,Collation: table.Collation,@@ -999,7 +1000,7 @@ func convertV1TableMetadata(table *v1pb.TableMetadata) *storepb.TableMetadata {if foreignKey == nil {continue}- t.ForeignKeys = append(t.ForeignKeys, &storepb.ForeignKeyMetadata{+ t.ForeignKeys = append(t.ForeignKeys, &metadatapb.ForeignKeyMetadata{Name: foreignKey.Name,Columns: foreignKey.Columns,ReferencedSchema: foreignKey.ReferencedSchema,@@ -1020,7 +1021,7 @@ func convertV1TableMetadata(table *v1pb.TableMetadata) *storepb.TableMetadata {if check == nil {continue}- t.CheckConstraints = append(t.CheckConstraints, &storepb.CheckConstraintMetadata{+ t.CheckConstraints = append(t.CheckConstraints, &metadatapb.CheckConstraintMetadata{Name: check.Name,Expression: check.Expression,})@@ -1034,8 +1035,8 @@ func convertV1TableMetadata(table *v1pb.TableMetadata) *storepb.TableMetadata {return t}-func convertV1TriggerMetadata(trigger *v1pb.TriggerMetadata) *storepb.TriggerMetadata {- return &storepb.TriggerMetadata{+func convertV1TriggerMetadata(trigger *v1pb.TriggerMetadata) *metadatapb.TriggerMetadata {+ return &metadatapb.TriggerMetadata{Name: trigger.Name,Timing: trigger.Timing,Event: trigger.Event,@@ -1048,8 +1049,8 @@ func convertV1TriggerMetadata(trigger *v1pb.TriggerMetadata) *storepb.TriggerMet}}-func convertV1TablePartitionMetadata(tablePartition *v1pb.TablePartitionMetadata) *storepb.TablePartitionMetadata {- metadata := &storepb.TablePartitionMetadata{+func convertV1TablePartitionMetadata(tablePartition *v1pb.TablePartitionMetadata) *metadatapb.TablePartitionMetadata {+ metadata := &metadatapb.TablePartitionMetadata{Name: tablePartition.Name,Expression: tablePartition.Expression,Value: tablePartition.Value,@@ -1057,23 +1058,23 @@ func convertV1TablePartitionMetadata(tablePartition *v1pb.TablePartitionMetadata}switch tablePartition.Type {case v1pb.TablePartitionMetadata_RANGE:- metadata.Type = storepb.TablePartitionMetadata_RANGE+ metadata.Type = metadatapb.TablePartitionMetadata_RANGEcase v1pb.TablePartitionMetadata_RANGE_COLUMNS:- metadata.Type = storepb.TablePartitionMetadata_RANGE_COLUMNS+ metadata.Type = metadatapb.TablePartitionMetadata_RANGE_COLUMNScase v1pb.TablePartitionMetadata_LIST:- metadata.Type = storepb.TablePartitionMetadata_LIST+ metadata.Type = metadatapb.TablePartitionMetadata_LISTcase v1pb.TablePartitionMetadata_LIST_COLUMNS:- metadata.Type = storepb.TablePartitionMetadata_LIST_COLUMNS+ metadata.Type = metadatapb.TablePartitionMetadata_LIST_COLUMNScase v1pb.TablePartitionMetadata_HASH:- metadata.Type = storepb.TablePartitionMetadata_HASH+ metadata.Type = metadatapb.TablePartitionMetadata_HASHcase v1pb.TablePartitionMetadata_LINEAR_HASH:- metadata.Type = storepb.TablePartitionMetadata_LINEAR_HASH+ metadata.Type = metadatapb.TablePartitionMetadata_LINEAR_HASHcase v1pb.TablePartitionMetadata_KEY:- metadata.Type = storepb.TablePartitionMetadata_KEY+ metadata.Type = metadatapb.TablePartitionMetadata_KEYcase v1pb.TablePartitionMetadata_LINEAR_KEY:- metadata.Type = storepb.TablePartitionMetadata_LINEAR_KEY+ metadata.Type = metadatapb.TablePartitionMetadata_LINEAR_KEYdefault:- metadata.Type = storepb.TablePartitionMetadata_TYPE_UNSPECIFIED+ metadata.Type = metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED}for _, index := range tablePartition.Indexes {if index == nil {@@ -1090,8 +1091,8 @@ func convertV1TablePartitionMetadata(tablePartition *v1pb.TablePartitionMetadatareturn metadata}-func convertV1ColumnMetadata(column *v1pb.ColumnMetadata) *storepb.ColumnMetadata {- metadata := &storepb.ColumnMetadata{+func convertV1ColumnMetadata(column *v1pb.ColumnMetadata) *metadatapb.ColumnMetadata {+ metadata := &metadatapb.ColumnMetadata{Name: column.Name,Position: column.Position,Nullable: column.Nullable,@@ -1102,7 +1103,7 @@ func convertV1ColumnMetadata(column *v1pb.ColumnMetadata) *storepb.ColumnMetadatComment: column.Comment,OnUpdate: column.OnUpdate,Generation: convertV1GenerationMetadata(column.Generation),- IdentityGeneration: storepb.ColumnMetadata_IdentityGeneration(column.IdentityGeneration),+ IdentityGeneration: metadatapb.ColumnMetadata_IdentityGeneration(column.IdentityGeneration),IsIdentity: column.IsIdentity,IdentitySeed: column.IdentitySeed,IdentityIncrement: column.IdentityIncrement,@@ -1114,29 +1115,29 @@ func convertV1ColumnMetadata(column *v1pb.ColumnMetadata) *storepb.ColumnMetadatswitch column.IdentityGeneration {case v1pb.ColumnMetadata_ALWAYS:- metadata.IdentityGeneration = storepb.ColumnMetadata_ALWAYS+ metadata.IdentityGeneration = metadatapb.ColumnMetadata_ALWAYScase v1pb.ColumnMetadata_BY_DEFAULT:- metadata.IdentityGeneration = storepb.ColumnMetadata_BY_DEFAULT+ metadata.IdentityGeneration = metadatapb.ColumnMetadata_BY_DEFAULTdefault:- metadata.IdentityGeneration = storepb.ColumnMetadata_IDENTITY_GENERATION_UNSPECIFIED+ metadata.IdentityGeneration = metadatapb.ColumnMetadata_IDENTITY_GENERATION_UNSPECIFIED}return metadata}-func convertV1GenerationMetadata(generation *v1pb.GenerationMetadata) *storepb.GenerationMetadata {+func convertV1GenerationMetadata(generation *v1pb.GenerationMetadata) *metadatapb.GenerationMetadata {if generation == nil {return nil}- meta := &storepb.GenerationMetadata{+ meta := &metadatapb.GenerationMetadata{Expression: generation.Expression,}switch generation.Type {case v1pb.GenerationMetadata_VIRTUAL:- meta.Type = storepb.GenerationMetadata_TYPE_VIRTUAL+ meta.Type = metadatapb.GenerationMetadata_TYPE_VIRTUALcase v1pb.GenerationMetadata_STORED:- meta.Type = storepb.GenerationMetadata_TYPE_STORED+ meta.Type = metadatapb.GenerationMetadata_TYPE_STOREDdefault:- meta.Type = storepb.GenerationMetadata_TYPE_UNSPECIFIED+ meta.Type = metadatapb.GenerationMetadata_TYPE_UNSPECIFIED}return meta}diff --git a/backend/api/v1/database_converter_test.go b/backend/api/v1/database_converter_test.goindex 785739a49d..5ed44a5e5c 100644--- a/backend/api/v1/database_converter_test.go+++ b/backend/api/v1/database_converter_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -23,31 +24,31 @@ func srid(v uint32) *uint32 { return &v }func TestConvertColumnMetadataSRIDInvisibleRoundTrip(t *testing.T) {testCases := []struct {name string- in *storepb.ColumnMetadata+ in *metadatapb.ColumnMetadata}{{name: "spatial_srid_4326",- in: &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},+ in: &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},},{// Explicit SRID 0 is a valid spatial reference system, distinct from "no SRID".// Presence (not a zero sentinel) must survive the round-trip.name: "explicit_srid_zero",- in: &storepb.ColumnMetadata{Name: "g", Type: "geometry", Nullable: false, Srid: srid(0)},+ in: &metadatapb.ColumnMetadata{Name: "g", Type: "geometry", Nullable: false, Srid: srid(0)},},{// Custom SRSs may exceed int32 range; the value must not be squeezed.name: "srid_above_int32",- in: &storepb.ColumnMetadata{Name: "g", Type: "geometry", Nullable: false, Srid: srid(3000000000)},+ in: &metadatapb.ColumnMetadata{Name: "g", Type: "geometry", Nullable: false, Srid: srid(3000000000)},},{name: "invisible_column",- in: &storepb.ColumnMetadata{Name: "secret", Type: "int", Nullable: false, IsInvisible: true},+ in: &metadatapb.ColumnMetadata{Name: "secret", Type: "int", Nullable: false, IsInvisible: true},},{// No SRID declared: presence must stay unset (nil), not collapse to SRID 0.name: "no_srid_visible",- in: &storepb.ColumnMetadata{Name: "c", Type: "int", Nullable: true},+ in: &metadatapb.ColumnMetadata{Name: "c", Type: "int", Nullable: true},},}for _, tc := range testCases {diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 06c4883185..2b06885183 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -8,6 +8,7 @@ import ("strings""connectrpc.com/connect"+ metadatapb "github.com/bytebase/omni/metadata"celast "github.com/google/cel-go/common/ast"celoperators "github.com/google/cel-go/common/operators"celoverloads "github.com/google/cel-go/common/overloads"@@ -1410,7 +1411,7 @@ func (s *DatabaseService) GetSchemaString(ctx context.Context, req *connect.Requif schemaMetadata == nil {return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("schema %q not found", req.Msg.Schema))}- var functionMetadata *storepb.FunctionMetadata+ var functionMetadata *metadatapb.FunctionMetadatafor _, fn := range schemaMetadata.GetProto().GetFunctions() {if fn.Name == req.Msg.Object {functionMetadata = fn@@ -1458,7 +1459,7 @@ func (s *DatabaseService) GetSchemaString(ctx context.Context, req *connect.Requ}}-func (*DatabaseService) getSingleFileSDL(engine storepb.Engine, metadata *storepb.DatabaseSchemaMetadata) (*connect.Response[v1pb.DatabaseSDLSchema], error) {+func (*DatabaseService) getSingleFileSDL(engine storepb.Engine, metadata *metadatapb.DatabaseSchemaMetadata) (*connect.Response[v1pb.DatabaseSDLSchema], error) {sdlText, err := schema.GetDatabaseDefinition(engine, schema.GetDefinitionContext{SkipBackupSchema: true,SDLFormat: true,@@ -1473,7 +1474,7 @@ func (*DatabaseService) getSingleFileSDL(engine storepb.Engine, metadata *storep}), nil}-func (*DatabaseService) getMultiFileSDL(engine storepb.Engine, metadata *storepb.DatabaseSchemaMetadata) (*connect.Response[v1pb.DatabaseSDLSchema], error) {+func (*DatabaseService) getMultiFileSDL(engine storepb.Engine, metadata *metadatapb.DatabaseSchemaMetadata) (*connect.Response[v1pb.DatabaseSDLSchema], error) {// Get multi-file schema from schema packageresult, err := schema.GetMultiFileDatabaseDefinition(engine, schema.GetDefinitionContext{SkipBackupSchema: true,diff --git a/backend/api/v1/query_result_masker.go b/backend/api/v1/query_result_masker.goindex b89463579d..6f46dcca67 100644--- a/backend/api/v1/query_result_masker.go+++ b/backend/api/v1/query_result_masker.go@@ -4,6 +4,7 @@ import ("context""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -317,7 +318,7 @@ func (p *maskingDataProvider) getProject(projectID string) *store.ProjectMessagereturn p.projects[projectID]}-func (p *maskingDataProvider) getColumn(col *parserbase.ColumnResource) (*storepb.ColumnMetadata, *storepb.ColumnCatalog) {+func (p *maskingDataProvider) getColumn(col *parserbase.ColumnResource) (*metadatapb.ColumnMetadata, *storepb.ColumnCatalog) {schema := p.schemas[col.Database]if schema == nil {return nil, nildiff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.goindex c887af1196..f28ba63bd9 100644--- a/backend/api/v1/release_service_check.go+++ b/backend/api/v1/release_service_check.go@@ -9,6 +9,7 @@ import ("unicode/utf8""connectrpc.com/connect"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""google.golang.org/protobuf/proto"@@ -352,7 +353,7 @@ loop:originMetadata := model.NewDatabaseMetadata(dbMetadata.GetProto(), nil, nil, engine, store.IsObjectCaseSensitive(instance))// Clone metadata for final to avoid modifying the original- clonedMetadata, ok := proto.Clone(dbMetadata.GetProto()).(*storepb.DatabaseSchemaMetadata)+ clonedMetadata, ok := proto.Clone(dbMetadata.GetProto()).(*metadatapb.DatabaseSchemaMetadata)if !ok {return nil, connect.NewError(connect.CodeInternal, errors.New("failed to clone database schema metadata"))}diff --git a/backend/api/v1/sql_service_schema_resolution_test.go b/backend/api/v1/sql_service_schema_resolution_test.goindex 8af2e4ea0c..767204529c 100644--- a/backend/api/v1/sql_service_schema_resolution_test.go+++ b/backend/api/v1/sql_service_schema_resolution_test.go@@ -3,6 +3,7 @@ package v1import ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -45,8 +46,8 @@ func TestSchemaForWriteTargetResolution(t *testing.T) {}func TestPostgresWriteTargetSchemaForRequest(t *testing.T) {- dbMeta := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ dbMeta := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "app"},{Name: "public"},},diff --git a/backend/common/util_test.go b/backend/common/util_test.goindex b2be826aef..00ee1d1334 100644--- a/backend/common/util_test.go+++ b/backend/common/util_test.go@@ -5,13 +5,12 @@ import ("testing""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert""github.com/stretchr/testify/require""google.golang.org/protobuf/encoding/protojson""google.golang.org/protobuf/proto""google.golang.org/protobuf/reflect/protoreflect"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")func TestHasPrefixes(t *testing.T) {@@ -403,7 +402,7 @@ func TestSanitizeUTF8MessageCoversEveryStringField(t *testing.T) {rawGBK := "\xb2\xe2\xca\xd4\xb1"require.False(t, utf8.ValidString(rawGBK))- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}fillAllStringFields(metadata.ProtoReflect(), rawGBK, 8)invalidBefore := countInvalidStringFields(metadata.ProtoReflect())@@ -427,13 +426,13 @@ func TestSanitizeUTF8MessageCoversEveryStringField(t *testing.T) {// after sanitization, and valid names must pass through untouched.func TestSanitizeUTF8MessageNameFields(t *testing.T) {rawGBK := "AB\xe6"- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: rawGBK,- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: rawGBK,- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: rawGBK,- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: rawGBK, Type: rawGBK, Default: rawGBK},{Name: "测试列", Type: "VARCHAR2(50)"},},diff --git a/backend/component/export/export_test.go b/backend/component/export/export_test.goindex fe59c002d7..a8f4b577f1 100644--- a/backend/component/export/export_test.go+++ b/backend/component/export/export_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -374,15 +375,15 @@ func TestGetResourcesTiDB(t *testing.T) {getDatabaseMetadataFunc := func(_ context.Context, _ string, _ string) (string, *model.DatabaseMetadata, error) {dbMeta := model.NewDatabaseMetadata(- &storepb.DatabaseSchemaMetadata{+ &metadatapb.DatabaseSchemaMetadata{Name: "",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "cbt_plans",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint"},},},diff --git a/backend/component/parsercontext/parsercontext.go b/backend/component/parsercontext/parsercontext.goindex 6eac5e8831..798b9bf46a 100644--- a/backend/component/parsercontext/parsercontext.go+++ b/backend/component/parsercontext/parsercontext.go@@ -13,6 +13,8 @@ import ("context""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/store/model"@@ -78,7 +80,7 @@ func BuildGetLinkedDatabaseMetadataFunc(storeInstance *store.Store, engine storeif err != nil {return "", "", nil, err}- var linkedMeta *storepb.LinkedDatabaseMetadata+ var linkedMeta *metadatapb.LinkedDatabaseMetadatafor _, database := range databases {meta, err := storeInstance.GetDBSchema(ctx, &store.FindDBSchemaMessage{Workspace: common.GetWorkspaceIDFromContext(ctx),diff --git a/backend/generated-go/store/database.pb.go b/backend/generated-go/store/database.pb.goindex 53d81bc626..1005c219dd 100644--- a/backend/generated-go/store/database.pb.go+++ b/backend/generated-go/store/database.pb.go@@ -72,4178 +72,97 @@ func (SyncStatus) EnumDescriptor() ([]byte, []int) {return file_store_database_proto_rawDescGZIP(), []int{0}}-type TaskMetadata_State int32--const (- TaskMetadata_STATE_UNSPECIFIED TaskMetadata_State = 0- TaskMetadata_STATE_STARTED TaskMetadata_State = 1- TaskMetadata_STATE_SUSPENDED TaskMetadata_State = 2-)--// Enum value maps for TaskMetadata_State.-var (- TaskMetadata_State_name = map[int32]string{- 0: "STATE_UNSPECIFIED",- 1: "STATE_STARTED",- 2: "STATE_SUSPENDED",- }- TaskMetadata_State_value = map[string]int32{- "STATE_UNSPECIFIED": 0,- "STATE_STARTED": 1,- "STATE_SUSPENDED": 2,- }-)--func (x TaskMetadata_State) Enum() *TaskMetadata_State {- p := new(TaskMetadata_State)- *p = x- return p-}--func (x TaskMetadata_State) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (TaskMetadata_State) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[1].Descriptor()-}--func (TaskMetadata_State) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[1]-}--func (x TaskMetadata_State) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use TaskMetadata_State.Descriptor instead.-func (TaskMetadata_State) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{11, 0}-}--type StreamMetadata_Type int32--const (- StreamMetadata_TYPE_UNSPECIFIED StreamMetadata_Type = 0- StreamMetadata_TYPE_DELTA StreamMetadata_Type = 1-)--// Enum value maps for StreamMetadata_Type.-var (- StreamMetadata_Type_name = map[int32]string{- 0: "TYPE_UNSPECIFIED",- 1: "TYPE_DELTA",- }- StreamMetadata_Type_value = map[string]int32{- "TYPE_UNSPECIFIED": 0,- "TYPE_DELTA": 1,- }-)--func (x StreamMetadata_Type) Enum() *StreamMetadata_Type {- p := new(StreamMetadata_Type)- *p = x- return p-}--func (x StreamMetadata_Type) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (StreamMetadata_Type) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[2].Descriptor()-}--func (StreamMetadata_Type) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[2]-}--func (x StreamMetadata_Type) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use StreamMetadata_Type.Descriptor instead.-func (StreamMetadata_Type) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{12, 0}-}--type StreamMetadata_Mode int32--const (- StreamMetadata_MODE_UNSPECIFIED StreamMetadata_Mode = 0- StreamMetadata_MODE_DEFAULT StreamMetadata_Mode = 1- StreamMetadata_MODE_APPEND_ONLY StreamMetadata_Mode = 2- StreamMetadata_MODE_INSERT_ONLY StreamMetadata_Mode = 3-)--// Enum value maps for StreamMetadata_Mode.-var (- StreamMetadata_Mode_name = map[int32]string{- 0: "MODE_UNSPECIFIED",- 1: "MODE_DEFAULT",- 2: "MODE_APPEND_ONLY",- 3: "MODE_INSERT_ONLY",- }- StreamMetadata_Mode_value = map[string]int32{- "MODE_UNSPECIFIED": 0,- "MODE_DEFAULT": 1,- "MODE_APPEND_ONLY": 2,- "MODE_INSERT_ONLY": 3,- }-)--func (x StreamMetadata_Mode) Enum() *StreamMetadata_Mode {- p := new(StreamMetadata_Mode)- *p = x- return p-}--func (x StreamMetadata_Mode) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (StreamMetadata_Mode) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[3].Descriptor()-}--func (StreamMetadata_Mode) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[3]-}--func (x StreamMetadata_Mode) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use StreamMetadata_Mode.Descriptor instead.-func (StreamMetadata_Mode) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{12, 1}-}--// The type is the type of a table partition. Some database engines may not-// support all types. Only available for the following database engines now:-// MySQL: RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, LINEAR HASH, KEY,-// LINEAR_KEY-// (https://dev.mysql.com/doc/refman/8.0/en/partitioning-types.html) TiDB:-// RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, KEY PostgreSQL: RANGE,-// LIST, HASH (https://www.postgresql.org/docs/current/ddl-partitioning.html)-type TablePartitionMetadata_Type int32--const (- TablePartitionMetadata_TYPE_UNSPECIFIED TablePartitionMetadata_Type = 0- TablePartitionMetadata_RANGE TablePartitionMetadata_Type = 1- TablePartitionMetadata_RANGE_COLUMNS TablePartitionMetadata_Type = 2- TablePartitionMetadata_LIST TablePartitionMetadata_Type = 3- TablePartitionMetadata_LIST_COLUMNS TablePartitionMetadata_Type = 4- TablePartitionMetadata_HASH TablePartitionMetadata_Type = 5- TablePartitionMetadata_LINEAR_HASH TablePartitionMetadata_Type = 6- TablePartitionMetadata_KEY TablePartitionMetadata_Type = 7- TablePartitionMetadata_LINEAR_KEY TablePartitionMetadata_Type = 8-)--// Enum value maps for TablePartitionMetadata_Type.-var (- TablePartitionMetadata_Type_name = map[int32]string{- 0: "TYPE_UNSPECIFIED",- 1: "RANGE",- 2: "RANGE_COLUMNS",- 3: "LIST",- 4: "LIST_COLUMNS",- 5: "HASH",- 6: "LINEAR_HASH",- 7: "KEY",- 8: "LINEAR_KEY",- }- TablePartitionMetadata_Type_value = map[string]int32{- "TYPE_UNSPECIFIED": 0,- "RANGE": 1,- "RANGE_COLUMNS": 2,- "LIST": 3,- "LIST_COLUMNS": 4,- "HASH": 5,- "LINEAR_HASH": 6,- "KEY": 7,- "LINEAR_KEY": 8,- }-)--func (x TablePartitionMetadata_Type) Enum() *TablePartitionMetadata_Type {- p := new(TablePartitionMetadata_Type)- *p = x- return p-}--func (x TablePartitionMetadata_Type) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (TablePartitionMetadata_Type) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[4].Descriptor()-}--func (TablePartitionMetadata_Type) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[4]-}--func (x TablePartitionMetadata_Type) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use TablePartitionMetadata_Type.Descriptor instead.-func (TablePartitionMetadata_Type) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{17, 0}-}--type ColumnMetadata_IdentityGeneration int32--const (- ColumnMetadata_IDENTITY_GENERATION_UNSPECIFIED ColumnMetadata_IdentityGeneration = 0- ColumnMetadata_ALWAYS ColumnMetadata_IdentityGeneration = 1- ColumnMetadata_BY_DEFAULT ColumnMetadata_IdentityGeneration = 2-)--// Enum value maps for ColumnMetadata_IdentityGeneration.-var (- ColumnMetadata_IdentityGeneration_name = map[int32]string{- 0: "IDENTITY_GENERATION_UNSPECIFIED",- 1: "ALWAYS",- 2: "BY_DEFAULT",- }- ColumnMetadata_IdentityGeneration_value = map[string]int32{- "IDENTITY_GENERATION_UNSPECIFIED": 0,- "ALWAYS": 1,- "BY_DEFAULT": 2,- }-)--func (x ColumnMetadata_IdentityGeneration) Enum() *ColumnMetadata_IdentityGeneration {- p := new(ColumnMetadata_IdentityGeneration)- *p = x- return p-}--func (x ColumnMetadata_IdentityGeneration) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (ColumnMetadata_IdentityGeneration) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[5].Descriptor()-}--func (ColumnMetadata_IdentityGeneration) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[5]-}--func (x ColumnMetadata_IdentityGeneration) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use ColumnMetadata_IdentityGeneration.Descriptor instead.-func (ColumnMetadata_IdentityGeneration) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{18, 0}-}--type GenerationMetadata_Type int32--const (- GenerationMetadata_TYPE_UNSPECIFIED GenerationMetadata_Type = 0- GenerationMetadata_TYPE_VIRTUAL GenerationMetadata_Type = 1- GenerationMetadata_TYPE_STORED GenerationMetadata_Type = 2-)--// Enum value maps for GenerationMetadata_Type.-var (- GenerationMetadata_Type_name = map[int32]string{- 0: "TYPE_UNSPECIFIED",- 1: "TYPE_VIRTUAL",- 2: "TYPE_STORED",- }- GenerationMetadata_Type_value = map[string]int32{- "TYPE_UNSPECIFIED": 0,- "TYPE_VIRTUAL": 1,- "TYPE_STORED": 2,- }-)--func (x GenerationMetadata_Type) Enum() *GenerationMetadata_Type {- p := new(GenerationMetadata_Type)- *p = x- return p-}--func (x GenerationMetadata_Type) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (GenerationMetadata_Type) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[6].Descriptor()-}--func (GenerationMetadata_Type) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[6]-}--func (x GenerationMetadata_Type) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use GenerationMetadata_Type.Descriptor instead.-func (GenerationMetadata_Type) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{19, 0}-}--type ObjectSchema_Type int32--const (- ObjectSchema_TYPE_UNSPECIFIED ObjectSchema_Type = 0- ObjectSchema_STRING ObjectSchema_Type = 1- ObjectSchema_NUMBER ObjectSchema_Type = 2- ObjectSchema_BOOLEAN ObjectSchema_Type = 3- ObjectSchema_OBJECT ObjectSchema_Type = 4- ObjectSchema_ARRAY ObjectSchema_Type = 5-)--// Enum value maps for ObjectSchema_Type.-var (- ObjectSchema_Type_name = map[int32]string{- 0: "TYPE_UNSPECIFIED",- 1: "STRING",- 2: "NUMBER",- 3: "BOOLEAN",- 4: "OBJECT",- 5: "ARRAY",- }- ObjectSchema_Type_value = map[string]int32{- "TYPE_UNSPECIFIED": 0,- "STRING": 1,- "NUMBER": 2,- "BOOLEAN": 3,- "OBJECT": 4,- "ARRAY": 5,- }-)--func (x ObjectSchema_Type) Enum() *ObjectSchema_Type {- p := new(ObjectSchema_Type)- *p = x- return p-}--func (x ObjectSchema_Type) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (ObjectSchema_Type) Descriptor() protoreflect.EnumDescriptor {- return file_store_database_proto_enumTypes[7].Descriptor()-}--func (ObjectSchema_Type) Type() protoreflect.EnumType {- return &file_store_database_proto_enumTypes[7]-}--func (x ObjectSchema_Type) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use ObjectSchema_Type.Descriptor instead.-func (ObjectSchema_Type) EnumDescriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{42, 0}-}--// DatabaseMetadata is the metadata for databases.-type DatabaseMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- Labels map[string]string `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`- LastSyncTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=last_sync_time,json=lastSyncTime,proto3" json:"last_sync_time,omitempty"`- BackupAvailable bool `protobuf:"varint,3,opt,name=backup_available,json=backupAvailable,proto3" json:"backup_available,omitempty"`- Datashare bool `protobuf:"varint,4,opt,name=datashare,proto3" json:"datashare,omitempty"`- // The release that was last applied to this database.- // Format: projects/{project}/releases/{release_id}- Release string `protobuf:"bytes,8,opt,name=release,proto3" json:"release,omitempty"`- // The sync status of the database.- SyncStatus SyncStatus `protobuf:"varint,9,opt,name=sync_status,json=syncStatus,proto3,enum=bytebase.store.SyncStatus" json:"sync_status,omitempty"`- // The error message if sync failed.- SyncError string `protobuf:"bytes,10,opt,name=sync_error,json=syncError,proto3" json:"sync_error,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DatabaseMetadata) Reset() {- *x = DatabaseMetadata{}- mi := &file_store_database_proto_msgTypes[0]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DatabaseMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DatabaseMetadata) ProtoMessage() {}--func (x *DatabaseMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[0]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DatabaseMetadata.ProtoReflect.Descriptor instead.-func (*DatabaseMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{0}-}--func (x *DatabaseMetadata) GetLabels() map[string]string {- if x != nil {- return x.Labels- }- return nil-}--func (x *DatabaseMetadata) GetLastSyncTime() *timestamppb.Timestamp {- if x != nil {- return x.LastSyncTime- }- return nil-}--func (x *DatabaseMetadata) GetBackupAvailable() bool {- if x != nil {- return x.BackupAvailable- }- return false-}--func (x *DatabaseMetadata) GetDatashare() bool {- if x != nil {- return x.Datashare- }- return false-}--func (x *DatabaseMetadata) GetRelease() string {- if x != nil {- return x.Release- }- return ""-}--func (x *DatabaseMetadata) GetSyncStatus() SyncStatus {- if x != nil {- return x.SyncStatus- }- return SyncStatus_SYNC_STATUS_UNSPECIFIED-}--func (x *DatabaseMetadata) GetSyncError() string {- if x != nil {- return x.SyncError- }- return ""-}--// DatabaseSchemaMetadata is the schema metadata for databases.-type DatabaseSchemaMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The list of schemas in a database.- Schemas []*SchemaMetadata `protobuf:"bytes,2,rep,name=schemas,proto3" json:"schemas,omitempty"`- // The character set of the database.- CharacterSet string `protobuf:"bytes,3,opt,name=character_set,json=characterSet,proto3" json:"character_set,omitempty"`- // The collation of the database.- Collation string `protobuf:"bytes,4,opt,name=collation,proto3" json:"collation,omitempty"`- // The list of extensions in a database.- Extensions []*ExtensionMetadata `protobuf:"bytes,5,rep,name=extensions,proto3" json:"extensions,omitempty"`- // The database belongs to a datashare.- Datashare bool `protobuf:"varint,6,opt,name=datashare,proto3" json:"datashare,omitempty"`- // The service name of the database. It's an Oracle-specific concept.- ServiceName string `protobuf:"bytes,7,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`- LinkedDatabases []*LinkedDatabaseMetadata `protobuf:"bytes,8,rep,name=linked_databases,json=linkedDatabases,proto3" json:"linked_databases,omitempty"`- Owner string `protobuf:"bytes,9,opt,name=owner,proto3" json:"owner,omitempty"`- // The search_path is the search path of a PostgreSQL database.- SearchPath string `protobuf:"bytes,10,opt,name=search_path,json=searchPath,proto3" json:"search_path,omitempty"`- // The list of event triggers in a database (PostgreSQL specific).- // Event triggers are database-level objects, not schema-scoped.- EventTriggers []*EventTriggerMetadata `protobuf:"bytes,11,rep,name=event_triggers,json=eventTriggers,proto3" json:"event_triggers,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DatabaseSchemaMetadata) Reset() {- *x = DatabaseSchemaMetadata{}- mi := &file_store_database_proto_msgTypes[1]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DatabaseSchemaMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DatabaseSchemaMetadata) ProtoMessage() {}--func (x *DatabaseSchemaMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[1]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DatabaseSchemaMetadata.ProtoReflect.Descriptor instead.-func (*DatabaseSchemaMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{1}-}--func (x *DatabaseSchemaMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *DatabaseSchemaMetadata) GetSchemas() []*SchemaMetadata {- if x != nil {- return x.Schemas- }- return nil-}--func (x *DatabaseSchemaMetadata) GetCharacterSet() string {- if x != nil {- return x.CharacterSet- }- return ""-}--func (x *DatabaseSchemaMetadata) GetCollation() string {- if x != nil {- return x.Collation- }- return ""-}--func (x *DatabaseSchemaMetadata) GetExtensions() []*ExtensionMetadata {- if x != nil {- return x.Extensions- }- return nil-}--func (x *DatabaseSchemaMetadata) GetDatashare() bool {- if x != nil {- return x.Datashare- }- return false-}--func (x *DatabaseSchemaMetadata) GetServiceName() string {- if x != nil {- return x.ServiceName- }- return ""-}--func (x *DatabaseSchemaMetadata) GetLinkedDatabases() []*LinkedDatabaseMetadata {- if x != nil {- return x.LinkedDatabases- }- return nil-}--func (x *DatabaseSchemaMetadata) GetOwner() string {- if x != nil {- return x.Owner- }- return ""-}--func (x *DatabaseSchemaMetadata) GetSearchPath() string {- if x != nil {- return x.SearchPath- }- return ""-}--func (x *DatabaseSchemaMetadata) GetEventTriggers() []*EventTriggerMetadata {- if x != nil {- return x.EventTriggers- }- return nil-}--type LinkedDatabaseMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`- Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *LinkedDatabaseMetadata) Reset() {- *x = LinkedDatabaseMetadata{}- mi := &file_store_database_proto_msgTypes[2]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *LinkedDatabaseMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*LinkedDatabaseMetadata) ProtoMessage() {}--func (x *LinkedDatabaseMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[2]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use LinkedDatabaseMetadata.ProtoReflect.Descriptor instead.-func (*LinkedDatabaseMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{2}-}--func (x *LinkedDatabaseMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *LinkedDatabaseMetadata) GetUsername() string {- if x != nil {- return x.Username- }- return ""-}--func (x *LinkedDatabaseMetadata) GetHost() string {- if x != nil {- return x.Host- }- return ""-}--// SchemaMetadata is the metadata for schemas.-// This is the concept of schema in Postgres, but it's a no-op for MySQL.-type SchemaMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The schema name.- // It is an empty string for databases without such concept such as MySQL.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The list of tables in a schema.- Tables []*TableMetadata `protobuf:"bytes,2,rep,name=tables,proto3" json:"tables,omitempty"`- // The list of external tables in a schema.- ExternalTables []*ExternalTableMetadata `protobuf:"bytes,3,rep,name=external_tables,json=externalTables,proto3" json:"external_tables,omitempty"`- // The list of views in a schema.- Views []*ViewMetadata `protobuf:"bytes,4,rep,name=views,proto3" json:"views,omitempty"`- // The list of functions in a schema.- Functions []*FunctionMetadata `protobuf:"bytes,5,rep,name=functions,proto3" json:"functions,omitempty"`- // The list of procedures in a schema.- Procedures []*ProcedureMetadata `protobuf:"bytes,6,rep,name=procedures,proto3" json:"procedures,omitempty"`- // The list of streams in a schema, currently only used for Snowflake.- Streams []*StreamMetadata `protobuf:"bytes,7,rep,name=streams,proto3" json:"streams,omitempty"`- // The list of tasks in a schema, currently only used for Snowflake.- Tasks []*TaskMetadata `protobuf:"bytes,8,rep,name=tasks,proto3" json:"tasks,omitempty"`- // The list of materialized views in a schema.- MaterializedViews []*MaterializedViewMetadata `protobuf:"bytes,9,rep,name=materialized_views,json=materializedViews,proto3" json:"materialized_views,omitempty"`- // The list of sequences in a schema.- Sequences []*SequenceMetadata `protobuf:"bytes,10,rep,name=sequences,proto3" json:"sequences,omitempty"`- // The list of packages in a schema.- Packages []*PackageMetadata `protobuf:"bytes,11,rep,name=packages,proto3" json:"packages,omitempty"`- Owner string `protobuf:"bytes,12,opt,name=owner,proto3" json:"owner,omitempty"`- Comment string `protobuf:"bytes,13,opt,name=comment,proto3" json:"comment,omitempty"`- Events []*EventMetadata `protobuf:"bytes,14,rep,name=events,proto3" json:"events,omitempty"`- EnumTypes []*EnumTypeMetadata `protobuf:"bytes,15,rep,name=enum_types,json=enumTypes,proto3" json:"enum_types,omitempty"`- SkipDump bool `protobuf:"varint,16,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- // The list of user-defined composite types in a schema (PostgreSQL family,- // CREATE TYPE ... AS). Excludes table/view row types and derived types.- CompositeTypes []*CompositeTypeMetadata `protobuf:"bytes,17,rep,name=composite_types,json=compositeTypes,proto3" json:"composite_types,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *SchemaMetadata) Reset() {- *x = SchemaMetadata{}- mi := &file_store_database_proto_msgTypes[3]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *SchemaMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*SchemaMetadata) ProtoMessage() {}--func (x *SchemaMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[3]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use SchemaMetadata.ProtoReflect.Descriptor instead.-func (*SchemaMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{3}-}--func (x *SchemaMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *SchemaMetadata) GetTables() []*TableMetadata {- if x != nil {- return x.Tables- }- return nil-}--func (x *SchemaMetadata) GetExternalTables() []*ExternalTableMetadata {- if x != nil {- return x.ExternalTables- }- return nil-}--func (x *SchemaMetadata) GetViews() []*ViewMetadata {- if x != nil {- return x.Views- }- return nil-}--func (x *SchemaMetadata) GetFunctions() []*FunctionMetadata {- if x != nil {- return x.Functions- }- return nil-}--func (x *SchemaMetadata) GetProcedures() []*ProcedureMetadata {- if x != nil {- return x.Procedures- }- return nil-}--func (x *SchemaMetadata) GetStreams() []*StreamMetadata {- if x != nil {- return x.Streams- }- return nil-}--func (x *SchemaMetadata) GetTasks() []*TaskMetadata {- if x != nil {- return x.Tasks- }- return nil-}--func (x *SchemaMetadata) GetMaterializedViews() []*MaterializedViewMetadata {- if x != nil {- return x.MaterializedViews- }- return nil-}--func (x *SchemaMetadata) GetSequences() []*SequenceMetadata {- if x != nil {- return x.Sequences- }- return nil-}--func (x *SchemaMetadata) GetPackages() []*PackageMetadata {- if x != nil {- return x.Packages- }- return nil-}--func (x *SchemaMetadata) GetOwner() string {- if x != nil {- return x.Owner- }- return ""-}--func (x *SchemaMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *SchemaMetadata) GetEvents() []*EventMetadata {- if x != nil {- return x.Events- }- return nil-}--func (x *SchemaMetadata) GetEnumTypes() []*EnumTypeMetadata {- if x != nil {- return x.EnumTypes- }- return nil-}--func (x *SchemaMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--func (x *SchemaMetadata) GetCompositeTypes() []*CompositeTypeMetadata {- if x != nil {- return x.CompositeTypes- }- return nil-}--type EnumTypeMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the enum type.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The enum values of the type.- Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`- Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"`- SkipDump bool `protobuf:"varint,4,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *EnumTypeMetadata) Reset() {- *x = EnumTypeMetadata{}- mi := &file_store_database_proto_msgTypes[4]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *EnumTypeMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*EnumTypeMetadata) ProtoMessage() {}--func (x *EnumTypeMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[4]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use EnumTypeMetadata.ProtoReflect.Descriptor instead.-func (*EnumTypeMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{4}-}--func (x *EnumTypeMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *EnumTypeMetadata) GetValues() []string {- if x != nil {- return x.Values- }- return nil-}--func (x *EnumTypeMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *EnumTypeMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--type CompositeTypeMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the composite type.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The ordered attributes of the composite type.- Attributes []*CompositeTypeAttribute `protobuf:"bytes,2,rep,name=attributes,proto3" json:"attributes,omitempty"`- Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"`- SkipDump bool `protobuf:"varint,4,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *CompositeTypeMetadata) Reset() {- *x = CompositeTypeMetadata{}- mi := &file_store_database_proto_msgTypes[5]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *CompositeTypeMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*CompositeTypeMetadata) ProtoMessage() {}--func (x *CompositeTypeMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[5]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use CompositeTypeMetadata.ProtoReflect.Descriptor instead.-func (*CompositeTypeMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{5}-}--func (x *CompositeTypeMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *CompositeTypeMetadata) GetAttributes() []*CompositeTypeAttribute {- if x != nil {- return x.Attributes- }- return nil-}--func (x *CompositeTypeMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *CompositeTypeMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--type CompositeTypeAttribute struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the attribute.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The attribute type. User-defined types are always schema-qualified.- Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`- // The non-default collation of the attribute as an emit-ready SQL- // identifier reference (quoted as needed, schema-qualified when outside- // pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`.- Collation string `protobuf:"bytes,3,opt,name=collation,proto3" json:"collation,omitempty"`- Comment string `protobuf:"bytes,4,opt,name=comment,proto3" json:"comment,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *CompositeTypeAttribute) Reset() {- *x = CompositeTypeAttribute{}- mi := &file_store_database_proto_msgTypes[6]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *CompositeTypeAttribute) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*CompositeTypeAttribute) ProtoMessage() {}--func (x *CompositeTypeAttribute) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[6]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use CompositeTypeAttribute.ProtoReflect.Descriptor instead.-func (*CompositeTypeAttribute) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{6}-}--func (x *CompositeTypeAttribute) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *CompositeTypeAttribute) GetType() string {- if x != nil {- return x.Type- }- return ""-}--func (x *CompositeTypeAttribute) GetCollation() string {- if x != nil {- return x.Collation- }- return ""-}--func (x *CompositeTypeAttribute) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--type EventMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the event.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The schedule of the event.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- // The time zone of the event.- TimeZone string `protobuf:"bytes,3,opt,name=time_zone,json=timeZone,proto3" json:"time_zone,omitempty"`- SqlMode string `protobuf:"bytes,4,opt,name=sql_mode,json=sqlMode,proto3" json:"sql_mode,omitempty"`- CharacterSetClient string `protobuf:"bytes,5,opt,name=character_set_client,json=characterSetClient,proto3" json:"character_set_client,omitempty"`- CollationConnection string `protobuf:"bytes,6,opt,name=collation_connection,json=collationConnection,proto3" json:"collation_connection,omitempty"`- Comment string `protobuf:"bytes,7,opt,name=comment,proto3" json:"comment,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *EventMetadata) Reset() {- *x = EventMetadata{}- mi := &file_store_database_proto_msgTypes[7]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *EventMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*EventMetadata) ProtoMessage() {}--func (x *EventMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[7]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use EventMetadata.ProtoReflect.Descriptor instead.-func (*EventMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{7}-}--func (x *EventMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *EventMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *EventMetadata) GetTimeZone() string {- if x != nil {- return x.TimeZone- }- return ""-}--func (x *EventMetadata) GetSqlMode() string {- if x != nil {- return x.SqlMode- }- return ""-}--func (x *EventMetadata) GetCharacterSetClient() string {- if x != nil {- return x.CharacterSetClient- }- return ""-}--func (x *EventMetadata) GetCollationConnection() string {- if x != nil {- return x.CollationConnection- }- return ""-}--func (x *EventMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--type SequenceMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of a sequence.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The data type of a sequence.- DataType string `protobuf:"bytes,2,opt,name=data_type,json=dataType,proto3" json:"data_type,omitempty"`- // The start value of a sequence.- Start string `protobuf:"bytes,3,opt,name=start,proto3" json:"start,omitempty"`- // The minimum value of a sequence.- MinValue string `protobuf:"bytes,4,opt,name=min_value,json=minValue,proto3" json:"min_value,omitempty"`- // The maximum value of a sequence.- MaxValue string `protobuf:"bytes,5,opt,name=max_value,json=maxValue,proto3" json:"max_value,omitempty"`- // The increment value of a sequence.- Increment string `protobuf:"bytes,6,opt,name=increment,proto3" json:"increment,omitempty"`- // Whether the sequence cycles.- Cycle bool `protobuf:"varint,7,opt,name=cycle,proto3" json:"cycle,omitempty"`- // Cache size of a sequence.- CacheSize string `protobuf:"bytes,8,opt,name=cache_size,json=cacheSize,proto3" json:"cache_size,omitempty"`- // The last value of a sequence.- LastValue string `protobuf:"bytes,9,opt,name=last_value,json=lastValue,proto3" json:"last_value,omitempty"`- // The table that owns the sequence.- OwnerTable string `protobuf:"bytes,10,opt,name=owner_table,json=ownerTable,proto3" json:"owner_table,omitempty"`- // The column that owns the sequence.- OwnerColumn string `protobuf:"bytes,11,opt,name=owner_column,json=ownerColumn,proto3" json:"owner_column,omitempty"`- Comment string `protobuf:"bytes,12,opt,name=comment,proto3" json:"comment,omitempty"`- SkipDump bool `protobuf:"varint,13,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *SequenceMetadata) Reset() {- *x = SequenceMetadata{}- mi := &file_store_database_proto_msgTypes[8]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *SequenceMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*SequenceMetadata) ProtoMessage() {}--func (x *SequenceMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[8]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use SequenceMetadata.ProtoReflect.Descriptor instead.-func (*SequenceMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{8}-}--func (x *SequenceMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *SequenceMetadata) GetDataType() string {- if x != nil {- return x.DataType- }- return ""-}--func (x *SequenceMetadata) GetStart() string {- if x != nil {- return x.Start- }- return ""-}--func (x *SequenceMetadata) GetMinValue() string {- if x != nil {- return x.MinValue- }- return ""-}--func (x *SequenceMetadata) GetMaxValue() string {- if x != nil {- return x.MaxValue- }- return ""-}--func (x *SequenceMetadata) GetIncrement() string {- if x != nil {- return x.Increment- }- return ""-}--func (x *SequenceMetadata) GetCycle() bool {- if x != nil {- return x.Cycle- }- return false-}--func (x *SequenceMetadata) GetCacheSize() string {- if x != nil {- return x.CacheSize- }- return ""-}--func (x *SequenceMetadata) GetLastValue() string {- if x != nil {- return x.LastValue- }- return ""-}--func (x *SequenceMetadata) GetOwnerTable() string {- if x != nil {- return x.OwnerTable- }- return ""-}--func (x *SequenceMetadata) GetOwnerColumn() string {- if x != nil {- return x.OwnerColumn- }- return ""-}--func (x *SequenceMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *SequenceMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--type TriggerMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the trigger.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The event that triggers this action, such as INSERT, UPDATE, DELETE, or TRUNCATE.- Event string `protobuf:"bytes,3,opt,name=event,proto3" json:"event,omitempty"`- // The timing of when the trigger fires, such as BEFORE or AFTER.- Timing string `protobuf:"bytes,4,opt,name=timing,proto3" json:"timing,omitempty"`- // The body of the trigger.- Body string `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`- SqlMode string `protobuf:"bytes,6,opt,name=sql_mode,json=sqlMode,proto3" json:"sql_mode,omitempty"`- CharacterSetClient string `protobuf:"bytes,7,opt,name=character_set_client,json=characterSetClient,proto3" json:"character_set_client,omitempty"`- CollationConnection string `protobuf:"bytes,8,opt,name=collation_connection,json=collationConnection,proto3" json:"collation_connection,omitempty"`- Comment string `protobuf:"bytes,9,opt,name=comment,proto3" json:"comment,omitempty"`- SkipDump bool `protobuf:"varint,10,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *TriggerMetadata) Reset() {- *x = TriggerMetadata{}- mi := &file_store_database_proto_msgTypes[9]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *TriggerMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*TriggerMetadata) ProtoMessage() {}--func (x *TriggerMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[9]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use TriggerMetadata.ProtoReflect.Descriptor instead.-func (*TriggerMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{9}-}--func (x *TriggerMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *TriggerMetadata) GetEvent() string {- if x != nil {- return x.Event- }- return ""-}--func (x *TriggerMetadata) GetTiming() string {- if x != nil {- return x.Timing- }- return ""-}--func (x *TriggerMetadata) GetBody() string {- if x != nil {- return x.Body- }- return ""-}--func (x *TriggerMetadata) GetSqlMode() string {- if x != nil {- return x.SqlMode- }- return ""-}--func (x *TriggerMetadata) GetCharacterSetClient() string {- if x != nil {- return x.CharacterSetClient- }- return ""-}--func (x *TriggerMetadata) GetCollationConnection() string {- if x != nil {- return x.CollationConnection- }- return ""-}--func (x *TriggerMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *TriggerMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--// RuleMetadata is the metadata for PostgreSQL rules.-type RuleMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the rule.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The event type of the rule: SELECT, INSERT, UPDATE, or DELETE.- Event string `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"`- // The WHERE condition of the rule (optional).- Condition string `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`- // The command(s) to execute when the rule fires.- Action string `protobuf:"bytes,4,opt,name=action,proto3" json:"action,omitempty"`- // The is_instead indicates whether this is an INSTEAD rule.- IsInstead bool `protobuf:"varint,5,opt,name=is_instead,json=isInstead,proto3" json:"is_instead,omitempty"`- // The is_enabled indicates whether the rule is enabled.- IsEnabled bool `protobuf:"varint,6,opt,name=is_enabled,json=isEnabled,proto3" json:"is_enabled,omitempty"`- // The full CREATE RULE statement.- Definition string `protobuf:"bytes,7,opt,name=definition,proto3" json:"definition,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *RuleMetadata) Reset() {- *x = RuleMetadata{}- mi := &file_store_database_proto_msgTypes[10]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *RuleMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*RuleMetadata) ProtoMessage() {}--func (x *RuleMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[10]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use RuleMetadata.ProtoReflect.Descriptor instead.-func (*RuleMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{10}-}--func (x *RuleMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *RuleMetadata) GetEvent() string {- if x != nil {- return x.Event- }- return ""-}--func (x *RuleMetadata) GetCondition() string {- if x != nil {- return x.Condition- }- return ""-}--func (x *RuleMetadata) GetAction() string {- if x != nil {- return x.Action- }- return ""-}--func (x *RuleMetadata) GetIsInstead() bool {- if x != nil {- return x.IsInstead- }- return false-}--func (x *RuleMetadata) GetIsEnabled() bool {- if x != nil {- return x.IsEnabled- }- return false-}--func (x *RuleMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--type TaskMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the task.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The Snowflake-generated ID of the task.- // Example: 01ad32a0-1bb6-5e93-0000-000000000001.- Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`- // The owner of the task.- Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"`- // The comment of the task.- Comment string `protobuf:"bytes,4,opt,name=comment,proto3" json:"comment,omitempty"`- // The warehouse of the task.- Warehouse string `protobuf:"bytes,5,opt,name=warehouse,proto3" json:"warehouse,omitempty"`- // The schedule interval of the task.- Schedule string `protobuf:"bytes,6,opt,name=schedule,proto3" json:"schedule,omitempty"`- // The predecessor tasks of the task.- Predecessors []string `protobuf:"bytes,7,rep,name=predecessors,proto3" json:"predecessors,omitempty"`- // The state of the task.- State TaskMetadata_State `protobuf:"varint,8,opt,name=state,proto3,enum=bytebase.store.TaskMetadata_State" json:"state,omitempty"`- // The condition of the task.- Condition string `protobuf:"bytes,9,opt,name=condition,proto3" json:"condition,omitempty"`- // The definition of the task.- Definition string `protobuf:"bytes,10,opt,name=definition,proto3" json:"definition,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *TaskMetadata) Reset() {- *x = TaskMetadata{}- mi := &file_store_database_proto_msgTypes[11]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *TaskMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*TaskMetadata) ProtoMessage() {}--func (x *TaskMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[11]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use TaskMetadata.ProtoReflect.Descriptor instead.-func (*TaskMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{11}-}--func (x *TaskMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *TaskMetadata) GetId() string {- if x != nil {- return x.Id- }- return ""-}--func (x *TaskMetadata) GetOwner() string {- if x != nil {- return x.Owner- }- return ""-}--func (x *TaskMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *TaskMetadata) GetWarehouse() string {- if x != nil {- return x.Warehouse- }- return ""-}--func (x *TaskMetadata) GetSchedule() string {- if x != nil {- return x.Schedule- }- return ""-}--func (x *TaskMetadata) GetPredecessors() []string {- if x != nil {- return x.Predecessors- }- return nil-}--func (x *TaskMetadata) GetState() TaskMetadata_State {- if x != nil {- return x.State- }- return TaskMetadata_STATE_UNSPECIFIED-}--func (x *TaskMetadata) GetCondition() string {- if x != nil {- return x.Condition- }- return ""-}--func (x *TaskMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--type StreamMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the stream.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The table_name is the name of the table/view that the stream is created on.- TableName string `protobuf:"bytes,2,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty"`- // The owner of the stream.- Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"`- // The comment of the stream.- Comment string `protobuf:"bytes,4,opt,name=comment,proto3" json:"comment,omitempty"`- // The type of the stream.- Type StreamMetadata_Type `protobuf:"varint,5,opt,name=type,proto3,enum=bytebase.store.StreamMetadata_Type" json:"type,omitempty"`- // Indicates whether the stream was last read before the `stale_after` time.- Stale bool `protobuf:"varint,6,opt,name=stale,proto3" json:"stale,omitempty"`- // The mode of the stream.- Mode StreamMetadata_Mode `protobuf:"varint,7,opt,name=mode,proto3,enum=bytebase.store.StreamMetadata_Mode" json:"mode,omitempty"`- // The definition of the stream.- Definition string `protobuf:"bytes,8,opt,name=definition,proto3" json:"definition,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *StreamMetadata) Reset() {- *x = StreamMetadata{}- mi := &file_store_database_proto_msgTypes[12]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *StreamMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*StreamMetadata) ProtoMessage() {}--func (x *StreamMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[12]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use StreamMetadata.ProtoReflect.Descriptor instead.-func (*StreamMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{12}-}--func (x *StreamMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *StreamMetadata) GetTableName() string {- if x != nil {- return x.TableName- }- return ""-}--func (x *StreamMetadata) GetOwner() string {- if x != nil {- return x.Owner- }- return ""-}--func (x *StreamMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *StreamMetadata) GetType() StreamMetadata_Type {- if x != nil {- return x.Type- }- return StreamMetadata_TYPE_UNSPECIFIED-}--func (x *StreamMetadata) GetStale() bool {- if x != nil {- return x.Stale- }- return false-}--func (x *StreamMetadata) GetMode() StreamMetadata_Mode {- if x != nil {- return x.Mode- }- return StreamMetadata_MODE_UNSPECIFIED-}--func (x *StreamMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--// TableMetadata is the metadata for tables.-type TableMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the table.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The columns is the ordered list of columns in a table.- Columns []*ColumnMetadata `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"`- // The indexes is the list of indexes in a table.- Indexes []*IndexMetadata `protobuf:"bytes,3,rep,name=indexes,proto3" json:"indexes,omitempty"`- // The engine is the engine of a table.- Engine string `protobuf:"bytes,4,opt,name=engine,proto3" json:"engine,omitempty"`- // The collation is the collation of a table.- Collation string `protobuf:"bytes,5,opt,name=collation,proto3" json:"collation,omitempty"`- // The character set of the table.- Charset string `protobuf:"bytes,17,opt,name=charset,proto3" json:"charset,omitempty"`- // The row_count is the estimated number of rows of a table.- RowCount int64 `protobuf:"varint,6,opt,name=row_count,json=rowCount,proto3" json:"row_count,omitempty"`- // The data_size is the estimated data size of a table.- DataSize int64 `protobuf:"varint,7,opt,name=data_size,json=dataSize,proto3" json:"data_size,omitempty"`- // The index_size is the estimated index size of a table.- IndexSize int64 `protobuf:"varint,8,opt,name=index_size,json=indexSize,proto3" json:"index_size,omitempty"`- // The data_free is the estimated free data size of a table.- DataFree int64 `protobuf:"varint,9,opt,name=data_free,json=dataFree,proto3" json:"data_free,omitempty"`- // The create_options is the create option of a table.- CreateOptions string `protobuf:"bytes,10,opt,name=create_options,json=createOptions,proto3" json:"create_options,omitempty"`- // The comment is the comment of a table.- Comment string `protobuf:"bytes,11,opt,name=comment,proto3" json:"comment,omitempty"`- // The foreign_keys is the list of foreign keys in a table.- ForeignKeys []*ForeignKeyMetadata `protobuf:"bytes,12,rep,name=foreign_keys,json=foreignKeys,proto3" json:"foreign_keys,omitempty"`- // The partitions is the list of partitions in a table.- Partitions []*TablePartitionMetadata `protobuf:"bytes,15,rep,name=partitions,proto3" json:"partitions,omitempty"`- // The check_constraints is the list of check constraints in a table.- CheckConstraints []*CheckConstraintMetadata `protobuf:"bytes,16,rep,name=check_constraints,json=checkConstraints,proto3" json:"check_constraints,omitempty"`- Owner string `protobuf:"bytes,18,opt,name=owner,proto3" json:"owner,omitempty"`- // The sorting_keys is a tuple of column names or arbitrary expressions. ClickHouse specific field.- // Reference: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#order_by- SortingKeys []string `protobuf:"bytes,19,rep,name=sorting_keys,json=sortingKeys,proto3" json:"sorting_keys,omitempty"`- Triggers []*TriggerMetadata `protobuf:"bytes,20,rep,name=triggers,proto3" json:"triggers,omitempty"`- SkipDump bool `protobuf:"varint,21,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- // The rules is the list of rules in a table (PostgreSQL specific).- Rules []*RuleMetadata `protobuf:"bytes,24,rep,name=rules,proto3" json:"rules,omitempty"`- // https://docs.pingcap.com/tidb/stable/information-schema-tables/- ShardingInfo string `protobuf:"bytes,22,opt,name=sharding_info,json=shardingInfo,proto3" json:"sharding_info,omitempty"`- // https://docs.pingcap.com/tidb/stable/clustered-indexes/#clustered-indexes- // CLUSTERED or NONCLUSTERED.- PrimaryKeyType string `protobuf:"bytes,23,opt,name=primary_key_type,json=primaryKeyType,proto3" json:"primary_key_type,omitempty"`- // The exclude_constraints is the list of EXCLUDE constraints in a table (PostgreSQL specific).- ExcludeConstraints []*ExcludeConstraintMetadata `protobuf:"bytes,25,rep,name=exclude_constraints,json=excludeConstraints,proto3" json:"exclude_constraints,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *TableMetadata) Reset() {- *x = TableMetadata{}- mi := &file_store_database_proto_msgTypes[13]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *TableMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*TableMetadata) ProtoMessage() {}--func (x *TableMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[13]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use TableMetadata.ProtoReflect.Descriptor instead.-func (*TableMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{13}-}--func (x *TableMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *TableMetadata) GetColumns() []*ColumnMetadata {- if x != nil {- return x.Columns- }- return nil-}--func (x *TableMetadata) GetIndexes() []*IndexMetadata {- if x != nil {- return x.Indexes- }- return nil-}--func (x *TableMetadata) GetEngine() string {- if x != nil {- return x.Engine- }- return ""-}--func (x *TableMetadata) GetCollation() string {- if x != nil {- return x.Collation- }- return ""-}--func (x *TableMetadata) GetCharset() string {- if x != nil {- return x.Charset- }- return ""-}--func (x *TableMetadata) GetRowCount() int64 {- if x != nil {- return x.RowCount- }- return 0-}--func (x *TableMetadata) GetDataSize() int64 {- if x != nil {- return x.DataSize- }- return 0-}--func (x *TableMetadata) GetIndexSize() int64 {- if x != nil {- return x.IndexSize- }- return 0-}--func (x *TableMetadata) GetDataFree() int64 {- if x != nil {- return x.DataFree- }- return 0-}--func (x *TableMetadata) GetCreateOptions() string {- if x != nil {- return x.CreateOptions- }- return ""-}--func (x *TableMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *TableMetadata) GetForeignKeys() []*ForeignKeyMetadata {- if x != nil {- return x.ForeignKeys- }- return nil-}--func (x *TableMetadata) GetPartitions() []*TablePartitionMetadata {- if x != nil {- return x.Partitions- }- return nil-}--func (x *TableMetadata) GetCheckConstraints() []*CheckConstraintMetadata {- if x != nil {- return x.CheckConstraints- }- return nil-}--func (x *TableMetadata) GetOwner() string {- if x != nil {- return x.Owner- }- return ""-}--func (x *TableMetadata) GetSortingKeys() []string {- if x != nil {- return x.SortingKeys- }- return nil-}--func (x *TableMetadata) GetTriggers() []*TriggerMetadata {- if x != nil {- return x.Triggers- }- return nil-}--func (x *TableMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--func (x *TableMetadata) GetRules() []*RuleMetadata {- if x != nil {- return x.Rules- }- return nil-}--func (x *TableMetadata) GetShardingInfo() string {- if x != nil {- return x.ShardingInfo- }- return ""-}--func (x *TableMetadata) GetPrimaryKeyType() string {- if x != nil {- return x.PrimaryKeyType- }- return ""-}--func (x *TableMetadata) GetExcludeConstraints() []*ExcludeConstraintMetadata {- if x != nil {- return x.ExcludeConstraints- }- return nil-}--type CheckConstraintMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the check constraint.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The expression is the expression of a check constraint.- Expression string `protobuf:"bytes,2,opt,name=expression,proto3" json:"expression,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *CheckConstraintMetadata) Reset() {- *x = CheckConstraintMetadata{}- mi := &file_store_database_proto_msgTypes[14]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *CheckConstraintMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*CheckConstraintMetadata) ProtoMessage() {}--func (x *CheckConstraintMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[14]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use CheckConstraintMetadata.ProtoReflect.Descriptor instead.-func (*CheckConstraintMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{14}-}--func (x *CheckConstraintMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *CheckConstraintMetadata) GetExpression() string {- if x != nil {- return x.Expression- }- return ""-}--type ExcludeConstraintMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the EXCLUDE constraint.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The expression is the full EXCLUDE constraint definition including "EXCLUDE" keyword.- // Example: "EXCLUDE USING gist (room_id WITH =, during WITH &&)"- Expression string `protobuf:"bytes,2,opt,name=expression,proto3" json:"expression,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ExcludeConstraintMetadata) Reset() {- *x = ExcludeConstraintMetadata{}- mi := &file_store_database_proto_msgTypes[15]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ExcludeConstraintMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ExcludeConstraintMetadata) ProtoMessage() {}--func (x *ExcludeConstraintMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[15]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ExcludeConstraintMetadata.ProtoReflect.Descriptor instead.-func (*ExcludeConstraintMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{15}-}--func (x *ExcludeConstraintMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ExcludeConstraintMetadata) GetExpression() string {- if x != nil {- return x.Expression- }- return ""-}--type ExternalTableMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the external table.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The external_server_name is the name of the external server.- ExternalServerName string `protobuf:"bytes,2,opt,name=external_server_name,json=externalServerName,proto3" json:"external_server_name,omitempty"`- // The external_database_name is the name of the external database.- ExternalDatabaseName string `protobuf:"bytes,3,opt,name=external_database_name,json=externalDatabaseName,proto3" json:"external_database_name,omitempty"`- // The columns is the ordered list of columns in a foreign table.- Columns []*ColumnMetadata `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ExternalTableMetadata) Reset() {- *x = ExternalTableMetadata{}- mi := &file_store_database_proto_msgTypes[16]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ExternalTableMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ExternalTableMetadata) ProtoMessage() {}--func (x *ExternalTableMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[16]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ExternalTableMetadata.ProtoReflect.Descriptor instead.-func (*ExternalTableMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{16}-}--func (x *ExternalTableMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ExternalTableMetadata) GetExternalServerName() string {- if x != nil {- return x.ExternalServerName- }- return ""-}--func (x *ExternalTableMetadata) GetExternalDatabaseName() string {- if x != nil {- return x.ExternalDatabaseName- }- return ""-}--func (x *ExternalTableMetadata) GetColumns() []*ColumnMetadata {- if x != nil {- return x.Columns- }- return nil-}--// TablePartitionMetadata is the metadata for table partitions.-type TablePartitionMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the table partition.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The type of a table partition.- Type TablePartitionMetadata_Type `protobuf:"varint,2,opt,name=type,proto3,enum=bytebase.store.TablePartitionMetadata_Type" json:"type,omitempty"`- // The expression is the expression of a table partition.- // For PostgreSQL, the expression is the text of {FOR VALUES- // partition_bound_spec}, see- // https://www.postgresql.org/docs/current/sql-createtable.html. For MySQL,- // the expression is the `expr` or `column_list` of the following syntax.- // PARTITION BY- //- // { [LINEAR] HASH(expr)- // | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)- // | RANGE{(expr) | COLUMNS(column_list)}- // | LIST{(expr) | COLUMNS(column_list)} }.- Expression string `protobuf:"bytes,3,opt,name=expression,proto3" json:"expression,omitempty"`- // The value is the value of a table partition.- // For MySQL, the value is for RANGE and LIST partition types,- // - For a RANGE partition, it contains the value set in the partition's- // VALUES LESS THAN clause, which can be either an integer or MAXVALUE.- // - For a LIST partition, this column contains the values defined in the- // partition's VALUES IN clause, which is a list of comma-separated integer- // values.- // - For others, it's an empty string.- Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`- // The use_default is whether the users use the default partition, it stores- // the different value for different database engines. For MySQL, it's [INT]- // type, 0 means not use default partition, otherwise, it's equals to number- // in syntax [SUB]PARTITION {number}.- UseDefault string `protobuf:"bytes,5,opt,name=use_default,json=useDefault,proto3" json:"use_default,omitempty"`- // The subpartitions is the list of subpartitions in a table partition.- Subpartitions []*TablePartitionMetadata `protobuf:"bytes,6,rep,name=subpartitions,proto3" json:"subpartitions,omitempty"`- Indexes []*IndexMetadata `protobuf:"bytes,7,rep,name=indexes,proto3" json:"indexes,omitempty"`- CheckConstraints []*CheckConstraintMetadata `protobuf:"bytes,8,rep,name=check_constraints,json=checkConstraints,proto3" json:"check_constraints,omitempty"`- ExcludeConstraints []*ExcludeConstraintMetadata `protobuf:"bytes,9,rep,name=exclude_constraints,json=excludeConstraints,proto3" json:"exclude_constraints,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *TablePartitionMetadata) Reset() {- *x = TablePartitionMetadata{}- mi := &file_store_database_proto_msgTypes[17]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *TablePartitionMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*TablePartitionMetadata) ProtoMessage() {}--func (x *TablePartitionMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[17]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use TablePartitionMetadata.ProtoReflect.Descriptor instead.-func (*TablePartitionMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{17}-}--func (x *TablePartitionMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *TablePartitionMetadata) GetType() TablePartitionMetadata_Type {- if x != nil {- return x.Type- }- return TablePartitionMetadata_TYPE_UNSPECIFIED-}--func (x *TablePartitionMetadata) GetExpression() string {- if x != nil {- return x.Expression- }- return ""-}--func (x *TablePartitionMetadata) GetValue() string {- if x != nil {- return x.Value- }- return ""-}--func (x *TablePartitionMetadata) GetUseDefault() string {- if x != nil {- return x.UseDefault- }- return ""-}--func (x *TablePartitionMetadata) GetSubpartitions() []*TablePartitionMetadata {- if x != nil {- return x.Subpartitions- }- return nil-}--func (x *TablePartitionMetadata) GetIndexes() []*IndexMetadata {- if x != nil {- return x.Indexes- }- return nil-}--func (x *TablePartitionMetadata) GetCheckConstraints() []*CheckConstraintMetadata {- if x != nil {- return x.CheckConstraints- }- return nil-}--func (x *TablePartitionMetadata) GetExcludeConstraints() []*ExcludeConstraintMetadata {- if x != nil {- return x.ExcludeConstraints- }- return nil-}--// ColumnMetadata is the metadata for columns.-type ColumnMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the column.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The position is the position in columns.- Position int32 `protobuf:"varint,2,opt,name=position,proto3" json:"position,omitempty"`- // The default value of the column.- Default string `protobuf:"bytes,3,opt,name=default,proto3" json:"default,omitempty"`- // Oracle specific metadata.- // The default_on_null is the default on null of a column.- DefaultOnNull bool `protobuf:"varint,16,opt,name=default_on_null,json=defaultOnNull,proto3" json:"default_on_null,omitempty"`- // The on_update is the on update action of a column.- // For MySQL like databases, it's only supported for TIMESTAMP columns with- // CURRENT_TIMESTAMP as on update value.- OnUpdate string `protobuf:"bytes,13,opt,name=on_update,json=onUpdate,proto3" json:"on_update,omitempty"`- // The nullable is the nullable of a column.- Nullable bool `protobuf:"varint,6,opt,name=nullable,proto3" json:"nullable,omitempty"`- // The type is the type of a column.- Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"`- // The character_set is the character_set of a column.- CharacterSet string `protobuf:"bytes,8,opt,name=character_set,json=characterSet,proto3" json:"character_set,omitempty"`- // The collation is the collation of a column.- Collation string `protobuf:"bytes,9,opt,name=collation,proto3" json:"collation,omitempty"`- // The comment is the comment of a column.- Comment string `protobuf:"bytes,10,opt,name=comment,proto3" json:"comment,omitempty"`- // The generation is for generated columns.- Generation *GenerationMetadata `protobuf:"bytes,14,opt,name=generation,proto3" json:"generation,omitempty"`- IsIdentity bool `protobuf:"varint,17,opt,name=is_identity,json=isIdentity,proto3" json:"is_identity,omitempty"`- // The identity_generation is for identity columns, PG only.- IdentityGeneration ColumnMetadata_IdentityGeneration `protobuf:"varint,15,opt,name=identity_generation,json=identityGeneration,proto3,enum=bytebase.store.ColumnMetadata_IdentityGeneration" json:"identity_generation,omitempty"`- // The identity_seed is for identity columns, MSSQL only.- IdentitySeed int64 `protobuf:"varint,18,opt,name=identity_seed,json=identitySeed,proto3" json:"identity_seed,omitempty"`- // The identity_increment is for identity columns, MSSQL only.- IdentityIncrement int64 `protobuf:"varint,19,opt,name=identity_increment,json=identityIncrement,proto3" json:"identity_increment,omitempty"`- // The default_constraint_name is the name of the default constraint, MSSQL only.- // In MSSQL, default values are implemented as named constraints. When modifying or- // dropping a column's default value, you must reference the constraint by name.- // This field stores the actual constraint name from the database.- //- // Example: A column definition like:- //- // CREATE TABLE employees (- // status NVARCHAR(20) DEFAULT 'active'- // )- //- // Will create a constraint with an auto-generated name like 'DF__employees__statu__3B75D760'- // or a user-defined name if specified:- //- // ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'active' FOR status- //- // To modify the default, you must first drop the existing constraint by name:- //- // ALTER TABLE employees DROP CONSTRAINT DF__employees__statu__3B75D760- // ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'inactive' FOR status- //- // This field is populated when syncing from the database. When empty (e.g., when parsing- // from SQL files), the system cannot automatically drop the constraint.- DefaultConstraintName string `protobuf:"bytes,20,opt,name=default_constraint_name,json=defaultConstraintName,proto3" json:"default_constraint_name,omitempty"`- // The spatial reference system identifier of a spatial column, MySQL 8.0 only.- // Unset means the column declares no SRID; presence carries the explicit SRID,- // including the valid SRID 0. SRS_IDs are unsigned 32-bit (custom SRSs may exceed- // int32). Captured from information_schema.COLUMNS.SRS_ID and rendered as the- // `/*!80003 SRID n */` column attribute.- Srid *uint32 `protobuf:"varint,21,opt,name=srid,proto3,oneof" json:"srid,omitempty"`- // Whether the column is invisible (hidden from SELECT *), MySQL 8.0.23+ only.- // Captured from information_schema.COLUMNS.EXTRA containing INVISIBLE and- // rendered as the `/*!80023 INVISIBLE */` column attribute.- IsInvisible bool `protobuf:"varint,22,opt,name=is_invisible,json=isInvisible,proto3" json:"is_invisible,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ColumnMetadata) Reset() {- *x = ColumnMetadata{}- mi := &file_store_database_proto_msgTypes[18]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ColumnMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ColumnMetadata) ProtoMessage() {}--func (x *ColumnMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[18]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ColumnMetadata.ProtoReflect.Descriptor instead.-func (*ColumnMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{18}-}--func (x *ColumnMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ColumnMetadata) GetPosition() int32 {- if x != nil {- return x.Position- }- return 0-}--func (x *ColumnMetadata) GetDefault() string {- if x != nil {- return x.Default- }- return ""-}--func (x *ColumnMetadata) GetDefaultOnNull() bool {- if x != nil {- return x.DefaultOnNull- }- return false-}--func (x *ColumnMetadata) GetOnUpdate() string {- if x != nil {- return x.OnUpdate- }- return ""-}--func (x *ColumnMetadata) GetNullable() bool {- if x != nil {- return x.Nullable- }- return false-}--func (x *ColumnMetadata) GetType() string {- if x != nil {- return x.Type- }- return ""-}--func (x *ColumnMetadata) GetCharacterSet() string {- if x != nil {- return x.CharacterSet- }- return ""-}--func (x *ColumnMetadata) GetCollation() string {- if x != nil {- return x.Collation- }- return ""-}--func (x *ColumnMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *ColumnMetadata) GetGeneration() *GenerationMetadata {- if x != nil {- return x.Generation- }- return nil-}--func (x *ColumnMetadata) GetIsIdentity() bool {- if x != nil {- return x.IsIdentity- }- return false-}--func (x *ColumnMetadata) GetIdentityGeneration() ColumnMetadata_IdentityGeneration {- if x != nil {- return x.IdentityGeneration- }- return ColumnMetadata_IDENTITY_GENERATION_UNSPECIFIED-}--func (x *ColumnMetadata) GetIdentitySeed() int64 {- if x != nil {- return x.IdentitySeed- }- return 0-}--func (x *ColumnMetadata) GetIdentityIncrement() int64 {- if x != nil {- return x.IdentityIncrement- }- return 0-}--func (x *ColumnMetadata) GetDefaultConstraintName() string {- if x != nil {- return x.DefaultConstraintName- }- return ""-}--func (x *ColumnMetadata) GetSrid() uint32 {- if x != nil && x.Srid != nil {- return *x.Srid- }- return 0-}--func (x *ColumnMetadata) GetIsInvisible() bool {- if x != nil {- return x.IsInvisible- }- return false-}--type GenerationMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- Type GenerationMetadata_Type `protobuf:"varint,1,opt,name=type,proto3,enum=bytebase.store.GenerationMetadata_Type" json:"type,omitempty"`- Expression string `protobuf:"bytes,2,opt,name=expression,proto3" json:"expression,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *GenerationMetadata) Reset() {- *x = GenerationMetadata{}- mi := &file_store_database_proto_msgTypes[19]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *GenerationMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*GenerationMetadata) ProtoMessage() {}--func (x *GenerationMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[19]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use GenerationMetadata.ProtoReflect.Descriptor instead.-func (*GenerationMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{19}-}--func (x *GenerationMetadata) GetType() GenerationMetadata_Type {- if x != nil {- return x.Type- }- return GenerationMetadata_TYPE_UNSPECIFIED-}--func (x *GenerationMetadata) GetExpression() string {- if x != nil {- return x.Expression- }- return ""-}--// ViewMetadata is the metadata for views.-type ViewMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the view.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The definition is the definition of a view.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- // The comment is the comment of a view.- Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"`- // The list of dependency columns of a view.- DependencyColumns []*DependencyColumn `protobuf:"bytes,4,rep,name=dependency_columns,json=dependencyColumns,proto3" json:"dependency_columns,omitempty"`- // The ordered list of columns in the view.- Columns []*ColumnMetadata `protobuf:"bytes,5,rep,name=columns,proto3" json:"columns,omitempty"`- // The list of triggers in the view.- Triggers []*TriggerMetadata `protobuf:"bytes,6,rep,name=triggers,proto3" json:"triggers,omitempty"`- SkipDump bool `protobuf:"varint,7,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- // The rules is the list of rules in a view (PostgreSQL specific).- Rules []*RuleMetadata `protobuf:"bytes,8,rep,name=rules,proto3" json:"rules,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ViewMetadata) Reset() {- *x = ViewMetadata{}- mi := &file_store_database_proto_msgTypes[20]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ViewMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ViewMetadata) ProtoMessage() {}--func (x *ViewMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[20]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ViewMetadata.ProtoReflect.Descriptor instead.-func (*ViewMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{20}-}--func (x *ViewMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ViewMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *ViewMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *ViewMetadata) GetDependencyColumns() []*DependencyColumn {- if x != nil {- return x.DependencyColumns- }- return nil-}--func (x *ViewMetadata) GetColumns() []*ColumnMetadata {- if x != nil {- return x.Columns- }- return nil-}--func (x *ViewMetadata) GetTriggers() []*TriggerMetadata {- if x != nil {- return x.Triggers- }- return nil-}--func (x *ViewMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--func (x *ViewMetadata) GetRules() []*RuleMetadata {- if x != nil {- return x.Rules- }- return nil-}--// DependencyColumn is the metadata for dependency columns.-type DependencyColumn struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The schema is the schema of a reference column.- Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`- // The table is the table of a reference column.- Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"`- // The column is the name of a reference column.- Column string `protobuf:"bytes,3,opt,name=column,proto3" json:"column,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DependencyColumn) Reset() {- *x = DependencyColumn{}- mi := &file_store_database_proto_msgTypes[21]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DependencyColumn) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DependencyColumn) ProtoMessage() {}--func (x *DependencyColumn) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[21]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DependencyColumn.ProtoReflect.Descriptor instead.-func (*DependencyColumn) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{21}-}--func (x *DependencyColumn) GetSchema() string {- if x != nil {- return x.Schema- }- return ""-}--func (x *DependencyColumn) GetTable() string {- if x != nil {- return x.Table- }- return ""-}--func (x *DependencyColumn) GetColumn() string {- if x != nil {- return x.Column- }- return ""-}--// MaterializedViewMetadata is the metadata for materialized views.-type MaterializedViewMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the materialized view.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The definition is the definition of a view.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- // The comment is the comment of a view.- Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"`- // The list of dependency columns of the view.- DependencyColumns []*DependencyColumn `protobuf:"bytes,4,rep,name=dependency_columns,json=dependencyColumns,proto3" json:"dependency_columns,omitempty"`- // The ordered list of columns in the materialized view.- Triggers []*TriggerMetadata `protobuf:"bytes,5,rep,name=triggers,proto3" json:"triggers,omitempty"`- // The list of indexes in the materialized view.- Indexes []*IndexMetadata `protobuf:"bytes,6,rep,name=indexes,proto3" json:"indexes,omitempty"`- SkipDump bool `protobuf:"varint,7,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *MaterializedViewMetadata) Reset() {- *x = MaterializedViewMetadata{}- mi := &file_store_database_proto_msgTypes[22]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *MaterializedViewMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*MaterializedViewMetadata) ProtoMessage() {}--func (x *MaterializedViewMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[22]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use MaterializedViewMetadata.ProtoReflect.Descriptor instead.-func (*MaterializedViewMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{22}-}--func (x *MaterializedViewMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *MaterializedViewMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *MaterializedViewMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *MaterializedViewMetadata) GetDependencyColumns() []*DependencyColumn {- if x != nil {- return x.DependencyColumns- }- return nil-}--func (x *MaterializedViewMetadata) GetTriggers() []*TriggerMetadata {- if x != nil {- return x.Triggers- }- return nil-}--func (x *MaterializedViewMetadata) GetIndexes() []*IndexMetadata {- if x != nil {- return x.Indexes- }- return nil-}--func (x *MaterializedViewMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--type DependencyTable struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The schema is the schema of a reference table.- Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`- // The table is the name of a reference table.- Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DependencyTable) Reset() {- *x = DependencyTable{}- mi := &file_store_database_proto_msgTypes[23]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DependencyTable) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DependencyTable) ProtoMessage() {}--func (x *DependencyTable) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[23]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DependencyTable.ProtoReflect.Descriptor instead.-func (*DependencyTable) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{23}-}--func (x *DependencyTable) GetSchema() string {- if x != nil {- return x.Schema- }- return ""-}--func (x *DependencyTable) GetTable() string {- if x != nil {- return x.Table- }- return ""-}--// FunctionMetadata is the metadata for functions.-type FunctionMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the function.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The definition is the definition of a function.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- // The signature is the name with the number and type of input arguments the- // function takes.- Signature string `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`- // MySQL specific metadata.- CharacterSetClient string `protobuf:"bytes,4,opt,name=character_set_client,json=characterSetClient,proto3" json:"character_set_client,omitempty"`- CollationConnection string `protobuf:"bytes,5,opt,name=collation_connection,json=collationConnection,proto3" json:"collation_connection,omitempty"`- DatabaseCollation string `protobuf:"bytes,6,opt,name=database_collation,json=databaseCollation,proto3" json:"database_collation,omitempty"`- SqlMode string `protobuf:"bytes,7,opt,name=sql_mode,json=sqlMode,proto3" json:"sql_mode,omitempty"`- Comment string `protobuf:"bytes,8,opt,name=comment,proto3" json:"comment,omitempty"`- // The dependency_tables is the list of dependency tables of a function.- // For PostgreSQL, it's the list of tables that the function depends on the return type definition.- DependencyTables []*DependencyTable `protobuf:"bytes,9,rep,name=dependency_tables,json=dependencyTables,proto3" json:"dependency_tables,omitempty"`- SkipDump bool `protobuf:"varint,10,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *FunctionMetadata) Reset() {- *x = FunctionMetadata{}- mi := &file_store_database_proto_msgTypes[24]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *FunctionMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*FunctionMetadata) ProtoMessage() {}--func (x *FunctionMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[24]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use FunctionMetadata.ProtoReflect.Descriptor instead.-func (*FunctionMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{24}-}--func (x *FunctionMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *FunctionMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *FunctionMetadata) GetSignature() string {- if x != nil {- return x.Signature- }- return ""-}--func (x *FunctionMetadata) GetCharacterSetClient() string {- if x != nil {- return x.CharacterSetClient- }- return ""-}--func (x *FunctionMetadata) GetCollationConnection() string {- if x != nil {- return x.CollationConnection- }- return ""-}--func (x *FunctionMetadata) GetDatabaseCollation() string {- if x != nil {- return x.DatabaseCollation- }- return ""-}--func (x *FunctionMetadata) GetSqlMode() string {- if x != nil {- return x.SqlMode- }- return ""-}--func (x *FunctionMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *FunctionMetadata) GetDependencyTables() []*DependencyTable {- if x != nil {- return x.DependencyTables- }- return nil-}--func (x *FunctionMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--// ProcedureMetadata is the metadata for procedures.-type ProcedureMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the procedure.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The definition is the definition of a procedure.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- // The signature is the name with the number and type of input arguments the- // function takes.- Signature string `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`- // MySQL specific metadata.- CharacterSetClient string `protobuf:"bytes,4,opt,name=character_set_client,json=characterSetClient,proto3" json:"character_set_client,omitempty"`- CollationConnection string `protobuf:"bytes,5,opt,name=collation_connection,json=collationConnection,proto3" json:"collation_connection,omitempty"`- DatabaseCollation string `protobuf:"bytes,6,opt,name=database_collation,json=databaseCollation,proto3" json:"database_collation,omitempty"`- SqlMode string `protobuf:"bytes,7,opt,name=sql_mode,json=sqlMode,proto3" json:"sql_mode,omitempty"`- Comment string `protobuf:"bytes,9,opt,name=comment,proto3" json:"comment,omitempty"`- SkipDump bool `protobuf:"varint,8,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ProcedureMetadata) Reset() {- *x = ProcedureMetadata{}- mi := &file_store_database_proto_msgTypes[25]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ProcedureMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ProcedureMetadata) ProtoMessage() {}--func (x *ProcedureMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[25]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ProcedureMetadata.ProtoReflect.Descriptor instead.-func (*ProcedureMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{25}-}--func (x *ProcedureMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ProcedureMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *ProcedureMetadata) GetSignature() string {- if x != nil {- return x.Signature- }- return ""-}--func (x *ProcedureMetadata) GetCharacterSetClient() string {- if x != nil {- return x.CharacterSetClient- }- return ""-}--func (x *ProcedureMetadata) GetCollationConnection() string {- if x != nil {- return x.CollationConnection- }- return ""-}--func (x *ProcedureMetadata) GetDatabaseCollation() string {- if x != nil {- return x.DatabaseCollation- }- return ""-}--func (x *ProcedureMetadata) GetSqlMode() string {- if x != nil {- return x.SqlMode- }- return ""-}--func (x *ProcedureMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *ProcedureMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false-}--// PackageMetadata is the metadata for packages.-type PackageMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the package.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The definition is the definition of a package.- Definition string `protobuf:"bytes,2,opt,name=definition,proto3" json:"definition,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *PackageMetadata) Reset() {- *x = PackageMetadata{}- mi := &file_store_database_proto_msgTypes[26]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *PackageMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*PackageMetadata) ProtoMessage() {}--func (x *PackageMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[26]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use PackageMetadata.ProtoReflect.Descriptor instead.-func (*PackageMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{26}-}--func (x *PackageMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *PackageMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--// IndexMetadata is the metadata for indexes.-type IndexMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the index.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The expressions are the ordered columns or expressions of an index.- //- // For PostgreSQL, the canonical shape for each entry matches- // pg_get_indexdef(oid, col, true) — the tightest `index_elem` grammar form:- // - column key: bare identifier e.g. "id", `"Name"`- // - function-call key: bare func_expr_windowless e.g. "lower(name)"- // - expression key: parenthesized a_expr e.g. "(payload ->> 'k'::text)"- //- // The DDL emitter writes entries verbatim into the CREATE INDEX key list.- Expressions []string `protobuf:"bytes,2,rep,name=expressions,proto3" json:"expressions,omitempty"`- // The ordered list of key lengths for the index.- // If the key length is not specified, it is -1.- KeyLength []int64 `protobuf:"varint,9,rep,packed,name=key_length,json=keyLength,proto3" json:"key_length,omitempty"`- // The ordered list of descending flags for the index columns.- Descending []bool `protobuf:"varint,10,rep,packed,name=descending,proto3" json:"descending,omitempty"`- // The type is the type of an index.- Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`- // The unique is whether the index is unique.- Unique bool `protobuf:"varint,4,opt,name=unique,proto3" json:"unique,omitempty"`- // The primary is whether the index is a primary key index.- Primary bool `protobuf:"varint,5,opt,name=primary,proto3" json:"primary,omitempty"`- // The visible is whether the index is visible.- Visible bool `protobuf:"varint,6,opt,name=visible,proto3" json:"visible,omitempty"`- // The comment is the comment of an index.- Comment string `protobuf:"bytes,7,opt,name=comment,proto3" json:"comment,omitempty"`- // The definition of an index.- Definition string `protobuf:"bytes,8,opt,name=definition,proto3" json:"definition,omitempty"`- // The schema name of the parent index.- ParentIndexSchema string `protobuf:"bytes,11,opt,name=parent_index_schema,json=parentIndexSchema,proto3" json:"parent_index_schema,omitempty"`- // The index name of the parent index.- ParentIndexName string `protobuf:"bytes,12,opt,name=parent_index_name,json=parentIndexName,proto3" json:"parent_index_name,omitempty"`- // The number of granules in the block. It's a ClickHouse specific field.- Granularity int64 `protobuf:"varint,13,opt,name=granularity,proto3" json:"granularity,omitempty"`- // It's a PostgreSQL specific field.- // The unique constraint and unique index are not the same thing in PostgreSQL.- IsConstraint bool `protobuf:"varint,14,opt,name=is_constraint,json=isConstraint,proto3" json:"is_constraint,omitempty"`- // Spatial index specific configuration- SpatialConfig *SpatialIndexConfig `protobuf:"bytes,15,opt,name=spatial_config,json=spatialConfig,proto3" json:"spatial_config,omitempty"`- // https://www.postgresql.org/docs/current/catalog-pg-opclass.html- // Name of the operator class for each column. (PostgreSQL specific).- OpclassNames []string `protobuf:"bytes,16,rep,name=opclass_names,json=opclassNames,proto3" json:"opclass_names,omitempty"`- // True if the operator class is the default. (PostgreSQL specific).- OpclassDefaults []bool `protobuf:"varint,17,rep,packed,name=opclass_defaults,json=opclassDefaults,proto3" json:"opclass_defaults,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *IndexMetadata) Reset() {- *x = IndexMetadata{}- mi := &file_store_database_proto_msgTypes[27]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *IndexMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*IndexMetadata) ProtoMessage() {}--func (x *IndexMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[27]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use IndexMetadata.ProtoReflect.Descriptor instead.-func (*IndexMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{27}-}--func (x *IndexMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *IndexMetadata) GetExpressions() []string {- if x != nil {- return x.Expressions- }- return nil-}--func (x *IndexMetadata) GetKeyLength() []int64 {- if x != nil {- return x.KeyLength- }- return nil-}--func (x *IndexMetadata) GetDescending() []bool {- if x != nil {- return x.Descending- }- return nil-}--func (x *IndexMetadata) GetType() string {- if x != nil {- return x.Type- }- return ""-}--func (x *IndexMetadata) GetUnique() bool {- if x != nil {- return x.Unique- }- return false-}--func (x *IndexMetadata) GetPrimary() bool {- if x != nil {- return x.Primary- }- return false-}--func (x *IndexMetadata) GetVisible() bool {- if x != nil {- return x.Visible- }- return false-}--func (x *IndexMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""-}--func (x *IndexMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""-}--func (x *IndexMetadata) GetParentIndexSchema() string {- if x != nil {- return x.ParentIndexSchema- }- return ""-}--func (x *IndexMetadata) GetParentIndexName() string {- if x != nil {- return x.ParentIndexName- }- return ""-}--func (x *IndexMetadata) GetGranularity() int64 {- if x != nil {- return x.Granularity- }- return 0-}--func (x *IndexMetadata) GetIsConstraint() bool {- if x != nil {- return x.IsConstraint- }- return false-}--func (x *IndexMetadata) GetSpatialConfig() *SpatialIndexConfig {- if x != nil {- return x.SpatialConfig- }- return nil-}--func (x *IndexMetadata) GetOpclassNames() []string {- if x != nil {- return x.OpclassNames- }- return nil-}--func (x *IndexMetadata) GetOpclassDefaults() []bool {- if x != nil {- return x.OpclassDefaults- }- return nil-}--// SpatialIndexConfig is the configuration for spatial indexes across different database engines.-type SpatialIndexConfig struct {- state protoimpl.MessageState `protogen:"open.v1"`- // Index method/type (database-specific)- // Examples: "SPATIAL" (MySQL/SQL Server), "GIST"/"SPGIST" (PostgreSQL), "MDSYS.SPATIAL_INDEX_V2" (Oracle)- Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`- // Tessellation configuration (primarily SQL Server)- Tessellation *TessellationConfig `protobuf:"bytes,2,opt,name=tessellation,proto3" json:"tessellation,omitempty"`- // Storage and performance parameters- Storage *StorageConfig `protobuf:"bytes,3,opt,name=storage,proto3" json:"storage,omitempty"`- // Dimensional and constraint parameters- Dimensional *DimensionalConfig `protobuf:"bytes,4,opt,name=dimensional,proto3" json:"dimensional,omitempty"`- // Database-specific parameters (stored as key-value pairs for extensibility)- EngineSpecific map[string]string `protobuf:"bytes,5,rep,name=engine_specific,json=engineSpecific,proto3" json:"engine_specific,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *SpatialIndexConfig) Reset() {- *x = SpatialIndexConfig{}- mi := &file_store_database_proto_msgTypes[28]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *SpatialIndexConfig) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*SpatialIndexConfig) ProtoMessage() {}--func (x *SpatialIndexConfig) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[28]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use SpatialIndexConfig.ProtoReflect.Descriptor instead.-func (*SpatialIndexConfig) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{28}-}--func (x *SpatialIndexConfig) GetMethod() string {- if x != nil {- return x.Method- }- return ""-}--func (x *SpatialIndexConfig) GetTessellation() *TessellationConfig {- if x != nil {- return x.Tessellation- }- return nil-}--func (x *SpatialIndexConfig) GetStorage() *StorageConfig {- if x != nil {- return x.Storage- }- return nil-}--func (x *SpatialIndexConfig) GetDimensional() *DimensionalConfig {- if x != nil {- return x.Dimensional- }- return nil-}--func (x *SpatialIndexConfig) GetEngineSpecific() map[string]string {- if x != nil {- return x.EngineSpecific- }- return nil-}--// TessellationConfig defines tessellation parameters for spatial indexes.-type TessellationConfig struct {- state protoimpl.MessageState `protogen:"open.v1"`- // Tessellation scheme- // Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID- Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"`- // Bounding box for GEOMETRY indexes (SQL Server)- BoundingBox *BoundingBox `protobuf:"bytes,2,opt,name=bounding_box,json=boundingBox,proto3" json:"bounding_box,omitempty"`- // Grid level configuration (SQL Server)- GridLevels []*GridLevel `protobuf:"bytes,3,rep,name=grid_levels,json=gridLevels,proto3" json:"grid_levels,omitempty"`- // Cells per object (SQL Server)- CellsPerObject int32 `protobuf:"varint,4,opt,name=cells_per_object,json=cellsPerObject,proto3" json:"cells_per_object,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *TessellationConfig) Reset() {- *x = TessellationConfig{}- mi := &file_store_database_proto_msgTypes[29]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *TessellationConfig) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*TessellationConfig) ProtoMessage() {}--func (x *TessellationConfig) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[29]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use TessellationConfig.ProtoReflect.Descriptor instead.-func (*TessellationConfig) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{29}-}--func (x *TessellationConfig) GetScheme() string {- if x != nil {- return x.Scheme- }- return ""-}--func (x *TessellationConfig) GetBoundingBox() *BoundingBox {- if x != nil {- return x.BoundingBox- }- return nil-}--func (x *TessellationConfig) GetGridLevels() []*GridLevel {- if x != nil {- return x.GridLevels- }- return nil-}--func (x *TessellationConfig) GetCellsPerObject() int32 {- if x != nil {- return x.CellsPerObject- }- return 0-}--// BoundingBox defines the bounding box for spatial indexes.-type BoundingBox struct {- state protoimpl.MessageState `protogen:"open.v1"`- Xmin float64 `protobuf:"fixed64,1,opt,name=xmin,proto3" json:"xmin,omitempty"`- Ymin float64 `protobuf:"fixed64,2,opt,name=ymin,proto3" json:"ymin,omitempty"`- Xmax float64 `protobuf:"fixed64,3,opt,name=xmax,proto3" json:"xmax,omitempty"`- Ymax float64 `protobuf:"fixed64,4,opt,name=ymax,proto3" json:"ymax,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *BoundingBox) Reset() {- *x = BoundingBox{}- mi := &file_store_database_proto_msgTypes[30]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *BoundingBox) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*BoundingBox) ProtoMessage() {}--func (x *BoundingBox) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[30]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use BoundingBox.ProtoReflect.Descriptor instead.-func (*BoundingBox) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{30}-}--func (x *BoundingBox) GetXmin() float64 {- if x != nil {- return x.Xmin- }- return 0-}--func (x *BoundingBox) GetYmin() float64 {- if x != nil {- return x.Ymin- }- return 0-}--func (x *BoundingBox) GetXmax() float64 {- if x != nil {- return x.Xmax- }- return 0-}--func (x *BoundingBox) GetYmax() float64 {- if x != nil {- return x.Ymax- }- return 0-}--// GridLevel defines a grid level for spatial tessellation.-type GridLevel struct {- state protoimpl.MessageState `protogen:"open.v1"`- Level int32 `protobuf:"varint,1,opt,name=level,proto3" json:"level,omitempty"` // 1-4 for SQL Server- Density string `protobuf:"bytes,2,opt,name=density,proto3" json:"density,omitempty"` // LOW, MEDIUM, HIGH- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *GridLevel) Reset() {- *x = GridLevel{}- mi := &file_store_database_proto_msgTypes[31]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *GridLevel) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*GridLevel) ProtoMessage() {}--func (x *GridLevel) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[31]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use GridLevel.ProtoReflect.Descriptor instead.-func (*GridLevel) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{31}-}--func (x *GridLevel) GetLevel() int32 {- if x != nil {- return x.Level- }- return 0-}--func (x *GridLevel) GetDensity() string {- if x != nil {- return x.Density- }- return ""-}--// StorageConfig defines storage and performance parameters for spatial indexes.-type StorageConfig struct {- state protoimpl.MessageState `protogen:"open.v1"`- // PostgreSQL parameters- Fillfactor int32 `protobuf:"varint,1,opt,name=fillfactor,proto3" json:"fillfactor,omitempty"` // 10-100- Buffering string `protobuf:"bytes,2,opt,name=buffering,proto3" json:"buffering,omitempty"` // auto, on, off- // Oracle parameters- Tablespace string `protobuf:"bytes,3,opt,name=tablespace,proto3" json:"tablespace,omitempty"`- WorkTablespace string `protobuf:"bytes,4,opt,name=work_tablespace,json=workTablespace,proto3" json:"work_tablespace,omitempty"`- SdoLevel int32 `protobuf:"varint,5,opt,name=sdo_level,json=sdoLevel,proto3" json:"sdo_level,omitempty"`- CommitInterval int32 `protobuf:"varint,6,opt,name=commit_interval,json=commitInterval,proto3" json:"commit_interval,omitempty"`- // SQL Server parameters- PadIndex bool `protobuf:"varint,7,opt,name=pad_index,json=padIndex,proto3" json:"pad_index,omitempty"`- SortInTempdb string `protobuf:"bytes,8,opt,name=sort_in_tempdb,json=sortInTempdb,proto3" json:"sort_in_tempdb,omitempty"` // ON, OFF- DropExisting bool `protobuf:"varint,9,opt,name=drop_existing,json=dropExisting,proto3" json:"drop_existing,omitempty"`- Online bool `protobuf:"varint,10,opt,name=online,proto3" json:"online,omitempty"`- AllowRowLocks bool `protobuf:"varint,11,opt,name=allow_row_locks,json=allowRowLocks,proto3" json:"allow_row_locks,omitempty"`- AllowPageLocks bool `protobuf:"varint,12,opt,name=allow_page_locks,json=allowPageLocks,proto3" json:"allow_page_locks,omitempty"`- Maxdop int32 `protobuf:"varint,13,opt,name=maxdop,proto3" json:"maxdop,omitempty"`- DataCompression string `protobuf:"bytes,14,opt,name=data_compression,json=dataCompression,proto3" json:"data_compression,omitempty"` // NONE, ROW, PAGE- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *StorageConfig) Reset() {- *x = StorageConfig{}- mi := &file_store_database_proto_msgTypes[32]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *StorageConfig) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*StorageConfig) ProtoMessage() {}--func (x *StorageConfig) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[32]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use StorageConfig.ProtoReflect.Descriptor instead.-func (*StorageConfig) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{32}-}--func (x *StorageConfig) GetFillfactor() int32 {- if x != nil {- return x.Fillfactor- }- return 0-}--func (x *StorageConfig) GetBuffering() string {- if x != nil {- return x.Buffering- }- return ""-}--func (x *StorageConfig) GetTablespace() string {- if x != nil {- return x.Tablespace- }- return ""-}--func (x *StorageConfig) GetWorkTablespace() string {- if x != nil {- return x.WorkTablespace- }- return ""-}--func (x *StorageConfig) GetSdoLevel() int32 {- if x != nil {- return x.SdoLevel- }- return 0-}--func (x *StorageConfig) GetCommitInterval() int32 {- if x != nil {- return x.CommitInterval- }- return 0-}--func (x *StorageConfig) GetPadIndex() bool {- if x != nil {- return x.PadIndex- }- return false-}--func (x *StorageConfig) GetSortInTempdb() string {- if x != nil {- return x.SortInTempdb- }- return ""-}--func (x *StorageConfig) GetDropExisting() bool {- if x != nil {- return x.DropExisting- }- return false-}--func (x *StorageConfig) GetOnline() bool {- if x != nil {- return x.Online- }- return false-}--func (x *StorageConfig) GetAllowRowLocks() bool {- if x != nil {- return x.AllowRowLocks- }- return false-}--func (x *StorageConfig) GetAllowPageLocks() bool {- if x != nil {- return x.AllowPageLocks- }- return false-}--func (x *StorageConfig) GetMaxdop() int32 {- if x != nil {- return x.Maxdop- }- return 0-}--func (x *StorageConfig) GetDataCompression() string {- if x != nil {- return x.DataCompression- }- return ""-}--// DimensionalConfig defines dimensional and constraint parameters for spatial indexes.-type DimensionalConfig struct {- state protoimpl.MessageState `protogen:"open.v1"`- // Number of dimensions (2-4, default 2)- Dimensions int32 `protobuf:"varint,1,opt,name=dimensions,proto3" json:"dimensions,omitempty"`- // Spatial data type- // Examples: GEOMETRY, GEOGRAPHY, POINT, POLYGON, etc.- DataType string `protobuf:"bytes,2,opt,name=data_type,json=dataType,proto3" json:"data_type,omitempty"`- // PostgreSQL operator class- // Examples: gist_geometry_ops_2d, gist_geometry_ops_nd, etc.- OperatorClass string `protobuf:"bytes,3,opt,name=operator_class,json=operatorClass,proto3" json:"operator_class,omitempty"`- // Oracle geometry type constraint- // Examples: POINT, LINE, POLYGON, COLLECTION- LayerGtype string `protobuf:"bytes,4,opt,name=layer_gtype,json=layerGtype,proto3" json:"layer_gtype,omitempty"`- // Parallel index creation- ParallelBuild bool `protobuf:"varint,5,opt,name=parallel_build,json=parallelBuild,proto3" json:"parallel_build,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DimensionalConfig) Reset() {- *x = DimensionalConfig{}- mi := &file_store_database_proto_msgTypes[33]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DimensionalConfig) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DimensionalConfig) ProtoMessage() {}--func (x *DimensionalConfig) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[33]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DimensionalConfig.ProtoReflect.Descriptor instead.-func (*DimensionalConfig) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{33}-}--func (x *DimensionalConfig) GetDimensions() int32 {- if x != nil {- return x.Dimensions- }- return 0-}--func (x *DimensionalConfig) GetDataType() string {- if x != nil {- return x.DataType- }- return ""-}--func (x *DimensionalConfig) GetOperatorClass() string {- if x != nil {- return x.OperatorClass- }- return ""-}--func (x *DimensionalConfig) GetLayerGtype() string {- if x != nil {- return x.LayerGtype- }- return ""-}--func (x *DimensionalConfig) GetParallelBuild() bool {- if x != nil {- return x.ParallelBuild- }- return false-}--// ExtensionMetadata is the metadata for extensions.-type ExtensionMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the extension.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The schema where the extension is installed. However, the extension usage- // is not limited to the schema.- Schema string `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"`- // The version is the version of an extension.- Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`- // The description is the description of an extension.- Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *ExtensionMetadata) Reset() {- *x = ExtensionMetadata{}- mi := &file_store_database_proto_msgTypes[34]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *ExtensionMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ExtensionMetadata) ProtoMessage() {}--func (x *ExtensionMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[34]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ExtensionMetadata.ProtoReflect.Descriptor instead.-func (*ExtensionMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{34}-}--func (x *ExtensionMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ExtensionMetadata) GetSchema() string {- if x != nil {- return x.Schema- }- return ""-}--func (x *ExtensionMetadata) GetVersion() string {- if x != nil {- return x.Version- }- return ""-}--func (x *ExtensionMetadata) GetDescription() string {- if x != nil {- return x.Description- }- return ""-}--// EventTriggerMetadata is the metadata for PostgreSQL event triggers.-// Event triggers are database-level objects that fire on DDL events.-type EventTriggerMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the event trigger.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The event type: DDL_COMMAND_START, DDL_COMMAND_END, SQL_DROP, TABLE_REWRITE.- Event string `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"`- // The tags filter (e.g., ['CREATE TABLE', 'DROP TABLE']).- Tags []string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"`- // The schema of the function to execute.- FunctionSchema string `protobuf:"bytes,4,opt,name=function_schema,json=functionSchema,proto3" json:"function_schema,omitempty"`- // The name of the function to execute.- FunctionName string `protobuf:"bytes,5,opt,name=function_name,json=functionName,proto3" json:"function_name,omitempty"`- // Whether the trigger is enabled.- Enabled bool `protobuf:"varint,6,opt,name=enabled,proto3" json:"enabled,omitempty"`- // The full CREATE EVENT TRIGGER definition from pg_get_event_trigger_def().- // SDL output should prefer using this field.- Definition string `protobuf:"bytes,7,opt,name=definition,proto3" json:"definition,omitempty"`- // The comment on the event trigger.- Comment string `protobuf:"bytes,8,opt,name=comment,proto3" json:"comment,omitempty"`- // Skip dump flag (for extension-owned triggers).- SkipDump bool `protobuf:"varint,9,opt,name=skip_dump,json=skipDump,proto3" json:"skip_dump,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *EventTriggerMetadata) Reset() {- *x = EventTriggerMetadata{}- mi := &file_store_database_proto_msgTypes[35]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *EventTriggerMetadata) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*EventTriggerMetadata) ProtoMessage() {}--func (x *EventTriggerMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[35]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use EventTriggerMetadata.ProtoReflect.Descriptor instead.-func (*EventTriggerMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{35}-}+type ObjectSchema_Type int32-func (x *EventTriggerMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""-}+const (+ ObjectSchema_TYPE_UNSPECIFIED ObjectSchema_Type = 0+ ObjectSchema_STRING ObjectSchema_Type = 1+ ObjectSchema_NUMBER ObjectSchema_Type = 2+ ObjectSchema_BOOLEAN ObjectSchema_Type = 3+ ObjectSchema_OBJECT ObjectSchema_Type = 4+ ObjectSchema_ARRAY ObjectSchema_Type = 5+)-func (x *EventTriggerMetadata) GetEvent() string {- if x != nil {- return x.Event+// Enum value maps for ObjectSchema_Type.+var (+ ObjectSchema_Type_name = map[int32]string{+ 0: "TYPE_UNSPECIFIED",+ 1: "STRING",+ 2: "NUMBER",+ 3: "BOOLEAN",+ 4: "OBJECT",+ 5: "ARRAY",}- return ""-}--func (x *EventTriggerMetadata) GetTags() []string {- if x != nil {- return x.Tags+ ObjectSchema_Type_value = map[string]int32{+ "TYPE_UNSPECIFIED": 0,+ "STRING": 1,+ "NUMBER": 2,+ "BOOLEAN": 3,+ "OBJECT": 4,+ "ARRAY": 5,}- return nil-}+)-func (x *EventTriggerMetadata) GetFunctionSchema() string {- if x != nil {- return x.FunctionSchema- }- return ""+func (x ObjectSchema_Type) Enum() *ObjectSchema_Type {+ p := new(ObjectSchema_Type)+ *p = x+ return p}-func (x *EventTriggerMetadata) GetFunctionName() string {- if x != nil {- return x.FunctionName- }- return ""+func (x ObjectSchema_Type) String() string {+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))}-func (x *EventTriggerMetadata) GetEnabled() bool {- if x != nil {- return x.Enabled- }- return false+func (ObjectSchema_Type) Descriptor() protoreflect.EnumDescriptor {+ return file_store_database_proto_enumTypes[1].Descriptor()}-func (x *EventTriggerMetadata) GetDefinition() string {- if x != nil {- return x.Definition- }- return ""+func (ObjectSchema_Type) Type() protoreflect.EnumType {+ return &file_store_database_proto_enumTypes[1]}-func (x *EventTriggerMetadata) GetComment() string {- if x != nil {- return x.Comment- }- return ""+func (x ObjectSchema_Type) Number() protoreflect.EnumNumber {+ return protoreflect.EnumNumber(x)}-func (x *EventTriggerMetadata) GetSkipDump() bool {- if x != nil {- return x.SkipDump- }- return false+// Deprecated: Use ObjectSchema_Type.Descriptor instead.+func (ObjectSchema_Type) EnumDescriptor() ([]byte, []int) {+ return file_store_database_proto_rawDescGZIP(), []int{6, 0}}-// ForeignKeyMetadata is the metadata for foreign keys.-type ForeignKeyMetadata struct {- state protoimpl.MessageState `protogen:"open.v1"`- // The name of the foreign key.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The columns are the ordered referencing columns of a foreign key.- Columns []string `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"`- // The referenced_schema is the referenced schema name of a foreign key.- // It is an empty string for databases without such concept such as MySQL.- ReferencedSchema string `protobuf:"bytes,3,opt,name=referenced_schema,json=referencedSchema,proto3" json:"referenced_schema,omitempty"`- // The referenced_table is the referenced table name of a foreign key.- ReferencedTable string `protobuf:"bytes,4,opt,name=referenced_table,json=referencedTable,proto3" json:"referenced_table,omitempty"`- // The referenced_columns are the ordered referenced columns of a foreign key.- ReferencedColumns []string `protobuf:"bytes,5,rep,name=referenced_columns,json=referencedColumns,proto3" json:"referenced_columns,omitempty"`- // The on_delete is the on delete action of a foreign key.- OnDelete string `protobuf:"bytes,6,opt,name=on_delete,json=onDelete,proto3" json:"on_delete,omitempty"`- // The on_update is the on update action of a foreign key.- OnUpdate string `protobuf:"bytes,7,opt,name=on_update,json=onUpdate,proto3" json:"on_update,omitempty"`- // The match_type is the match type of a foreign key.- // The match_type is the PostgreSQL specific field.- // It's empty string for other databases.- MatchType string `protobuf:"bytes,8,opt,name=match_type,json=matchType,proto3" json:"match_type,omitempty"`+// DatabaseMetadata is the metadata for databases.+type DatabaseMetadata struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ Labels map[string]string `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`+ LastSyncTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=last_sync_time,json=lastSyncTime,proto3" json:"last_sync_time,omitempty"`+ BackupAvailable bool `protobuf:"varint,3,opt,name=backup_available,json=backupAvailable,proto3" json:"backup_available,omitempty"`+ Datashare bool `protobuf:"varint,4,opt,name=datashare,proto3" json:"datashare,omitempty"`+ // The release that was last applied to this database.+ // Format: projects/{project}/releases/{release_id}+ Release string `protobuf:"bytes,8,opt,name=release,proto3" json:"release,omitempty"`+ // The sync status of the database.+ SyncStatus SyncStatus `protobuf:"varint,9,opt,name=sync_status,json=syncStatus,proto3,enum=bytebase.store.SyncStatus" json:"sync_status,omitempty"`+ // The error message if sync failed.+ SyncError string `protobuf:"bytes,10,opt,name=sync_error,json=syncError,proto3" json:"sync_error,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCache}-func (x *ForeignKeyMetadata) Reset() {- *x = ForeignKeyMetadata{}- mi := &file_store_database_proto_msgTypes[36]+func (x *DatabaseMetadata) Reset() {+ *x = DatabaseMetadata{}+ mi := &file_store_database_proto_msgTypes[0]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}-func (x *ForeignKeyMetadata) String() string {+func (x *DatabaseMetadata) String() string {return protoimpl.X.MessageStringOf(x)}-func (*ForeignKeyMetadata) ProtoMessage() {}+func (*DatabaseMetadata) ProtoMessage() {}-func (x *ForeignKeyMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[36]+func (x *DatabaseMetadata) ProtoReflect() protoreflect.Message {+ mi := &file_store_database_proto_msgTypes[0]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4254,63 +173,56 @@ func (x *ForeignKeyMetadata) ProtoReflect() protoreflect.Message {return mi.MessageOf(x)}-// Deprecated: Use ForeignKeyMetadata.ProtoReflect.Descriptor instead.-func (*ForeignKeyMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{36}-}--func (x *ForeignKeyMetadata) GetName() string {- if x != nil {- return x.Name- }- return ""+// Deprecated: Use DatabaseMetadata.ProtoReflect.Descriptor instead.+func (*DatabaseMetadata) Descriptor() ([]byte, []int) {+ return file_store_database_proto_rawDescGZIP(), []int{0}}-func (x *ForeignKeyMetadata) GetColumns() []string {+func (x *DatabaseMetadata) GetLabels() map[string]string {if x != nil {- return x.Columns+ return x.Labels}return nil}-func (x *ForeignKeyMetadata) GetReferencedSchema() string {+func (x *DatabaseMetadata) GetLastSyncTime() *timestamppb.Timestamp {if x != nil {- return x.ReferencedSchema+ return x.LastSyncTime}- return ""+ return nil}-func (x *ForeignKeyMetadata) GetReferencedTable() string {+func (x *DatabaseMetadata) GetBackupAvailable() bool {if x != nil {- return x.ReferencedTable+ return x.BackupAvailable}- return ""+ return false}-func (x *ForeignKeyMetadata) GetReferencedColumns() []string {+func (x *DatabaseMetadata) GetDatashare() bool {if x != nil {- return x.ReferencedColumns+ return x.Datashare}- return nil+ return false}-func (x *ForeignKeyMetadata) GetOnDelete() string {+func (x *DatabaseMetadata) GetRelease() string {if x != nil {- return x.OnDelete+ return x.Release}return ""}-func (x *ForeignKeyMetadata) GetOnUpdate() string {+func (x *DatabaseMetadata) GetSyncStatus() SyncStatus {if x != nil {- return x.OnUpdate+ return x.SyncStatus}- return ""+ return SyncStatus_SYNC_STATUS_UNSPECIFIED}-func (x *ForeignKeyMetadata) GetMatchType() string {+func (x *DatabaseMetadata) GetSyncError() string {if x != nil {- return x.MatchType+ return x.SyncError}return ""}@@ -4329,7 +241,7 @@ type InstanceRoleMetadata struct {func (x *InstanceRoleMetadata) Reset() {*x = InstanceRoleMetadata{}- mi := &file_store_database_proto_msgTypes[37]+ mi := &file_store_database_proto_msgTypes[1]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4341,7 +253,7 @@ func (x *InstanceRoleMetadata) String() string {func (*InstanceRoleMetadata) ProtoMessage() {}func (x *InstanceRoleMetadata) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[37]+ mi := &file_store_database_proto_msgTypes[1]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4354,7 +266,7 @@ func (x *InstanceRoleMetadata) ProtoReflect() protoreflect.Message {// Deprecated: Use InstanceRoleMetadata.ProtoReflect.Descriptor instead.func (*InstanceRoleMetadata) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{37}+ return file_store_database_proto_rawDescGZIP(), []int{1}}func (x *InstanceRoleMetadata) GetName() string {@@ -4382,7 +294,7 @@ type DatabaseConfig struct {func (x *DatabaseConfig) Reset() {*x = DatabaseConfig{}- mi := &file_store_database_proto_msgTypes[38]+ mi := &file_store_database_proto_msgTypes[2]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4394,7 +306,7 @@ func (x *DatabaseConfig) String() string {func (*DatabaseConfig) ProtoMessage() {}func (x *DatabaseConfig) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[38]+ mi := &file_store_database_proto_msgTypes[2]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4407,7 +319,7 @@ func (x *DatabaseConfig) ProtoReflect() protoreflect.Message {// Deprecated: Use DatabaseConfig.ProtoReflect.Descriptor instead.func (*DatabaseConfig) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{38}+ return file_store_database_proto_rawDescGZIP(), []int{2}}func (x *DatabaseConfig) GetName() string {@@ -4437,7 +349,7 @@ type SchemaCatalog struct {func (x *SchemaCatalog) Reset() {*x = SchemaCatalog{}- mi := &file_store_database_proto_msgTypes[39]+ mi := &file_store_database_proto_msgTypes[3]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4449,7 +361,7 @@ func (x *SchemaCatalog) String() string {func (*SchemaCatalog) ProtoMessage() {}func (x *SchemaCatalog) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[39]+ mi := &file_store_database_proto_msgTypes[3]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4462,7 +374,7 @@ func (x *SchemaCatalog) ProtoReflect() protoreflect.Message {// Deprecated: Use SchemaCatalog.ProtoReflect.Descriptor instead.func (*SchemaCatalog) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{39}+ return file_store_database_proto_rawDescGZIP(), []int{3}}func (x *SchemaCatalog) GetName() string {@@ -4493,7 +405,7 @@ type TableCatalog struct {func (x *TableCatalog) Reset() {*x = TableCatalog{}- mi := &file_store_database_proto_msgTypes[40]+ mi := &file_store_database_proto_msgTypes[4]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4505,7 +417,7 @@ func (x *TableCatalog) String() string {func (*TableCatalog) ProtoMessage() {}func (x *TableCatalog) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[40]+ mi := &file_store_database_proto_msgTypes[4]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4518,7 +430,7 @@ func (x *TableCatalog) ProtoReflect() protoreflect.Message {// Deprecated: Use TableCatalog.ProtoReflect.Descriptor instead.func (*TableCatalog) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{40}+ return file_store_database_proto_rawDescGZIP(), []int{4}}func (x *TableCatalog) GetName() string {@@ -4564,7 +476,7 @@ type ColumnCatalog struct {func (x *ColumnCatalog) Reset() {*x = ColumnCatalog{}- mi := &file_store_database_proto_msgTypes[41]+ mi := &file_store_database_proto_msgTypes[5]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4576,7 +488,7 @@ func (x *ColumnCatalog) String() string {func (*ColumnCatalog) ProtoMessage() {}func (x *ColumnCatalog) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[41]+ mi := &file_store_database_proto_msgTypes[5]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4589,7 +501,7 @@ func (x *ColumnCatalog) ProtoReflect() protoreflect.Message {// Deprecated: Use ColumnCatalog.ProtoReflect.Descriptor instead.func (*ColumnCatalog) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{41}+ return file_store_database_proto_rawDescGZIP(), []int{5}}func (x *ColumnCatalog) GetName() string {@@ -4642,7 +554,7 @@ type ObjectSchema struct {func (x *ObjectSchema) Reset() {*x = ObjectSchema{}- mi := &file_store_database_proto_msgTypes[42]+ mi := &file_store_database_proto_msgTypes[6]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4654,7 +566,7 @@ func (x *ObjectSchema) String() string {func (*ObjectSchema) ProtoMessage() {}func (x *ObjectSchema) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[42]+ mi := &file_store_database_proto_msgTypes[6]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4667,7 +579,7 @@ func (x *ObjectSchema) ProtoReflect() protoreflect.Message {// Deprecated: Use ObjectSchema.ProtoReflect.Descriptor instead.func (*ObjectSchema) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{42}+ return file_store_database_proto_rawDescGZIP(), []int{6}}func (x *ObjectSchema) GetType() ObjectSchema_Type {@@ -4734,7 +646,7 @@ type ObjectSchema_StructKind struct {func (x *ObjectSchema_StructKind) Reset() {*x = ObjectSchema_StructKind{}- mi := &file_store_database_proto_msgTypes[46]+ mi := &file_store_database_proto_msgTypes[9]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4746,7 +658,7 @@ func (x *ObjectSchema_StructKind) String() string {func (*ObjectSchema_StructKind) ProtoMessage() {}func (x *ObjectSchema_StructKind) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[46]+ mi := &file_store_database_proto_msgTypes[9]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4759,7 +671,7 @@ func (x *ObjectSchema_StructKind) ProtoReflect() protoreflect.Message {// Deprecated: Use ObjectSchema_StructKind.ProtoReflect.Descriptor instead.func (*ObjectSchema_StructKind) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{42, 0}+ return file_store_database_proto_rawDescGZIP(), []int{6, 0}}func (x *ObjectSchema_StructKind) GetProperties() map[string]*ObjectSchema {@@ -4778,7 +690,7 @@ type ObjectSchema_ArrayKind struct {func (x *ObjectSchema_ArrayKind) Reset() {*x = ObjectSchema_ArrayKind{}- mi := &file_store_database_proto_msgTypes[47]+ mi := &file_store_database_proto_msgTypes[10]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -4790,7 +702,7 @@ func (x *ObjectSchema_ArrayKind) String() string {func (*ObjectSchema_ArrayKind) ProtoMessage() {}func (x *ObjectSchema_ArrayKind) ProtoReflect() protoreflect.Message {- mi := &file_store_database_proto_msgTypes[47]+ mi := &file_store_database_proto_msgTypes[10]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -4803,7 +715,7 @@ func (x *ObjectSchema_ArrayKind) ProtoReflect() protoreflect.Message {// Deprecated: Use ObjectSchema_ArrayKind.ProtoReflect.Descriptor instead.func (*ObjectSchema_ArrayKind) Descriptor() ([]byte, []int) {- return file_store_database_proto_rawDescGZIP(), []int{42, 1}+ return file_store_database_proto_rawDescGZIP(), []int{6, 1}}func (x *ObjectSchema_ArrayKind) GetKind() *ObjectSchema {@@ -4831,424 +743,7 @@ const file_store_database_proto_rawDesc = "" +" \x01(\tR\tsyncError\x1a9\n" +"\vLabelsEntry\x12\x10\n" +"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\a\x10\b\"\x84\x04\n" +- "\x16DatabaseSchemaMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x128\n" +- "\aschemas\x18\x02 \x03(\v2\x1e.bytebase.store.SchemaMetadataR\aschemas\x12#\n" +- "\rcharacter_set\x18\x03 \x01(\tR\fcharacterSet\x12\x1c\n" +- "\tcollation\x18\x04 \x01(\tR\tcollation\x12A\n" +- "\n" +- "extensions\x18\x05 \x03(\v2!.bytebase.store.ExtensionMetadataR\n" +- "extensions\x12\x1c\n" +- "\tdatashare\x18\x06 \x01(\bR\tdatashare\x12!\n" +- "\fservice_name\x18\a \x01(\tR\vserviceName\x12Q\n" +- "\x10linked_databases\x18\b \x03(\v2&.bytebase.store.LinkedDatabaseMetadataR\x0flinkedDatabases\x12\x14\n" +- "\x05owner\x18\t \x01(\tR\x05owner\x12\x1f\n" +- "\vsearch_path\x18\n" +- " \x01(\tR\n" +- "searchPath\x12K\n" +- "\x0eevent_triggers\x18\v \x03(\v2$.bytebase.store.EventTriggerMetadataR\reventTriggers\"\\\n" +- "\x16LinkedDatabaseMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +- "\busername\x18\x02 \x01(\tR\busername\x12\x12\n" +- "\x04host\x18\x03 \x01(\tR\x04host\"\xbb\a\n" +- "\x0eSchemaMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x125\n" +- "\x06tables\x18\x02 \x03(\v2\x1d.bytebase.store.TableMetadataR\x06tables\x12N\n" +- "\x0fexternal_tables\x18\x03 \x03(\v2%.bytebase.store.ExternalTableMetadataR\x0eexternalTables\x122\n" +- "\x05views\x18\x04 \x03(\v2\x1c.bytebase.store.ViewMetadataR\x05views\x12>\n" +- "\tfunctions\x18\x05 \x03(\v2 .bytebase.store.FunctionMetadataR\tfunctions\x12A\n" +- "\n" +- "procedures\x18\x06 \x03(\v2!.bytebase.store.ProcedureMetadataR\n" +- "procedures\x128\n" +- "\astreams\x18\a \x03(\v2\x1e.bytebase.store.StreamMetadataR\astreams\x122\n" +- "\x05tasks\x18\b \x03(\v2\x1c.bytebase.store.TaskMetadataR\x05tasks\x12W\n" +- "\x12materialized_views\x18\t \x03(\v2(.bytebase.store.MaterializedViewMetadataR\x11materializedViews\x12>\n" +- "\tsequences\x18\n" +- " \x03(\v2 .bytebase.store.SequenceMetadataR\tsequences\x12;\n" +- "\bpackages\x18\v \x03(\v2\x1f.bytebase.store.PackageMetadataR\bpackages\x12\x14\n" +- "\x05owner\x18\f \x01(\tR\x05owner\x12\x18\n" +- "\acomment\x18\r \x01(\tR\acomment\x125\n" +- "\x06events\x18\x0e \x03(\v2\x1d.bytebase.store.EventMetadataR\x06events\x12?\n" +- "\n" +- "enum_types\x18\x0f \x03(\v2 .bytebase.store.EnumTypeMetadataR\tenumTypes\x12\x1b\n" +- "\tskip_dump\x18\x10 \x01(\bR\bskipDump\x12N\n" +- "\x0fcomposite_types\x18\x11 \x03(\v2%.bytebase.store.CompositeTypeMetadataR\x0ecompositeTypes\"u\n" +- "\x10EnumTypeMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" +- "\x06values\x18\x02 \x03(\tR\x06values\x12\x18\n" +- "\acomment\x18\x03 \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\x04 \x01(\bR\bskipDump\"\xaa\x01\n" +- "\x15CompositeTypeMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12F\n" +- "\n" +- "attributes\x18\x02 \x03(\v2&.bytebase.store.CompositeTypeAttributeR\n" +- "attributes\x12\x18\n" +- "\acomment\x18\x03 \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\x04 \x01(\bR\bskipDump\"x\n" +- "\x16CompositeTypeAttribute\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" +- "\x04type\x18\x02 \x01(\tR\x04type\x12\x1c\n" +- "\tcollation\x18\x03 \x01(\tR\tcollation\x12\x18\n" +- "\acomment\x18\x04 \x01(\tR\acomment\"\xfa\x01\n" +- "\rEventMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\x12\x1b\n" +- "\ttime_zone\x18\x03 \x01(\tR\btimeZone\x12\x19\n" +- "\bsql_mode\x18\x04 \x01(\tR\asqlMode\x120\n" +- "\x14character_set_client\x18\x05 \x01(\tR\x12characterSetClient\x121\n" +- "\x14collation_connection\x18\x06 \x01(\tR\x13collationConnection\x12\x18\n" +- "\acomment\x18\a \x01(\tR\acomment\"\x80\x03\n" +- "\x10SequenceMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1b\n" +- "\tdata_type\x18\x02 \x01(\tR\bdataType\x12\x14\n" +- "\x05start\x18\x03 \x01(\tR\x05start\x12\x1b\n" +- "\tmin_value\x18\x04 \x01(\tR\bminValue\x12\x1b\n" +- "\tmax_value\x18\x05 \x01(\tR\bmaxValue\x12\x1c\n" +- "\tincrement\x18\x06 \x01(\tR\tincrement\x12\x14\n" +- "\x05cycle\x18\a \x01(\bR\x05cycle\x12\x1d\n" +- "\n" +- "cache_size\x18\b \x01(\tR\tcacheSize\x12\x1d\n" +- "\n" +- "last_value\x18\t \x01(\tR\tlastValue\x12\x1f\n" +- "\vowner_table\x18\n" +- " \x01(\tR\n" +- "ownerTable\x12!\n" +- "\fowner_column\x18\v \x01(\tR\vownerColumn\x12\x18\n" +- "\acomment\x18\f \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\r \x01(\bR\bskipDump\"\xa4\x02\n" +- "\x0fTriggerMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +- "\x05event\x18\x03 \x01(\tR\x05event\x12\x16\n" +- "\x06timing\x18\x04 \x01(\tR\x06timing\x12\x12\n" +- "\x04body\x18\x05 \x01(\tR\x04body\x12\x19\n" +- "\bsql_mode\x18\x06 \x01(\tR\asqlMode\x120\n" +- "\x14character_set_client\x18\a \x01(\tR\x12characterSetClient\x121\n" +- "\x14collation_connection\x18\b \x01(\tR\x13collationConnection\x12\x18\n" +- "\acomment\x18\t \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\n" +- " \x01(\bR\bskipDumpJ\x04\b\x02\x10\x03\"\xcc\x01\n" +- "\fRuleMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +- "\x05event\x18\x02 \x01(\tR\x05event\x12\x1c\n" +- "\tcondition\x18\x03 \x01(\tR\tcondition\x12\x16\n" +- "\x06action\x18\x04 \x01(\tR\x06action\x12\x1d\n" +- "\n" +- "is_instead\x18\x05 \x01(\bR\tisInstead\x12\x1d\n" +- "\n" +- "is_enabled\x18\x06 \x01(\bR\tisEnabled\x12\x1e\n" +- "\n" +- "definition\x18\a \x01(\tR\n" +- "definition\"\x80\x03\n" +- "\fTaskMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x0e\n" +- "\x02id\x18\x02 \x01(\tR\x02id\x12\x14\n" +- "\x05owner\x18\x03 \x01(\tR\x05owner\x12\x18\n" +- "\acomment\x18\x04 \x01(\tR\acomment\x12\x1c\n" +- "\twarehouse\x18\x05 \x01(\tR\twarehouse\x12\x1a\n" +- "\bschedule\x18\x06 \x01(\tR\bschedule\x12\"\n" +- "\fpredecessors\x18\a \x03(\tR\fpredecessors\x128\n" +- "\x05state\x18\b \x01(\x0e2\".bytebase.store.TaskMetadata.StateR\x05state\x12\x1c\n" +- "\tcondition\x18\t \x01(\tR\tcondition\x12\x1e\n" +- "\n" +- "definition\x18\n" +- " \x01(\tR\n" +- "definition\"F\n" +- "\x05State\x12\x15\n" +- "\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n" +- "\rSTATE_STARTED\x10\x01\x12\x13\n" +- "\x0fSTATE_SUSPENDED\x10\x02\"\xa5\x03\n" +- "\x0eStreamMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" +- "\n" +- "table_name\x18\x02 \x01(\tR\ttableName\x12\x14\n" +- "\x05owner\x18\x03 \x01(\tR\x05owner\x12\x18\n" +- "\acomment\x18\x04 \x01(\tR\acomment\x127\n" +- "\x04type\x18\x05 \x01(\x0e2#.bytebase.store.StreamMetadata.TypeR\x04type\x12\x14\n" +- "\x05stale\x18\x06 \x01(\bR\x05stale\x127\n" +- "\x04mode\x18\a \x01(\x0e2#.bytebase.store.StreamMetadata.ModeR\x04mode\x12\x1e\n" +- "\n" +- "definition\x18\b \x01(\tR\n" +- "definition\",\n" +- "\x04Type\x12\x14\n" +- "\x10TYPE_UNSPECIFIED\x10\x00\x12\x0e\n" +- "\n" +- "TYPE_DELTA\x10\x01\"Z\n" +- "\x04Mode\x12\x14\n" +- "\x10MODE_UNSPECIFIED\x10\x00\x12\x10\n" +- "\fMODE_DEFAULT\x10\x01\x12\x14\n" +- "\x10MODE_APPEND_ONLY\x10\x02\x12\x14\n" +- "\x10MODE_INSERT_ONLY\x10\x03\"\xfa\a\n" +- "\rTableMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x128\n" +- "\acolumns\x18\x02 \x03(\v2\x1e.bytebase.store.ColumnMetadataR\acolumns\x127\n" +- "\aindexes\x18\x03 \x03(\v2\x1d.bytebase.store.IndexMetadataR\aindexes\x12\x16\n" +- "\x06engine\x18\x04 \x01(\tR\x06engine\x12\x1c\n" +- "\tcollation\x18\x05 \x01(\tR\tcollation\x12\x18\n" +- "\acharset\x18\x11 \x01(\tR\acharset\x12\x1b\n" +- "\trow_count\x18\x06 \x01(\x03R\browCount\x12\x1b\n" +- "\tdata_size\x18\a \x01(\x03R\bdataSize\x12\x1d\n" +- "\n" +- "index_size\x18\b \x01(\x03R\tindexSize\x12\x1b\n" +- "\tdata_free\x18\t \x01(\x03R\bdataFree\x12%\n" +- "\x0ecreate_options\x18\n" +- " \x01(\tR\rcreateOptions\x12\x18\n" +- "\acomment\x18\v \x01(\tR\acomment\x12E\n" +- "\fforeign_keys\x18\f \x03(\v2\".bytebase.store.ForeignKeyMetadataR\vforeignKeys\x12F\n" +- "\n" +- "partitions\x18\x0f \x03(\v2&.bytebase.store.TablePartitionMetadataR\n" +- "partitions\x12T\n" +- "\x11check_constraints\x18\x10 \x03(\v2'.bytebase.store.CheckConstraintMetadataR\x10checkConstraints\x12\x14\n" +- "\x05owner\x18\x12 \x01(\tR\x05owner\x12!\n" +- "\fsorting_keys\x18\x13 \x03(\tR\vsortingKeys\x12;\n" +- "\btriggers\x18\x14 \x03(\v2\x1f.bytebase.store.TriggerMetadataR\btriggers\x12\x1b\n" +- "\tskip_dump\x18\x15 \x01(\bR\bskipDump\x122\n" +- "\x05rules\x18\x18 \x03(\v2\x1c.bytebase.store.RuleMetadataR\x05rules\x12#\n" +- "\rsharding_info\x18\x16 \x01(\tR\fshardingInfo\x12(\n" +- "\x10primary_key_type\x18\x17 \x01(\tR\x0eprimaryKeyType\x12Z\n" +- "\x13exclude_constraints\x18\x19 \x03(\v2).bytebase.store.ExcludeConstraintMetadataR\x12excludeConstraintsJ\x04\b\r\x10\x0f\"M\n" +- "\x17CheckConstraintMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "expression\x18\x02 \x01(\tR\n" +- "expression\"O\n" +- "\x19ExcludeConstraintMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "expression\x18\x02 \x01(\tR\n" +- "expression\"\xcd\x01\n" +- "\x15ExternalTableMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x120\n" +- "\x14external_server_name\x18\x02 \x01(\tR\x12externalServerName\x124\n" +- "\x16external_database_name\x18\x03 \x01(\tR\x14externalDatabaseName\x128\n" +- "\acolumns\x18\x04 \x03(\v2\x1e.bytebase.store.ColumnMetadataR\acolumns\"\x8a\x05\n" +- "\x16TablePartitionMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12?\n" +- "\x04type\x18\x02 \x01(\x0e2+.bytebase.store.TablePartitionMetadata.TypeR\x04type\x12\x1e\n" +- "\n" +- "expression\x18\x03 \x01(\tR\n" +- "expression\x12\x14\n" +- "\x05value\x18\x04 \x01(\tR\x05value\x12\x1f\n" +- "\vuse_default\x18\x05 \x01(\tR\n" +- "useDefault\x12L\n" +- "\rsubpartitions\x18\x06 \x03(\v2&.bytebase.store.TablePartitionMetadataR\rsubpartitions\x127\n" +- "\aindexes\x18\a \x03(\v2\x1d.bytebase.store.IndexMetadataR\aindexes\x12T\n" +- "\x11check_constraints\x18\b \x03(\v2'.bytebase.store.CheckConstraintMetadataR\x10checkConstraints\x12Z\n" +- "\x13exclude_constraints\x18\t \x03(\v2).bytebase.store.ExcludeConstraintMetadataR\x12excludeConstraints\"\x8a\x01\n" +- "\x04Type\x12\x14\n" +- "\x10TYPE_UNSPECIFIED\x10\x00\x12\t\n" +- "\x05RANGE\x10\x01\x12\x11\n" +- "\rRANGE_COLUMNS\x10\x02\x12\b\n" +- "\x04LIST\x10\x03\x12\x10\n" +- "\fLIST_COLUMNS\x10\x04\x12\b\n" +- "\x04HASH\x10\x05\x12\x0f\n" +- "\vLINEAR_HASH\x10\x06\x12\a\n" +- "\x03KEY\x10\a\x12\x0e\n" +- "\n" +- "LINEAR_KEY\x10\b\"\xa9\x06\n" +- "\x0eColumnMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +- "\bposition\x18\x02 \x01(\x05R\bposition\x12\x18\n" +- "\adefault\x18\x03 \x01(\tR\adefault\x12&\n" +- "\x0fdefault_on_null\x18\x10 \x01(\bR\rdefaultOnNull\x12\x1b\n" +- "\ton_update\x18\r \x01(\tR\bonUpdate\x12\x1a\n" +- "\bnullable\x18\x06 \x01(\bR\bnullable\x12\x12\n" +- "\x04type\x18\a \x01(\tR\x04type\x12#\n" +- "\rcharacter_set\x18\b \x01(\tR\fcharacterSet\x12\x1c\n" +- "\tcollation\x18\t \x01(\tR\tcollation\x12\x18\n" +- "\acomment\x18\n" +- " \x01(\tR\acomment\x12B\n" +- "\n" +- "generation\x18\x0e \x01(\v2\".bytebase.store.GenerationMetadataR\n" +- "generation\x12\x1f\n" +- "\vis_identity\x18\x11 \x01(\bR\n" +- "isIdentity\x12b\n" +- "\x13identity_generation\x18\x0f \x01(\x0e21.bytebase.store.ColumnMetadata.IdentityGenerationR\x12identityGeneration\x12#\n" +- "\ridentity_seed\x18\x12 \x01(\x03R\fidentitySeed\x12-\n" +- "\x12identity_increment\x18\x13 \x01(\x03R\x11identityIncrement\x126\n" +- "\x17default_constraint_name\x18\x14 \x01(\tR\x15defaultConstraintName\x12\x17\n" +- "\x04srid\x18\x15 \x01(\rH\x00R\x04srid\x88\x01\x01\x12!\n" +- "\fis_invisible\x18\x16 \x01(\bR\visInvisible\"U\n" +- "\x12IdentityGeneration\x12#\n" +- "\x1fIDENTITY_GENERATION_UNSPECIFIED\x10\x00\x12\n" +- "\n" +- "\x06ALWAYS\x10\x01\x12\x0e\n" +- "\n" +- "BY_DEFAULT\x10\x02B\a\n" +- "\x05_sridJ\x04\b\x04\x10\x06J\x04\b\v\x10\r\"\xb2\x01\n" +- "\x12GenerationMetadata\x12;\n" +- "\x04type\x18\x01 \x01(\x0e2'.bytebase.store.GenerationMetadata.TypeR\x04type\x12\x1e\n" +- "\n" +- "expression\x18\x02 \x01(\tR\n" +- "expression\"?\n" +- "\x04Type\x12\x14\n" +- "\x10TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +- "\fTYPE_VIRTUAL\x10\x01\x12\x0f\n" +- "\vTYPE_STORED\x10\x02\"\xf5\x02\n" +- "\fViewMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\x12\x18\n" +- "\acomment\x18\x03 \x01(\tR\acomment\x12O\n" +- "\x12dependency_columns\x18\x04 \x03(\v2 .bytebase.store.DependencyColumnR\x11dependencyColumns\x128\n" +- "\acolumns\x18\x05 \x03(\v2\x1e.bytebase.store.ColumnMetadataR\acolumns\x12;\n" +- "\btriggers\x18\x06 \x03(\v2\x1f.bytebase.store.TriggerMetadataR\btriggers\x12\x1b\n" +- "\tskip_dump\x18\a \x01(\bR\bskipDump\x122\n" +- "\x05rules\x18\b \x03(\v2\x1c.bytebase.store.RuleMetadataR\x05rules\"X\n" +- "\x10DependencyColumn\x12\x16\n" +- "\x06schema\x18\x01 \x01(\tR\x06schema\x12\x14\n" +- "\x05table\x18\x02 \x01(\tR\x05table\x12\x16\n" +- "\x06column\x18\x03 \x01(\tR\x06column\"\xcc\x02\n" +- "\x18MaterializedViewMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\x12\x18\n" +- "\acomment\x18\x03 \x01(\tR\acomment\x12O\n" +- "\x12dependency_columns\x18\x04 \x03(\v2 .bytebase.store.DependencyColumnR\x11dependencyColumns\x12;\n" +- "\btriggers\x18\x05 \x03(\v2\x1f.bytebase.store.TriggerMetadataR\btriggers\x127\n" +- "\aindexes\x18\x06 \x03(\v2\x1d.bytebase.store.IndexMetadataR\aindexes\x12\x1b\n" +- "\tskip_dump\x18\a \x01(\bR\bskipDump\"?\n" +- "\x0fDependencyTable\x12\x16\n" +- "\x06schema\x18\x01 \x01(\tR\x06schema\x12\x14\n" +- "\x05table\x18\x02 \x01(\tR\x05table\"\x98\x03\n" +- "\x10FunctionMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\x12\x1c\n" +- "\tsignature\x18\x03 \x01(\tR\tsignature\x120\n" +- "\x14character_set_client\x18\x04 \x01(\tR\x12characterSetClient\x121\n" +- "\x14collation_connection\x18\x05 \x01(\tR\x13collationConnection\x12-\n" +- "\x12database_collation\x18\x06 \x01(\tR\x11databaseCollation\x12\x19\n" +- "\bsql_mode\x18\a \x01(\tR\asqlMode\x12\x18\n" +- "\acomment\x18\b \x01(\tR\acomment\x12L\n" +- "\x11dependency_tables\x18\t \x03(\v2\x1f.bytebase.store.DependencyTableR\x10dependencyTables\x12\x1b\n" +- "\tskip_dump\x18\n" +- " \x01(\bR\bskipDump\"\xcb\x02\n" +- "\x11ProcedureMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\x12\x1c\n" +- "\tsignature\x18\x03 \x01(\tR\tsignature\x120\n" +- "\x14character_set_client\x18\x04 \x01(\tR\x12characterSetClient\x121\n" +- "\x14collation_connection\x18\x05 \x01(\tR\x13collationConnection\x12-\n" +- "\x12database_collation\x18\x06 \x01(\tR\x11databaseCollation\x12\x19\n" +- "\bsql_mode\x18\a \x01(\tR\asqlMode\x12\x18\n" +- "\acomment\x18\t \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\b \x01(\bR\bskipDump\"E\n" +- "\x0fPackageMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x1e\n" +- "\n" +- "definition\x18\x02 \x01(\tR\n" +- "definition\"\xdc\x04\n" +- "\rIndexMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12 \n" +- "\vexpressions\x18\x02 \x03(\tR\vexpressions\x12\x1d\n" +- "\n" +- "key_length\x18\t \x03(\x03R\tkeyLength\x12\x1e\n" +- "\n" +- "descending\x18\n" +- " \x03(\bR\n" +- "descending\x12\x12\n" +- "\x04type\x18\x03 \x01(\tR\x04type\x12\x16\n" +- "\x06unique\x18\x04 \x01(\bR\x06unique\x12\x18\n" +- "\aprimary\x18\x05 \x01(\bR\aprimary\x12\x18\n" +- "\avisible\x18\x06 \x01(\bR\avisible\x12\x18\n" +- "\acomment\x18\a \x01(\tR\acomment\x12\x1e\n" +- "\n" +- "definition\x18\b \x01(\tR\n" +- "definition\x12.\n" +- "\x13parent_index_schema\x18\v \x01(\tR\x11parentIndexSchema\x12*\n" +- "\x11parent_index_name\x18\f \x01(\tR\x0fparentIndexName\x12 \n" +- "\vgranularity\x18\r \x01(\x03R\vgranularity\x12#\n" +- "\ris_constraint\x18\x0e \x01(\bR\fisConstraint\x12I\n" +- "\x0espatial_config\x18\x0f \x01(\v2\".bytebase.store.SpatialIndexConfigR\rspatialConfig\x12#\n" +- "\ropclass_names\x18\x10 \x03(\tR\fopclassNames\x12)\n" +- "\x10opclass_defaults\x18\x11 \x03(\bR\x0fopclassDefaults\"\x96\x03\n" +- "\x12SpatialIndexConfig\x12\x16\n" +- "\x06method\x18\x01 \x01(\tR\x06method\x12F\n" +- "\ftessellation\x18\x02 \x01(\v2\".bytebase.store.TessellationConfigR\ftessellation\x127\n" +- "\astorage\x18\x03 \x01(\v2\x1d.bytebase.store.StorageConfigR\astorage\x12C\n" +- "\vdimensional\x18\x04 \x01(\v2!.bytebase.store.DimensionalConfigR\vdimensional\x12_\n" +- "\x0fengine_specific\x18\x05 \x03(\v26.bytebase.store.SpatialIndexConfig.EngineSpecificEntryR\x0eengineSpecific\x1aA\n" +- "\x13EngineSpecificEntry\x12\x10\n" +- "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd2\x01\n" +- "\x12TessellationConfig\x12\x16\n" +- "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12>\n" +- "\fbounding_box\x18\x02 \x01(\v2\x1b.bytebase.store.BoundingBoxR\vboundingBox\x12:\n" +- "\vgrid_levels\x18\x03 \x03(\v2\x19.bytebase.store.GridLevelR\n" +- "gridLevels\x12(\n" +- "\x10cells_per_object\x18\x04 \x01(\x05R\x0ecellsPerObject\"]\n" +- "\vBoundingBox\x12\x12\n" +- "\x04xmin\x18\x01 \x01(\x01R\x04xmin\x12\x12\n" +- "\x04ymin\x18\x02 \x01(\x01R\x04ymin\x12\x12\n" +- "\x04xmax\x18\x03 \x01(\x01R\x04xmax\x12\x12\n" +- "\x04ymax\x18\x04 \x01(\x01R\x04ymax\";\n" +- "\tGridLevel\x12\x14\n" +- "\x05level\x18\x01 \x01(\x05R\x05level\x12\x18\n" +- "\adensity\x18\x02 \x01(\tR\adensity\"\xf1\x03\n" +- "\rStorageConfig\x12\x1e\n" +- "\n" +- "fillfactor\x18\x01 \x01(\x05R\n" +- "fillfactor\x12\x1c\n" +- "\tbuffering\x18\x02 \x01(\tR\tbuffering\x12\x1e\n" +- "\n" +- "tablespace\x18\x03 \x01(\tR\n" +- "tablespace\x12'\n" +- "\x0fwork_tablespace\x18\x04 \x01(\tR\x0eworkTablespace\x12\x1b\n" +- "\tsdo_level\x18\x05 \x01(\x05R\bsdoLevel\x12'\n" +- "\x0fcommit_interval\x18\x06 \x01(\x05R\x0ecommitInterval\x12\x1b\n" +- "\tpad_index\x18\a \x01(\bR\bpadIndex\x12$\n" +- "\x0esort_in_tempdb\x18\b \x01(\tR\fsortInTempdb\x12#\n" +- "\rdrop_existing\x18\t \x01(\bR\fdropExisting\x12\x16\n" +- "\x06online\x18\n" +- " \x01(\bR\x06online\x12&\n" +- "\x0fallow_row_locks\x18\v \x01(\bR\rallowRowLocks\x12(\n" +- "\x10allow_page_locks\x18\f \x01(\bR\x0eallowPageLocks\x12\x16\n" +- "\x06maxdop\x18\r \x01(\x05R\x06maxdop\x12)\n" +- "\x10data_compression\x18\x0e \x01(\tR\x0fdataCompression\"\xbf\x01\n" +- "\x11DimensionalConfig\x12\x1e\n" +- "\n" +- "dimensions\x18\x01 \x01(\x05R\n" +- "dimensions\x12\x1b\n" +- "\tdata_type\x18\x02 \x01(\tR\bdataType\x12%\n" +- "\x0eoperator_class\x18\x03 \x01(\tR\roperatorClass\x12\x1f\n" +- "\vlayer_gtype\x18\x04 \x01(\tR\n" +- "layerGtype\x12%\n" +- "\x0eparallel_build\x18\x05 \x01(\bR\rparallelBuild\"{\n" +- "\x11ExtensionMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" +- "\x06schema\x18\x02 \x01(\tR\x06schema\x12\x18\n" +- "\aversion\x18\x03 \x01(\tR\aversion\x12 \n" +- "\vdescription\x18\x04 \x01(\tR\vdescription\"\x93\x02\n" +- "\x14EventTriggerMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +- "\x05event\x18\x02 \x01(\tR\x05event\x12\x12\n" +- "\x04tags\x18\x03 \x03(\tR\x04tags\x12'\n" +- "\x0ffunction_schema\x18\x04 \x01(\tR\x0efunctionSchema\x12#\n" +- "\rfunction_name\x18\x05 \x01(\tR\ffunctionName\x12\x18\n" +- "\aenabled\x18\x06 \x01(\bR\aenabled\x12\x1e\n" +- "\n" +- "definition\x18\a \x01(\tR\n" +- "definition\x12\x18\n" +- "\acomment\x18\b \x01(\tR\acomment\x12\x1b\n" +- "\tskip_dump\x18\t \x01(\bR\bskipDump\"\xa2\x02\n" +- "\x12ForeignKeyMetadata\x12\x12\n" +- "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" +- "\acolumns\x18\x02 \x03(\tR\acolumns\x12+\n" +- "\x11referenced_schema\x18\x03 \x01(\tR\x10referencedSchema\x12)\n" +- "\x10referenced_table\x18\x04 \x01(\tR\x0freferencedTable\x12-\n" +- "\x12referenced_columns\x18\x05 \x03(\tR\x11referencedColumns\x12\x1b\n" +- "\ton_delete\x18\x06 \x01(\tR\bonDelete\x12\x1b\n" +- "\ton_update\x18\a \x01(\tR\bonUpdate\x12\x1d\n" +- "\n" +- "match_type\x18\b \x01(\tR\tmatchType\"L\n" ++ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\a\x10\b\"L\n" +"\x14InstanceRoleMetadata\x12\x12\n" +"\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" +"\x05grant\x18\a \x01(\tR\x05grantJ\x04\b\x01\x10\x02J\x04\b\x03\x10\a\"c\n" +@@ -5321,142 +816,46 @@ func file_store_database_proto_rawDescGZIP() []byte {return file_store_database_proto_rawDescData}-var file_store_database_proto_enumTypes = make([]protoimpl.EnumInfo, 8)-var file_store_database_proto_msgTypes = make([]protoimpl.MessageInfo, 49)+var file_store_database_proto_enumTypes = make([]protoimpl.EnumInfo, 2)+var file_store_database_proto_msgTypes = make([]protoimpl.MessageInfo, 12)var file_store_database_proto_goTypes = []any{- (SyncStatus)(0), // 0: bytebase.store.SyncStatus- (TaskMetadata_State)(0), // 1: bytebase.store.TaskMetadata.State- (StreamMetadata_Type)(0), // 2: bytebase.store.StreamMetadata.Type- (StreamMetadata_Mode)(0), // 3: bytebase.store.StreamMetadata.Mode- (TablePartitionMetadata_Type)(0), // 4: bytebase.store.TablePartitionMetadata.Type- (ColumnMetadata_IdentityGeneration)(0), // 5: bytebase.store.ColumnMetadata.IdentityGeneration- (GenerationMetadata_Type)(0), // 6: bytebase.store.GenerationMetadata.Type- (ObjectSchema_Type)(0), // 7: bytebase.store.ObjectSchema.Type- (*DatabaseMetadata)(nil), // 8: bytebase.store.DatabaseMetadata- (*DatabaseSchemaMetadata)(nil), // 9: bytebase.store.DatabaseSchemaMetadata- (*LinkedDatabaseMetadata)(nil), // 10: bytebase.store.LinkedDatabaseMetadata- (*SchemaMetadata)(nil), // 11: bytebase.store.SchemaMetadata- (*EnumTypeMetadata)(nil), // 12: bytebase.store.EnumTypeMetadata- (*CompositeTypeMetadata)(nil), // 13: bytebase.store.CompositeTypeMetadata- (*CompositeTypeAttribute)(nil), // 14: bytebase.store.CompositeTypeAttribute- (*EventMetadata)(nil), // 15: bytebase.store.EventMetadata- (*SequenceMetadata)(nil), // 16: bytebase.store.SequenceMetadata- (*TriggerMetadata)(nil), // 17: bytebase.store.TriggerMetadata- (*RuleMetadata)(nil), // 18: bytebase.store.RuleMetadata- (*TaskMetadata)(nil), // 19: bytebase.store.TaskMetadata- (*StreamMetadata)(nil), // 20: bytebase.store.StreamMetadata- (*TableMetadata)(nil), // 21: bytebase.store.TableMetadata- (*CheckConstraintMetadata)(nil), // 22: bytebase.store.CheckConstraintMetadata- (*ExcludeConstraintMetadata)(nil), // 23: bytebase.store.ExcludeConstraintMetadata- (*ExternalTableMetadata)(nil), // 24: bytebase.store.ExternalTableMetadata- (*TablePartitionMetadata)(nil), // 25: bytebase.store.TablePartitionMetadata- (*ColumnMetadata)(nil), // 26: bytebase.store.ColumnMetadata- (*GenerationMetadata)(nil), // 27: bytebase.store.GenerationMetadata- (*ViewMetadata)(nil), // 28: bytebase.store.ViewMetadata- (*DependencyColumn)(nil), // 29: bytebase.store.DependencyColumn- (*MaterializedViewMetadata)(nil), // 30: bytebase.store.MaterializedViewMetadata- (*DependencyTable)(nil), // 31: bytebase.store.DependencyTable- (*FunctionMetadata)(nil), // 32: bytebase.store.FunctionMetadata- (*ProcedureMetadata)(nil), // 33: bytebase.store.ProcedureMetadata- (*PackageMetadata)(nil), // 34: bytebase.store.PackageMetadata- (*IndexMetadata)(nil), // 35: bytebase.store.IndexMetadata- (*SpatialIndexConfig)(nil), // 36: bytebase.store.SpatialIndexConfig- (*TessellationConfig)(nil), // 37: bytebase.store.TessellationConfig- (*BoundingBox)(nil), // 38: bytebase.store.BoundingBox- (*GridLevel)(nil), // 39: bytebase.store.GridLevel- (*StorageConfig)(nil), // 40: bytebase.store.StorageConfig- (*DimensionalConfig)(nil), // 41: bytebase.store.DimensionalConfig- (*ExtensionMetadata)(nil), // 42: bytebase.store.ExtensionMetadata- (*EventTriggerMetadata)(nil), // 43: bytebase.store.EventTriggerMetadata- (*ForeignKeyMetadata)(nil), // 44: bytebase.store.ForeignKeyMetadata- (*InstanceRoleMetadata)(nil), // 45: bytebase.store.InstanceRoleMetadata- (*DatabaseConfig)(nil), // 46: bytebase.store.DatabaseConfig- (*SchemaCatalog)(nil), // 47: bytebase.store.SchemaCatalog- (*TableCatalog)(nil), // 48: bytebase.store.TableCatalog- (*ColumnCatalog)(nil), // 49: bytebase.store.ColumnCatalog- (*ObjectSchema)(nil), // 50: bytebase.store.ObjectSchema- nil, // 51: bytebase.store.DatabaseMetadata.LabelsEntry- nil, // 52: bytebase.store.SpatialIndexConfig.EngineSpecificEntry- nil, // 53: bytebase.store.ColumnCatalog.LabelsEntry- (*ObjectSchema_StructKind)(nil), // 54: bytebase.store.ObjectSchema.StructKind- (*ObjectSchema_ArrayKind)(nil), // 55: bytebase.store.ObjectSchema.ArrayKind- nil, // 56: bytebase.store.ObjectSchema.StructKind.PropertiesEntry- (*timestamppb.Timestamp)(nil), // 57: google.protobuf.Timestamp+ (SyncStatus)(0), // 0: bytebase.store.SyncStatus+ (ObjectSchema_Type)(0), // 1: bytebase.store.ObjectSchema.Type+ (*DatabaseMetadata)(nil), // 2: bytebase.store.DatabaseMetadata+ (*InstanceRoleMetadata)(nil), // 3: bytebase.store.InstanceRoleMetadata+ (*DatabaseConfig)(nil), // 4: bytebase.store.DatabaseConfig+ (*SchemaCatalog)(nil), // 5: bytebase.store.SchemaCatalog+ (*TableCatalog)(nil), // 6: bytebase.store.TableCatalog+ (*ColumnCatalog)(nil), // 7: bytebase.store.ColumnCatalog+ (*ObjectSchema)(nil), // 8: bytebase.store.ObjectSchema+ nil, // 9: bytebase.store.DatabaseMetadata.LabelsEntry+ nil, // 10: bytebase.store.ColumnCatalog.LabelsEntry+ (*ObjectSchema_StructKind)(nil), // 11: bytebase.store.ObjectSchema.StructKind+ (*ObjectSchema_ArrayKind)(nil), // 12: bytebase.store.ObjectSchema.ArrayKind+ nil, // 13: bytebase.store.ObjectSchema.StructKind.PropertiesEntry+ (*timestamppb.Timestamp)(nil), // 14: google.protobuf.Timestamp}var file_store_database_proto_depIdxs = []int32{- 51, // 0: bytebase.store.DatabaseMetadata.labels:type_name -> bytebase.store.DatabaseMetadata.LabelsEntry- 57, // 1: bytebase.store.DatabaseMetadata.last_sync_time:type_name -> google.protobuf.Timestamp+ 9, // 0: bytebase.store.DatabaseMetadata.labels:type_name -> bytebase.store.DatabaseMetadata.LabelsEntry+ 14, // 1: bytebase.store.DatabaseMetadata.last_sync_time:type_name -> google.protobuf.Timestamp0, // 2: bytebase.store.DatabaseMetadata.sync_status:type_name -> bytebase.store.SyncStatus- 11, // 3: bytebase.store.DatabaseSchemaMetadata.schemas:type_name -> bytebase.store.SchemaMetadata- 42, // 4: bytebase.store.DatabaseSchemaMetadata.extensions:type_name -> bytebase.store.ExtensionMetadata- 10, // 5: bytebase.store.DatabaseSchemaMetadata.linked_databases:type_name -> bytebase.store.LinkedDatabaseMetadata- 43, // 6: bytebase.store.DatabaseSchemaMetadata.event_triggers:type_name -> bytebase.store.EventTriggerMetadata- 21, // 7: bytebase.store.SchemaMetadata.tables:type_name -> bytebase.store.TableMetadata- 24, // 8: bytebase.store.SchemaMetadata.external_tables:type_name -> bytebase.store.ExternalTableMetadata- 28, // 9: bytebase.store.SchemaMetadata.views:type_name -> bytebase.store.ViewMetadata- 32, // 10: bytebase.store.SchemaMetadata.functions:type_name -> bytebase.store.FunctionMetadata- 33, // 11: bytebase.store.SchemaMetadata.procedures:type_name -> bytebase.store.ProcedureMetadata- 20, // 12: bytebase.store.SchemaMetadata.streams:type_name -> bytebase.store.StreamMetadata- 19, // 13: bytebase.store.SchemaMetadata.tasks:type_name -> bytebase.store.TaskMetadata- 30, // 14: bytebase.store.SchemaMetadata.materialized_views:type_name -> bytebase.store.MaterializedViewMetadata- 16, // 15: bytebase.store.SchemaMetadata.sequences:type_name -> bytebase.store.SequenceMetadata- 34, // 16: bytebase.store.SchemaMetadata.packages:type_name -> bytebase.store.PackageMetadata- 15, // 17: bytebase.store.SchemaMetadata.events:type_name -> bytebase.store.EventMetadata- 12, // 18: bytebase.store.SchemaMetadata.enum_types:type_name -> bytebase.store.EnumTypeMetadata- 13, // 19: bytebase.store.SchemaMetadata.composite_types:type_name -> bytebase.store.CompositeTypeMetadata- 14, // 20: bytebase.store.CompositeTypeMetadata.attributes:type_name -> bytebase.store.CompositeTypeAttribute- 1, // 21: bytebase.store.TaskMetadata.state:type_name -> bytebase.store.TaskMetadata.State- 2, // 22: bytebase.store.StreamMetadata.type:type_name -> bytebase.store.StreamMetadata.Type- 3, // 23: bytebase.store.StreamMetadata.mode:type_name -> bytebase.store.StreamMetadata.Mode- 26, // 24: bytebase.store.TableMetadata.columns:type_name -> bytebase.store.ColumnMetadata- 35, // 25: bytebase.store.TableMetadata.indexes:type_name -> bytebase.store.IndexMetadata- 44, // 26: bytebase.store.TableMetadata.foreign_keys:type_name -> bytebase.store.ForeignKeyMetadata- 25, // 27: bytebase.store.TableMetadata.partitions:type_name -> bytebase.store.TablePartitionMetadata- 22, // 28: bytebase.store.TableMetadata.check_constraints:type_name -> bytebase.store.CheckConstraintMetadata- 17, // 29: bytebase.store.TableMetadata.triggers:type_name -> bytebase.store.TriggerMetadata- 18, // 30: bytebase.store.TableMetadata.rules:type_name -> bytebase.store.RuleMetadata- 23, // 31: bytebase.store.TableMetadata.exclude_constraints:type_name -> bytebase.store.ExcludeConstraintMetadata- 26, // 32: bytebase.store.ExternalTableMetadata.columns:type_name -> bytebase.store.ColumnMetadata- 4, // 33: bytebase.store.TablePartitionMetadata.type:type_name -> bytebase.store.TablePartitionMetadata.Type- 25, // 34: bytebase.store.TablePartitionMetadata.subpartitions:type_name -> bytebase.store.TablePartitionMetadata- 35, // 35: bytebase.store.TablePartitionMetadata.indexes:type_name -> bytebase.store.IndexMetadata- 22, // 36: bytebase.store.TablePartitionMetadata.check_constraints:type_name -> bytebase.store.CheckConstraintMetadata- 23, // 37: bytebase.store.TablePartitionMetadata.exclude_constraints:type_name -> bytebase.store.ExcludeConstraintMetadata- 27, // 38: bytebase.store.ColumnMetadata.generation:type_name -> bytebase.store.GenerationMetadata- 5, // 39: bytebase.store.ColumnMetadata.identity_generation:type_name -> bytebase.store.ColumnMetadata.IdentityGeneration- 6, // 40: bytebase.store.GenerationMetadata.type:type_name -> bytebase.store.GenerationMetadata.Type- 29, // 41: bytebase.store.ViewMetadata.dependency_columns:type_name -> bytebase.store.DependencyColumn- 26, // 42: bytebase.store.ViewMetadata.columns:type_name -> bytebase.store.ColumnMetadata- 17, // 43: bytebase.store.ViewMetadata.triggers:type_name -> bytebase.store.TriggerMetadata- 18, // 44: bytebase.store.ViewMetadata.rules:type_name -> bytebase.store.RuleMetadata- 29, // 45: bytebase.store.MaterializedViewMetadata.dependency_columns:type_name -> bytebase.store.DependencyColumn- 17, // 46: bytebase.store.MaterializedViewMetadata.triggers:type_name -> bytebase.store.TriggerMetadata- 35, // 47: bytebase.store.MaterializedViewMetadata.indexes:type_name -> bytebase.store.IndexMetadata- 31, // 48: bytebase.store.FunctionMetadata.dependency_tables:type_name -> bytebase.store.DependencyTable- 36, // 49: bytebase.store.IndexMetadata.spatial_config:type_name -> bytebase.store.SpatialIndexConfig- 37, // 50: bytebase.store.SpatialIndexConfig.tessellation:type_name -> bytebase.store.TessellationConfig- 40, // 51: bytebase.store.SpatialIndexConfig.storage:type_name -> bytebase.store.StorageConfig- 41, // 52: bytebase.store.SpatialIndexConfig.dimensional:type_name -> bytebase.store.DimensionalConfig- 52, // 53: bytebase.store.SpatialIndexConfig.engine_specific:type_name -> bytebase.store.SpatialIndexConfig.EngineSpecificEntry- 38, // 54: bytebase.store.TessellationConfig.bounding_box:type_name -> bytebase.store.BoundingBox- 39, // 55: bytebase.store.TessellationConfig.grid_levels:type_name -> bytebase.store.GridLevel- 47, // 56: bytebase.store.DatabaseConfig.schemas:type_name -> bytebase.store.SchemaCatalog- 48, // 57: bytebase.store.SchemaCatalog.tables:type_name -> bytebase.store.TableCatalog- 49, // 58: bytebase.store.TableCatalog.columns:type_name -> bytebase.store.ColumnCatalog- 50, // 59: bytebase.store.TableCatalog.object_schema:type_name -> bytebase.store.ObjectSchema- 53, // 60: bytebase.store.ColumnCatalog.labels:type_name -> bytebase.store.ColumnCatalog.LabelsEntry- 50, // 61: bytebase.store.ColumnCatalog.object_schema:type_name -> bytebase.store.ObjectSchema- 7, // 62: bytebase.store.ObjectSchema.type:type_name -> bytebase.store.ObjectSchema.Type- 54, // 63: bytebase.store.ObjectSchema.struct_kind:type_name -> bytebase.store.ObjectSchema.StructKind- 55, // 64: bytebase.store.ObjectSchema.array_kind:type_name -> bytebase.store.ObjectSchema.ArrayKind- 56, // 65: bytebase.store.ObjectSchema.StructKind.properties:type_name -> bytebase.store.ObjectSchema.StructKind.PropertiesEntry- 50, // 66: bytebase.store.ObjectSchema.ArrayKind.kind:type_name -> bytebase.store.ObjectSchema- 50, // 67: bytebase.store.ObjectSchema.StructKind.PropertiesEntry.value:type_name -> bytebase.store.ObjectSchema- 68, // [68:68] is the sub-list for method output_type- 68, // [68:68] is the sub-list for method input_type- 68, // [68:68] is the sub-list for extension type_name- 68, // [68:68] is the sub-list for extension extendee- 0, // [0:68] is the sub-list for field type_name+ 5, // 3: bytebase.store.DatabaseConfig.schemas:type_name -> bytebase.store.SchemaCatalog+ 6, // 4: bytebase.store.SchemaCatalog.tables:type_name -> bytebase.store.TableCatalog+ 7, // 5: bytebase.store.TableCatalog.columns:type_name -> bytebase.store.ColumnCatalog+ 8, // 6: bytebase.store.TableCatalog.object_schema:type_name -> bytebase.store.ObjectSchema+ 10, // 7: bytebase.store.ColumnCatalog.labels:type_name -> bytebase.store.ColumnCatalog.LabelsEntry+ 8, // 8: bytebase.store.ColumnCatalog.object_schema:type_name -> bytebase.store.ObjectSchema+ 1, // 9: bytebase.store.ObjectSchema.type:type_name -> bytebase.store.ObjectSchema.Type+ 11, // 10: bytebase.store.ObjectSchema.struct_kind:type_name -> bytebase.store.ObjectSchema.StructKind+ 12, // 11: bytebase.store.ObjectSchema.array_kind:type_name -> bytebase.store.ObjectSchema.ArrayKind+ 13, // 12: bytebase.store.ObjectSchema.StructKind.properties:type_name -> bytebase.store.ObjectSchema.StructKind.PropertiesEntry+ 8, // 13: bytebase.store.ObjectSchema.ArrayKind.kind:type_name -> bytebase.store.ObjectSchema+ 8, // 14: bytebase.store.ObjectSchema.StructKind.PropertiesEntry.value:type_name -> bytebase.store.ObjectSchema+ 15, // [15:15] is the sub-list for method output_type+ 15, // [15:15] is the sub-list for method input_type+ 15, // [15:15] is the sub-list for extension type_name+ 15, // [15:15] is the sub-list for extension extendee+ 0, // [0:15] is the sub-list for field type_name}func init() { file_store_database_proto_init() }@@ -5464,10 +863,9 @@ func file_store_database_proto_init() {if File_store_database_proto != nil {return}- file_store_database_proto_msgTypes[18].OneofWrappers = []any{}- file_store_database_proto_msgTypes[40].OneofWrappers = []any{}- file_store_database_proto_msgTypes[41].OneofWrappers = []any{}- file_store_database_proto_msgTypes[42].OneofWrappers = []any{+ file_store_database_proto_msgTypes[4].OneofWrappers = []any{}+ file_store_database_proto_msgTypes[5].OneofWrappers = []any{}+ file_store_database_proto_msgTypes[6].OneofWrappers = []any{(*ObjectSchema_StructKind_)(nil),(*ObjectSchema_ArrayKind_)(nil),}@@ -5476,8 +874,8 @@ func file_store_database_proto_init() {File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_database_proto_rawDesc), len(file_store_database_proto_rawDesc)),- NumEnums: 8,- NumMessages: 49,+ NumEnums: 2,+ NumMessages: 12,NumExtensions: 0,NumServices: 0,},diff --git a/backend/generated-go/store/database_equal.pb.go b/backend/generated-go/store/database_equal.pb.goindex 61c18ff1e8..0fe1825856 100644--- a/backend/generated-go/store/database_equal.pb.go+++ b/backend/generated-go/store/database_equal.pb.go@@ -3,10 +3,6 @@package store-import (- math "math"-)-func (x *DatabaseMetadata) Equal(y *DatabaseMetadata) bool {if x == y {return true@@ -47,1440 +43,6 @@ func (x *DatabaseMetadata) Equal(y *DatabaseMetadata) bool {return true}-func (x *DatabaseSchemaMetadata) Equal(y *DatabaseSchemaMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Schemas) != len(y.Schemas) {- return false- }- for i := 0; i < len(x.Schemas); i++ {- if !x.Schemas[i].Equal(y.Schemas[i]) {- return false- }- }- if x.CharacterSet != y.CharacterSet {- return false- }- if x.Collation != y.Collation {- return false- }- if len(x.Extensions) != len(y.Extensions) {- return false- }- for i := 0; i < len(x.Extensions); i++ {- if !x.Extensions[i].Equal(y.Extensions[i]) {- return false- }- }- if x.Datashare != y.Datashare {- return false- }- if x.ServiceName != y.ServiceName {- return false- }- if len(x.LinkedDatabases) != len(y.LinkedDatabases) {- return false- }- for i := 0; i < len(x.LinkedDatabases); i++ {- if !x.LinkedDatabases[i].Equal(y.LinkedDatabases[i]) {- return false- }- }- if x.Owner != y.Owner {- return false- }- if x.SearchPath != y.SearchPath {- return false- }- if len(x.EventTriggers) != len(y.EventTriggers) {- return false- }- for i := 0; i < len(x.EventTriggers); i++ {- if !x.EventTriggers[i].Equal(y.EventTriggers[i]) {- return false- }- }- return true-}--func (x *LinkedDatabaseMetadata) Equal(y *LinkedDatabaseMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Username != y.Username {- return false- }- if x.Host != y.Host {- return false- }- return true-}--func (x *SchemaMetadata) Equal(y *SchemaMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Tables) != len(y.Tables) {- return false- }- for i := 0; i < len(x.Tables); i++ {- if !x.Tables[i].Equal(y.Tables[i]) {- return false- }- }- if len(x.ExternalTables) != len(y.ExternalTables) {- return false- }- for i := 0; i < len(x.ExternalTables); i++ {- if !x.ExternalTables[i].Equal(y.ExternalTables[i]) {- return false- }- }- if len(x.Views) != len(y.Views) {- return false- }- for i := 0; i < len(x.Views); i++ {- if !x.Views[i].Equal(y.Views[i]) {- return false- }- }- if len(x.Functions) != len(y.Functions) {- return false- }- for i := 0; i < len(x.Functions); i++ {- if !x.Functions[i].Equal(y.Functions[i]) {- return false- }- }- if len(x.Procedures) != len(y.Procedures) {- return false- }- for i := 0; i < len(x.Procedures); i++ {- if !x.Procedures[i].Equal(y.Procedures[i]) {- return false- }- }- if len(x.Streams) != len(y.Streams) {- return false- }- for i := 0; i < len(x.Streams); i++ {- if !x.Streams[i].Equal(y.Streams[i]) {- return false- }- }- if len(x.Tasks) != len(y.Tasks) {- return false- }- for i := 0; i < len(x.Tasks); i++ {- if !x.Tasks[i].Equal(y.Tasks[i]) {- return false- }- }- if len(x.MaterializedViews) != len(y.MaterializedViews) {- return false- }- for i := 0; i < len(x.MaterializedViews); i++ {- if !x.MaterializedViews[i].Equal(y.MaterializedViews[i]) {- return false- }- }- if len(x.Sequences) != len(y.Sequences) {- return false- }- for i := 0; i < len(x.Sequences); i++ {- if !x.Sequences[i].Equal(y.Sequences[i]) {- return false- }- }- if len(x.Packages) != len(y.Packages) {- return false- }- for i := 0; i < len(x.Packages); i++ {- if !x.Packages[i].Equal(y.Packages[i]) {- return false- }- }- if x.Owner != y.Owner {- return false- }- if x.Comment != y.Comment {- return false- }- if len(x.Events) != len(y.Events) {- return false- }- for i := 0; i < len(x.Events); i++ {- if !x.Events[i].Equal(y.Events[i]) {- return false- }- }- if len(x.EnumTypes) != len(y.EnumTypes) {- return false- }- for i := 0; i < len(x.EnumTypes); i++ {- if !x.EnumTypes[i].Equal(y.EnumTypes[i]) {- return false- }- }- if x.SkipDump != y.SkipDump {- return false- }- if len(x.CompositeTypes) != len(y.CompositeTypes) {- return false- }- for i := 0; i < len(x.CompositeTypes); i++ {- if !x.CompositeTypes[i].Equal(y.CompositeTypes[i]) {- return false- }- }- return true-}--func (x *EnumTypeMetadata) Equal(y *EnumTypeMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Values) != len(y.Values) {- return false- }- for i := 0; i < len(x.Values); i++ {- if x.Values[i] != y.Values[i] {- return false- }- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *CompositeTypeMetadata) Equal(y *CompositeTypeMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Attributes) != len(y.Attributes) {- return false- }- for i := 0; i < len(x.Attributes); i++ {- if !x.Attributes[i].Equal(y.Attributes[i]) {- return false- }- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *CompositeTypeAttribute) Equal(y *CompositeTypeAttribute) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Type != y.Type {- return false- }- if x.Collation != y.Collation {- return false- }- if x.Comment != y.Comment {- return false- }- return true-}--func (x *EventMetadata) Equal(y *EventMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- if x.TimeZone != y.TimeZone {- return false- }- if x.SqlMode != y.SqlMode {- return false- }- if x.CharacterSetClient != y.CharacterSetClient {- return false- }- if x.CollationConnection != y.CollationConnection {- return false- }- if x.Comment != y.Comment {- return false- }- return true-}--func (x *SequenceMetadata) Equal(y *SequenceMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.DataType != y.DataType {- return false- }- if x.Start != y.Start {- return false- }- if x.MinValue != y.MinValue {- return false- }- if x.MaxValue != y.MaxValue {- return false- }- if x.Increment != y.Increment {- return false- }- if x.Cycle != y.Cycle {- return false- }- if x.CacheSize != y.CacheSize {- return false- }- if x.LastValue != y.LastValue {- return false- }- if x.OwnerTable != y.OwnerTable {- return false- }- if x.OwnerColumn != y.OwnerColumn {- return false- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *TriggerMetadata) Equal(y *TriggerMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Event != y.Event {- return false- }- if x.Timing != y.Timing {- return false- }- if x.Body != y.Body {- return false- }- if x.SqlMode != y.SqlMode {- return false- }- if x.CharacterSetClient != y.CharacterSetClient {- return false- }- if x.CollationConnection != y.CollationConnection {- return false- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *RuleMetadata) Equal(y *RuleMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Event != y.Event {- return false- }- if x.Condition != y.Condition {- return false- }- if x.Action != y.Action {- return false- }- if x.IsInstead != y.IsInstead {- return false- }- if x.IsEnabled != y.IsEnabled {- return false- }- if x.Definition != y.Definition {- return false- }- return true-}--func (x *TaskMetadata) Equal(y *TaskMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Id != y.Id {- return false- }- if x.Owner != y.Owner {- return false- }- if x.Comment != y.Comment {- return false- }- if x.Warehouse != y.Warehouse {- return false- }- if x.Schedule != y.Schedule {- return false- }- if len(x.Predecessors) != len(y.Predecessors) {- return false- }- for i := 0; i < len(x.Predecessors); i++ {- if x.Predecessors[i] != y.Predecessors[i] {- return false- }- }- if x.State != y.State {- return false- }- if x.Condition != y.Condition {- return false- }- if x.Definition != y.Definition {- return false- }- return true-}--func (x *StreamMetadata) Equal(y *StreamMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.TableName != y.TableName {- return false- }- if x.Owner != y.Owner {- return false- }- if x.Comment != y.Comment {- return false- }- if x.Type != y.Type {- return false- }- if x.Stale != y.Stale {- return false- }- if x.Mode != y.Mode {- return false- }- if x.Definition != y.Definition {- return false- }- return true-}--func (x *TableMetadata) Equal(y *TableMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Columns) != len(y.Columns) {- return false- }- for i := 0; i < len(x.Columns); i++ {- if !x.Columns[i].Equal(y.Columns[i]) {- return false- }- }- if len(x.Indexes) != len(y.Indexes) {- return false- }- for i := 0; i < len(x.Indexes); i++ {- if !x.Indexes[i].Equal(y.Indexes[i]) {- return false- }- }- if x.Engine != y.Engine {- return false- }- if x.Collation != y.Collation {- return false- }- if x.Charset != y.Charset {- return false- }- if x.RowCount != y.RowCount {- return false- }- if x.DataSize != y.DataSize {- return false- }- if x.IndexSize != y.IndexSize {- return false- }- if x.DataFree != y.DataFree {- return false- }- if x.CreateOptions != y.CreateOptions {- return false- }- if x.Comment != y.Comment {- return false- }- if len(x.ForeignKeys) != len(y.ForeignKeys) {- return false- }- for i := 0; i < len(x.ForeignKeys); i++ {- if !x.ForeignKeys[i].Equal(y.ForeignKeys[i]) {- return false- }- }- if len(x.Partitions) != len(y.Partitions) {- return false- }- for i := 0; i < len(x.Partitions); i++ {- if !x.Partitions[i].Equal(y.Partitions[i]) {- return false- }- }- if len(x.CheckConstraints) != len(y.CheckConstraints) {- return false- }- for i := 0; i < len(x.CheckConstraints); i++ {- if !x.CheckConstraints[i].Equal(y.CheckConstraints[i]) {- return false- }- }- if x.Owner != y.Owner {- return false- }- if len(x.SortingKeys) != len(y.SortingKeys) {- return false- }- for i := 0; i < len(x.SortingKeys); i++ {- if x.SortingKeys[i] != y.SortingKeys[i] {- return false- }- }- if len(x.Triggers) != len(y.Triggers) {- return false- }- for i := 0; i < len(x.Triggers); i++ {- if !x.Triggers[i].Equal(y.Triggers[i]) {- return false- }- }- if x.SkipDump != y.SkipDump {- return false- }- if len(x.Rules) != len(y.Rules) {- return false- }- for i := 0; i < len(x.Rules); i++ {- if !x.Rules[i].Equal(y.Rules[i]) {- return false- }- }- if x.ShardingInfo != y.ShardingInfo {- return false- }- if x.PrimaryKeyType != y.PrimaryKeyType {- return false- }- if len(x.ExcludeConstraints) != len(y.ExcludeConstraints) {- return false- }- for i := 0; i < len(x.ExcludeConstraints); i++ {- if !x.ExcludeConstraints[i].Equal(y.ExcludeConstraints[i]) {- return false- }- }- return true-}--func (x *CheckConstraintMetadata) Equal(y *CheckConstraintMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Expression != y.Expression {- return false- }- return true-}--func (x *ExcludeConstraintMetadata) Equal(y *ExcludeConstraintMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Expression != y.Expression {- return false- }- return true-}--func (x *ExternalTableMetadata) Equal(y *ExternalTableMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.ExternalServerName != y.ExternalServerName {- return false- }- if x.ExternalDatabaseName != y.ExternalDatabaseName {- return false- }- if len(x.Columns) != len(y.Columns) {- return false- }- for i := 0; i < len(x.Columns); i++ {- if !x.Columns[i].Equal(y.Columns[i]) {- return false- }- }- return true-}--func (x *TablePartitionMetadata) Equal(y *TablePartitionMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Type != y.Type {- return false- }- if x.Expression != y.Expression {- return false- }- if x.Value != y.Value {- return false- }- if x.UseDefault != y.UseDefault {- return false- }- if len(x.Subpartitions) != len(y.Subpartitions) {- return false- }- for i := 0; i < len(x.Subpartitions); i++ {- if !x.Subpartitions[i].Equal(y.Subpartitions[i]) {- return false- }- }- if len(x.Indexes) != len(y.Indexes) {- return false- }- for i := 0; i < len(x.Indexes); i++ {- if !x.Indexes[i].Equal(y.Indexes[i]) {- return false- }- }- if len(x.CheckConstraints) != len(y.CheckConstraints) {- return false- }- for i := 0; i < len(x.CheckConstraints); i++ {- if !x.CheckConstraints[i].Equal(y.CheckConstraints[i]) {- return false- }- }- if len(x.ExcludeConstraints) != len(y.ExcludeConstraints) {- return false- }- for i := 0; i < len(x.ExcludeConstraints); i++ {- if !x.ExcludeConstraints[i].Equal(y.ExcludeConstraints[i]) {- return false- }- }- return true-}--func (x *ColumnMetadata) Equal(y *ColumnMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Position != y.Position {- return false- }- if x.Default != y.Default {- return false- }- if x.DefaultOnNull != y.DefaultOnNull {- return false- }- if x.OnUpdate != y.OnUpdate {- return false- }- if x.Nullable != y.Nullable {- return false- }- if x.Type != y.Type {- return false- }- if x.CharacterSet != y.CharacterSet {- return false- }- if x.Collation != y.Collation {- return false- }- if x.Comment != y.Comment {- return false- }- if !x.Generation.Equal(y.Generation) {- return false- }- if x.IsIdentity != y.IsIdentity {- return false- }- if x.IdentityGeneration != y.IdentityGeneration {- return false- }- if x.IdentitySeed != y.IdentitySeed {- return false- }- if x.IdentityIncrement != y.IdentityIncrement {- return false- }- if x.DefaultConstraintName != y.DefaultConstraintName {- return false- }- if p, q := x.Srid, y.Srid; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) {- return false- }- if x.IsInvisible != y.IsInvisible {- return false- }- return true-}--func (x *GenerationMetadata) Equal(y *GenerationMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Type != y.Type {- return false- }- if x.Expression != y.Expression {- return false- }- return true-}--func (x *ViewMetadata) Equal(y *ViewMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- if x.Comment != y.Comment {- return false- }- if len(x.DependencyColumns) != len(y.DependencyColumns) {- return false- }- for i := 0; i < len(x.DependencyColumns); i++ {- if !x.DependencyColumns[i].Equal(y.DependencyColumns[i]) {- return false- }- }- if len(x.Columns) != len(y.Columns) {- return false- }- for i := 0; i < len(x.Columns); i++ {- if !x.Columns[i].Equal(y.Columns[i]) {- return false- }- }- if len(x.Triggers) != len(y.Triggers) {- return false- }- for i := 0; i < len(x.Triggers); i++ {- if !x.Triggers[i].Equal(y.Triggers[i]) {- return false- }- }- if x.SkipDump != y.SkipDump {- return false- }- if len(x.Rules) != len(y.Rules) {- return false- }- for i := 0; i < len(x.Rules); i++ {- if !x.Rules[i].Equal(y.Rules[i]) {- return false- }- }- return true-}--func (x *DependencyColumn) Equal(y *DependencyColumn) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Schema != y.Schema {- return false- }- if x.Table != y.Table {- return false- }- if x.Column != y.Column {- return false- }- return true-}--func (x *MaterializedViewMetadata) Equal(y *MaterializedViewMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- if x.Comment != y.Comment {- return false- }- if len(x.DependencyColumns) != len(y.DependencyColumns) {- return false- }- for i := 0; i < len(x.DependencyColumns); i++ {- if !x.DependencyColumns[i].Equal(y.DependencyColumns[i]) {- return false- }- }- if len(x.Triggers) != len(y.Triggers) {- return false- }- for i := 0; i < len(x.Triggers); i++ {- if !x.Triggers[i].Equal(y.Triggers[i]) {- return false- }- }- if len(x.Indexes) != len(y.Indexes) {- return false- }- for i := 0; i < len(x.Indexes); i++ {- if !x.Indexes[i].Equal(y.Indexes[i]) {- return false- }- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *DependencyTable) Equal(y *DependencyTable) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Schema != y.Schema {- return false- }- if x.Table != y.Table {- return false- }- return true-}--func (x *FunctionMetadata) Equal(y *FunctionMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- if x.Signature != y.Signature {- return false- }- if x.CharacterSetClient != y.CharacterSetClient {- return false- }- if x.CollationConnection != y.CollationConnection {- return false- }- if x.DatabaseCollation != y.DatabaseCollation {- return false- }- if x.SqlMode != y.SqlMode {- return false- }- if x.Comment != y.Comment {- return false- }- if len(x.DependencyTables) != len(y.DependencyTables) {- return false- }- for i := 0; i < len(x.DependencyTables); i++ {- if !x.DependencyTables[i].Equal(y.DependencyTables[i]) {- return false- }- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *ProcedureMetadata) Equal(y *ProcedureMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- if x.Signature != y.Signature {- return false- }- if x.CharacterSetClient != y.CharacterSetClient {- return false- }- if x.CollationConnection != y.CollationConnection {- return false- }- if x.DatabaseCollation != y.DatabaseCollation {- return false- }- if x.SqlMode != y.SqlMode {- return false- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *PackageMetadata) Equal(y *PackageMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Definition != y.Definition {- return false- }- return true-}--func (x *IndexMetadata) Equal(y *IndexMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Expressions) != len(y.Expressions) {- return false- }- for i := 0; i < len(x.Expressions); i++ {- if x.Expressions[i] != y.Expressions[i] {- return false- }- }- if len(x.KeyLength) != len(y.KeyLength) {- return false- }- for i := 0; i < len(x.KeyLength); i++ {- if x.KeyLength[i] != y.KeyLength[i] {- return false- }- }- if len(x.Descending) != len(y.Descending) {- return false- }- for i := 0; i < len(x.Descending); i++ {- if x.Descending[i] != y.Descending[i] {- return false- }- }- if x.Type != y.Type {- return false- }- if x.Unique != y.Unique {- return false- }- if x.Primary != y.Primary {- return false- }- if x.Visible != y.Visible {- return false- }- if x.Comment != y.Comment {- return false- }- if x.Definition != y.Definition {- return false- }- if x.ParentIndexSchema != y.ParentIndexSchema {- return false- }- if x.ParentIndexName != y.ParentIndexName {- return false- }- if x.Granularity != y.Granularity {- return false- }- if x.IsConstraint != y.IsConstraint {- return false- }- if !x.SpatialConfig.Equal(y.SpatialConfig) {- return false- }- if len(x.OpclassNames) != len(y.OpclassNames) {- return false- }- for i := 0; i < len(x.OpclassNames); i++ {- if x.OpclassNames[i] != y.OpclassNames[i] {- return false- }- }- if len(x.OpclassDefaults) != len(y.OpclassDefaults) {- return false- }- for i := 0; i < len(x.OpclassDefaults); i++ {- if x.OpclassDefaults[i] != y.OpclassDefaults[i] {- return false- }- }- return true-}--func (x *SpatialIndexConfig) Equal(y *SpatialIndexConfig) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Method != y.Method {- return false- }- if !x.Tessellation.Equal(y.Tessellation) {- return false- }- if !x.Storage.Equal(y.Storage) {- return false- }- if !x.Dimensional.Equal(y.Dimensional) {- return false- }- if len(x.EngineSpecific) != len(y.EngineSpecific) {- return false- }- for k := range x.EngineSpecific {- _, ok := y.EngineSpecific[k]- if !ok {- return false- }- if x.EngineSpecific[k] != y.EngineSpecific[k] {- return false- }- }- return true-}--func (x *TessellationConfig) Equal(y *TessellationConfig) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Scheme != y.Scheme {- return false- }- if !x.BoundingBox.Equal(y.BoundingBox) {- return false- }- if len(x.GridLevels) != len(y.GridLevels) {- return false- }- for i := 0; i < len(x.GridLevels); i++ {- if !x.GridLevels[i].Equal(y.GridLevels[i]) {- return false- }- }- if x.CellsPerObject != y.CellsPerObject {- return false- }- return true-}--func (x *BoundingBox) Equal(y *BoundingBox) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if (math.IsNaN(float64(x.Xmin)) && !math.IsNaN(float64(y.Xmin)) || !math.IsNaN(float64(x.Xmin)) && math.IsNaN(float64(y.Xmin))) || (!math.IsNaN(float64(x.Xmin)) && !math.IsNaN(float64(y.Xmin)) && x.Xmin != y.Xmin) {- return false- }- if (math.IsNaN(float64(x.Ymin)) && !math.IsNaN(float64(y.Ymin)) || !math.IsNaN(float64(x.Ymin)) && math.IsNaN(float64(y.Ymin))) || (!math.IsNaN(float64(x.Ymin)) && !math.IsNaN(float64(y.Ymin)) && x.Ymin != y.Ymin) {- return false- }- if (math.IsNaN(float64(x.Xmax)) && !math.IsNaN(float64(y.Xmax)) || !math.IsNaN(float64(x.Xmax)) && math.IsNaN(float64(y.Xmax))) || (!math.IsNaN(float64(x.Xmax)) && !math.IsNaN(float64(y.Xmax)) && x.Xmax != y.Xmax) {- return false- }- if (math.IsNaN(float64(x.Ymax)) && !math.IsNaN(float64(y.Ymax)) || !math.IsNaN(float64(x.Ymax)) && math.IsNaN(float64(y.Ymax))) || (!math.IsNaN(float64(x.Ymax)) && !math.IsNaN(float64(y.Ymax)) && x.Ymax != y.Ymax) {- return false- }- return true-}--func (x *GridLevel) Equal(y *GridLevel) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Level != y.Level {- return false- }- if x.Density != y.Density {- return false- }- return true-}--func (x *StorageConfig) Equal(y *StorageConfig) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Fillfactor != y.Fillfactor {- return false- }- if x.Buffering != y.Buffering {- return false- }- if x.Tablespace != y.Tablespace {- return false- }- if x.WorkTablespace != y.WorkTablespace {- return false- }- if x.SdoLevel != y.SdoLevel {- return false- }- if x.CommitInterval != y.CommitInterval {- return false- }- if x.PadIndex != y.PadIndex {- return false- }- if x.SortInTempdb != y.SortInTempdb {- return false- }- if x.DropExisting != y.DropExisting {- return false- }- if x.Online != y.Online {- return false- }- if x.AllowRowLocks != y.AllowRowLocks {- return false- }- if x.AllowPageLocks != y.AllowPageLocks {- return false- }- if x.Maxdop != y.Maxdop {- return false- }- if x.DataCompression != y.DataCompression {- return false- }- return true-}--func (x *DimensionalConfig) Equal(y *DimensionalConfig) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Dimensions != y.Dimensions {- return false- }- if x.DataType != y.DataType {- return false- }- if x.OperatorClass != y.OperatorClass {- return false- }- if x.LayerGtype != y.LayerGtype {- return false- }- if x.ParallelBuild != y.ParallelBuild {- return false- }- return true-}--func (x *ExtensionMetadata) Equal(y *ExtensionMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Schema != y.Schema {- return false- }- if x.Version != y.Version {- return false- }- if x.Description != y.Description {- return false- }- return true-}--func (x *EventTriggerMetadata) Equal(y *EventTriggerMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if x.Event != y.Event {- return false- }- if len(x.Tags) != len(y.Tags) {- return false- }- for i := 0; i < len(x.Tags); i++ {- if x.Tags[i] != y.Tags[i] {- return false- }- }- if x.FunctionSchema != y.FunctionSchema {- return false- }- if x.FunctionName != y.FunctionName {- return false- }- if x.Enabled != y.Enabled {- return false- }- if x.Definition != y.Definition {- return false- }- if x.Comment != y.Comment {- return false- }- if x.SkipDump != y.SkipDump {- return false- }- return true-}--func (x *ForeignKeyMetadata) Equal(y *ForeignKeyMetadata) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.Name != y.Name {- return false- }- if len(x.Columns) != len(y.Columns) {- return false- }- for i := 0; i < len(x.Columns); i++ {- if x.Columns[i] != y.Columns[i] {- return false- }- }- if x.ReferencedSchema != y.ReferencedSchema {- return false- }- if x.ReferencedTable != y.ReferencedTable {- return false- }- if len(x.ReferencedColumns) != len(y.ReferencedColumns) {- return false- }- for i := 0; i < len(x.ReferencedColumns); i++ {- if x.ReferencedColumns[i] != y.ReferencedColumns[i] {- return false- }- }- if x.OnDelete != y.OnDelete {- return false- }- if x.OnUpdate != y.OnUpdate {- return false- }- if x.MatchType != y.MatchType {- return false- }- return true-}-func (x *InstanceRoleMetadata) Equal(y *InstanceRoleMetadata) bool {if x == y {return truediff --git a/backend/plugin/advisor/advisor.go b/backend/plugin/advisor/advisor.goindex 594ef8f770..2d2a85a48f 100644--- a/backend/plugin/advisor/advisor.go+++ b/backend/plugin/advisor/advisor.go@@ -9,6 +9,7 @@ import ("log/slog""sync"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common/log"@@ -36,7 +37,7 @@ func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRule_Level) (storepb.A// Context is the context for advisor.type Context struct {- DBSchema *storepb.DatabaseSchemaMetadata+ DBSchema *metadatapb.DatabaseSchemaMetadataEnablePriorBackup boolEnableGhost boolListDatabaseNamesFunc base.ListDatabaseNamesFuncdiff --git a/backend/plugin/advisor/mssql/rule_index_not_redundant.go b/backend/plugin/advisor/mssql/rule_index_not_redundant.goindex c0459b3276..3f95e7d4f6 100644--- a/backend/plugin/advisor/mssql/rule_index_not_redundant.go+++ b/backend/plugin/advisor/mssql/rule_index_not_redundant.go@@ -5,6 +5,7 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mssql/ast"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -113,9 +114,9 @@ type FindIndexesKey struct {}// The value in the map represents the column list of a certain index.-type IndexMap = map[FindIndexesKey][]*storepb.IndexMetadata+type IndexMap = map[FindIndexesKey][]*metadatapb.IndexMetadata-func getIndexMapFromMetadata(dbMetadata *storepb.DatabaseSchemaMetadata) *IndexMap {+func getIndexMapFromMetadata(dbMetadata *metadatapb.DatabaseSchemaMetadata) *IndexMap {indexMap := IndexMap{}if dbMetadata == nil {return &indexMapdiff --git a/backend/plugin/advisor/mysql/mysql_rules_test.go b/backend/plugin/advisor/mysql/mysql_rules_test.goindex 0360419ed0..1e2cf18f05 100644--- a/backend/plugin/advisor/mysql/mysql_rules_test.go+++ b/backend/plugin/advisor/mysql/mysql_rules_test.go@@ -9,6 +9,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""github.com/bytebase/bytebase/backend/component/sheet"@@ -296,14 +297,14 @@ func TestMariaDBPriorBackupCheckAdvisor(t *testing.T) {func TestMySQLBuiltinWalkThroughCheckTableExists(t *testing.T) {sm := sheet.NewManager()- finalMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ finalMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "test",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "user",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},},diff --git a/backend/plugin/advisor/mysql/rule_table_limit_size.go b/backend/plugin/advisor/mysql/rule_table_limit_size.goindex a61bcda0f1..b38387f53f 100644--- a/backend/plugin/advisor/mysql/rule_table_limit_size.go+++ b/backend/plugin/advisor/mysql/rule_table_limit_size.go@@ -4,6 +4,7 @@ import ("context""fmt"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"@@ -57,7 +58,7 @@ type tableLimitSizeOmniRule struct {OmniBaseRuleaffectedTabNames []stringmaxRows int- dbMetadata *storepb.DatabaseSchemaMetadata+ dbMetadata *metadatapb.DatabaseSchemaMetadata}func (*tableLimitSizeOmniRule) Name() string {@@ -116,7 +117,7 @@ func (r *tableLimitSizeOmniRule) generateAdvice() {}}-func getTabRowsByName(targetTabName string, tables []*storepb.TableMetadata) int64 {+func getTabRowsByName(targetTabName string, tables []*metadatapb.TableMetadata) int64 {for _, table := range tables {if table.Name == targetTabName {return table.RowCountdiff --git a/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check.go b/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check.goindex d162b9a97c..474cfddf07 100644--- a/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check.go@@ -5,6 +5,7 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/oracle/ast""github.com/bytebase/bytebase/backend/common"@@ -236,7 +237,7 @@ func oracleNameEqual(astName, metadataName string, isObjectCaseSensitive bool) b// the current owner only — a DML explicitly qualified with a different owner// must stay silent (its metadata is simply not synced), not borrow the// current schema's table of the same name.-func oracleFindLongColumns(dbSchema *storepb.DatabaseSchemaMetadata, table *TableReference, isObjectCaseSensitive bool) []string {+func oracleFindLongColumns(dbSchema *metadatapb.DatabaseSchemaMetadata, table *TableReference, isObjectCaseSensitive bool) []string {var result []stringfor _, schemaMeta := range dbSchema.GetSchemas() {if schemaMeta.GetName() == "" {diff --git a/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check_test.go b/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check_test.goindex 929e8dce31..4ff0be479c 100644--- a/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check_test.go+++ b/backend/plugin/advisor/oracle/rule_builtin_prior_backup_check_test.go@@ -5,6 +5,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -20,21 +21,21 @@ func TestPriorBackupLongColumnWarning(t *testing.T) {// The real Oracle sync stores the connection schema's tables under an// EMPTY schema name (db/oracle/sync.go) — the fixture must match that// shape or the schema comparison is never exercised realistically.- dbSchema := &storepb.DatabaseSchemaMetadata{+ dbSchema := &metadatapb.DatabaseSchemaMetadata{Name: "DB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{- {Name: "T_LONG", Columns: []*storepb.ColumnMetadata{+ Tables: []*metadatapb.TableMetadata{+ {Name: "T_LONG", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "PAYLOAD", Type: "LONG"},}},- {Name: "T_LONG_RAW", Columns: []*storepb.ColumnMetadata{+ {Name: "T_LONG_RAW", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "BLOB_ISH", Type: "LONG RAW"},}},- {Name: "T_CLOB", Columns: []*storepb.ColumnMetadata{+ {Name: "T_CLOB", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "DOC", Type: "CLOB"},}},@@ -121,24 +122,24 @@ func TestPriorBackupLongColumnWarning(t *testing.T) {// catalogued upper-case: T_LONG and a quoted "t_long" are DIFFERENT// tables. The lookup must honor that instead of EqualFold-ing across it.t.Run("quoted_identifier_case_semantics", func(t *testing.T) {- csSchema := &storepb.DatabaseSchemaMetadata{+ csSchema := &metadatapb.DatabaseSchemaMetadata{Name: "DB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{// Unquoted DDL: catalogued upper, has a LONG column.- {Name: "T_LONG", Columns: []*storepb.ColumnMetadata{+ {Name: "T_LONG", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "PAYLOAD", Type: "LONG"},}},// Quoted DDL twin: exact-case lower, NO LONG column.- {Name: "t_long", Columns: []*storepb.ColumnMetadata{+ {Name: "t_long", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "NOTE", Type: "VARCHAR2"},}},// Quoted DDL with a LONG column.- {Name: "t_raw", Columns: []*storepb.ColumnMetadata{+ {Name: "t_raw", Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "RAWCOL", Type: "LONG RAW"},}},diff --git a/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go b/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.goindex 5d454e6530..27cb6c9265 100644--- a/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go+++ b/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go@@ -6,6 +6,7 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/oracle/ast""github.com/bytebase/bytebase/backend/common"@@ -105,7 +106,7 @@ func NewWhereDisallowFunctionsAndCalculationsRule(level storepb.Advice_Status,title string,currentSchema string,- dbSchema *storepb.DatabaseSchemaMetadata,+ dbSchema *metadatapb.DatabaseSchemaMetadata,isObjectCaseSensitive bool,) *WhereDisallowFunctionsAndCalculationsRule {r := &WhereDisallowFunctionsAndCalculationsRule{diff --git a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.goindex b51db73762..af5401438d 100644--- a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go+++ b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go@@ -5,6 +5,7 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -45,7 +46,7 @@ func (*FullyQualifiedObjectNameAdvisor) Check(_ context.Context, checkCtx advisotype fullyQualifiedObjectNameRule struct {OmniBaseRule- dbMetadata *storepb.DatabaseSchemaMetadata+ dbMetadata *metadatapb.DatabaseSchemaMetadata}func (*fullyQualifiedObjectNameRule) Name() string {diff --git a/backend/plugin/advisor/pg/advisor_statement_where_disallow_functions_and_calculations_test.go b/backend/plugin/advisor/pg/advisor_statement_where_disallow_functions_and_calculations_test.goindex 9051bf96d0..a3eafbb058 100644--- a/backend/plugin/advisor/pg/advisor_statement_where_disallow_functions_and_calculations_test.go+++ b/backend/plugin/advisor/pg/advisor_statement_where_disallow_functions_and_calculations_test.go@@ -5,6 +5,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""github.com/bytebase/bytebase/backend/component/sheet"@@ -19,21 +20,21 @@ import (func TestSearchPathResolution(t *testing.T) {// Custom mock: indexed `tech_book(name)` lives ONLY in `app_schema`.// public is empty. SearchPath puts app_schema first.- dbSchema := &storepb.DatabaseSchemaMetadata{+ dbSchema := &metadatapb.DatabaseSchemaMetadata{Name: "test",SearchPath: "app_schema, public",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "app_schema",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "tech_book",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "name", Type: "text"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "tech_book_name_idx", Expressions: []string{"name"}},},},@@ -71,21 +72,21 @@ func TestSearchPathResolution(t *testing.T) {// using parameterless GetSearchPath drops `$user`, so deployments with// `search_path = "$user", public` miss tables in the session-user schema.func TestSearchPathSessionUserResolution(t *testing.T) {- dbSchema := &storepb.DatabaseSchemaMetadata{+ dbSchema := &metadatapb.DatabaseSchemaMetadata{Name: "test",SearchPath: `"$user", public`,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "alice",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "tech_book",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "name", Type: "text"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "tech_book_name_idx", Expressions: []string{"name"}},},},diff --git a/backend/plugin/advisor/pg/advisor_table_require_pk_test.go b/backend/plugin/advisor/pg/advisor_table_require_pk_test.goindex d6efb639dc..0798739137 100644--- a/backend/plugin/advisor/pg/advisor_table_require_pk_test.go+++ b/backend/plugin/advisor/pg/advisor_table_require_pk_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""google.golang.org/protobuf/proto"@@ -20,50 +21,50 @@ import (// with_pk and without_pk live only in app_schema; shadow exists in both// schemas, with a PK only in public; legacy exists in both without a PK.func TestTableRequirePKSearchPath(t *testing.T) {- dbSchema := &storepb.DatabaseSchemaMetadata{+ dbSchema := &metadatapb.DatabaseSchemaMetadata{Name: "test",SearchPath: "app_schema, public",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "shadow",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},- Indexes: []*storepb.IndexMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Indexes: []*metadatapb.IndexMetadata{{Name: "shadow_pkey", Expressions: []string{"id"}, Unique: true, Primary: true},},},{Name: "legacy",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},},},},{Name: "app_schema",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "shadow",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},},{Name: "legacy",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},},{Name: "with_pk",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "name", Type: "text"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "with_pk_pkey", Expressions: []string{"id"}, Unique: true, Primary: true},},},{Name: "without_pk",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},@@ -134,12 +135,12 @@ func TestTableRequirePKSearchPath(t *testing.T) {}for _, tc := range tests {t.Run(tc.name, func(t *testing.T) {- original, ok := proto.Clone(dbSchema).(*storepb.DatabaseSchemaMetadata)+ original, ok := proto.Clone(dbSchema).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)if tc.searchPath != "" {original.SearchPath = tc.searchPath}- final, ok := proto.Clone(original).(*storepb.DatabaseSchemaMetadata)+ final, ok := proto.Clone(original).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)checkCtx := advisor.Context{DBType: storepb.Engine_POSTGRES,diff --git a/backend/plugin/advisor/pg/sdl_drop_check_test.go b/backend/plugin/advisor/pg/sdl_drop_check_test.goindex 1c1c7cedcf..1960544a22 100644--- a/backend/plugin/advisor/pg/sdl_drop_check_test.go+++ b/backend/plugin/advisor/pg/sdl_drop_check_test.go@@ -3,6 +3,7 @@ package pgimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -48,7 +49,7 @@ func TestCheckSDLDropOperations(t *testing.T) {ColumnChanges: []*schema.ColumnDiff{{Action: schema.MetadataDiffActionDrop,- OldColumn: &storepb.ColumnMetadata{+ OldColumn: &metadatapb.ColumnMetadata{Name: "email",},},@@ -105,7 +106,7 @@ func TestCheckSDLDropOperations(t *testing.T) {ForeignKeyChanges: []*schema.ForeignKeyDiff{{Action: schema.MetadataDiffActionDrop,- OldForeignKey: &storepb.ForeignKeyMetadata{+ OldForeignKey: &metadatapb.ForeignKeyMetadata{Name: "fk_users_teams",},},@@ -193,7 +194,7 @@ func TestCheckSDLDropOperations(t *testing.T) {ColumnChanges: []*schema.ColumnDiff{{Action: schema.MetadataDiffActionDrop,- OldColumn: &storepb.ColumnMetadata{+ OldColumn: &metadatapb.ColumnMetadata{Name: "legacy_field",},},diff --git a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.goindex d149e875de..62d0b1b6e6 100644--- a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go@@ -6,6 +6,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/tidb/ast"pingcapast "github.com/pingcap/tidb/pkg/parser/ast"@@ -438,7 +439,7 @@ func omniCollectTableAliases(t ast.TableExpr, defaultDB string, m *updateTableAl// refs at execution time).//// Returns deduplicated targets.-func omniExtractUpdateTargets(setList []*ast.Assignment, m *updateTableAliasMap, dbMetadata *storepb.DatabaseSchemaMetadata) []priorBackupTable {+func omniExtractUpdateTargets(setList []*ast.Assignment, m *updateTableAliasMap, dbMetadata *metadatapb.DatabaseSchemaMetadata) []priorBackupTable {var result []priorBackupTableseen := make(map[string]bool)add := func(t priorBackupTable) {@@ -524,7 +525,7 @@ func omniExtractUpdateTargets(setList []*ast.Assignment, m *updateTableAliasMap,// SET fall through to the zero-match path → all distinctBases// fallback. Case-insensitive matching on table/column names per// MySQL convention.-func omniResolveUnqualifiedSETColumn(colName string, distinctBases []priorBackupTable, dbMetadata *storepb.DatabaseSchemaMetadata) []priorBackupTable {+func omniResolveUnqualifiedSETColumn(colName string, distinctBases []priorBackupTable, dbMetadata *metadatapb.DatabaseSchemaMetadata) []priorBackupTable {if colName == "" {return distinctBases}diff --git a/backend/plugin/advisor/utils_for_tests.go b/backend/plugin/advisor/utils_for_tests.goindex 10f2897189..855e58c315 100644--- a/backend/plugin/advisor/utils_for_tests.go+++ b/backend/plugin/advisor/utils_for_tests.go@@ -10,6 +10,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""google.golang.org/protobuf/proto""gopkg.in/yaml.v3"@@ -43,14 +44,14 @@ var (// MockIndexColumnList is the mock index column list for test.MockIndexColumnList = []string{"id", "name"}// MockMySQLDatabase is the mock MySQL database for test.- MockMySQLDatabase = &storepb.DatabaseSchemaMetadata{+ MockMySQLDatabase = &metadatapb.DatabaseSchemaMetadata{Name: "test",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: MockTableName,- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",@@ -64,7 +65,7 @@ var (Type: "varchar(255)",},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: MockOldMySQLPKName,Expressions: []string{"id", "name"},@@ -84,7 +85,7 @@ var (},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "order_id", Type: "int"},{Name: "customer_name", Type: "varchar(255)"},{Name: "amount", Type: "decimal(10,2)"},@@ -93,7 +94,7 @@ var (// qualified lookups distinguish tech_book.name (indexed) from orders.name.{Name: "name", Type: "varchar(255)"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Expressions: []string{"order_id"},@@ -115,20 +116,20 @@ var (},}// MockPostgreSQLDatabase is the mock PostgreSQL database for test.- MockPostgreSQLDatabase = &storepb.DatabaseSchemaMetadata{+ MockPostgreSQLDatabase = &metadatapb.DatabaseSchemaMetadata{Name: "test",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: MockTableName,- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Position: 1},{Name: "name", Type: "text", Position: 2},{Name: "creator", Type: "text", Position: 3},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: MockOldPostgreSQLPKName,Expressions: []string{"id", "name"},@@ -148,14 +149,14 @@ var (},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "order_id", Type: "integer", Position: 1},{Name: "customer_name", Type: "text", Position: 2},{Name: "amount", Type: "numeric", Position: 3},{Name: "note", Type: "text", Position: 4},{Name: "name", Type: "text", Position: 5},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "orders_pkey", Expressions: []string{"order_id"}, Unique: true, Primary: true},{Name: "idx_orders_customer", Expressions: []string{"customer_name"}},{Name: "idx_orders_amount", Expressions: []string{"amount"}},@@ -163,26 +164,26 @@ var (},{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "product_id", Type: "integer", Position: 1},{Name: "title", Type: "text", Position: 2},{Name: "price", Type: "numeric", Position: 3},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "products_pkey", Expressions: []string{"product_id"}, Unique: true, Primary: true},{Name: "idx_products_price", Expressions: []string{"price"}},},},{Name: "no_index_table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "col_a", Type: "integer", Position: 1},{Name: "col_b", Type: "text", Position: 2},},},{Name: "insert_target",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Position: 1},{Name: "name", Type: "text", Position: 2},},@@ -194,15 +195,15 @@ var (},},}- MockMSSQLDatabase = &storepb.DatabaseSchemaMetadata{+ MockMSSQLDatabase = &metadatapb.DatabaseSchemaMetadata{Name: "master",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "pokes",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1", Type: "int"},{Name: "c2", Type: "int"},{Name: "c3", Type: "int"},@@ -211,7 +212,7 @@ var ({Name: "foo", Type: "int"},{Name: "bar", Type: "int"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx_0",Expressions: []string{"c1", "c2", "c3"},@@ -224,7 +225,7 @@ var (},{Name: "pokes2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "foo", Type: "int"},{Name: "bar", Type: "int"},// c1 also exists here (non-indexed) so tests can verify@@ -237,15 +238,15 @@ var (},{Name: "sales",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "order_id", Type: "int"},{Name: "customer_id", Type: "int"},{Name: "note", Type: "varchar"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Expressions: []string{"order_id"},@@ -266,34 +267,34 @@ var (// (`backend/plugin/db/oracle/sync.go`) stores SchemaMetadata{Name: ""}// — a single anonymous schema containing every object. The mock mirrors// this so advisors resolve tables the same way in tests and production.- MockOracleDatabase = &storepb.DatabaseSchemaMetadata{+ MockOracleDatabase = &metadatapb.DatabaseSchemaMetadata{Name: "TEST_DB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "TECH_BOOK",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "NAME", Type: "VARCHAR2(255)"},{Name: "CREATOR", Type: "VARCHAR2(255)"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "TECH_BOOK_PK", Expressions: []string{"ID", "NAME"}, Unique: true, Primary: true},{Name: "IDX_TECH_BOOK_NAME", Expressions: []string{"ID", "NAME"}},},},{Name: "ORDERS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ORDER_ID", Type: "NUMBER"},{Name: "CUSTOMER_NAME", Type: "VARCHAR2(255)"},{Name: "AMOUNT", Type: "NUMBER"},{Name: "NOTE", Type: "VARCHAR2(255)"},{Name: "NAME", Type: "VARCHAR2(255)"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "ORDERS_PK", Expressions: []string{"ORDER_ID"}, Unique: true, Primary: true},{Name: "IDX_ORDERS_CUSTOMER", Expressions: []string{"CUSTOMER_NAME"}},{Name: "IDX_ORDERS_AMOUNT", Expressions: []string{"AMOUNT"}},@@ -301,26 +302,26 @@ var (},{Name: "PRODUCTS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "PRODUCT_ID", Type: "NUMBER"},{Name: "TITLE", Type: "VARCHAR2(255)"},{Name: "PRICE", Type: "NUMBER"},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRODUCTS_PK", Expressions: []string{"PRODUCT_ID"}, Unique: true, Primary: true},{Name: "IDX_PRODUCTS_PRICE", Expressions: []string{"PRICE"}},},},{Name: "NO_INDEX_TABLE",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "COL_A", Type: "NUMBER"},{Name: "COL_B", Type: "VARCHAR2(255)"},},},{Name: "INSERT_TARGET",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER"},{Name: "NAME", Type: "VARCHAR2(255)"},},@@ -366,7 +367,7 @@ func RunSQLReviewRuleTest(t *testing.T, rule *storepb.SQLReviewRule, dbType storsm := sheet.NewManager()for i, tc := range tests {// Set metadata and database-specific settings based on engine type- var schemaMetadata *storepb.DatabaseSchemaMetadata+ var schemaMetadata *metadatapb.DatabaseSchemaMetadatacurDB := "TEST_DB"isCaseSensitive := false@@ -393,13 +394,13 @@ func RunSQLReviewRuleTest(t *testing.T, rule *storepb.SQLReviewRule, dbType stor// Create OriginalMetadata as DatabaseMetadata (read-only)// Clone to avoid mutations affecting future test cases- metadata, ok := proto.Clone(schemaMetadata).(*storepb.DatabaseSchemaMetadata)+ metadata, ok := proto.Clone(schemaMetadata).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok, "failed to clone metadata")originalMetadata := model.NewDatabaseMetadata(metadata, nil, nil, dbType, isCaseSensitive)// Create FinalMetadata as DatabaseMetadata (mutable for walk-through)// Clone to avoid mutations affecting future test cases- metadata, ok = proto.Clone(schemaMetadata).(*storepb.DatabaseSchemaMetadata)+ metadata, ok = proto.Clone(schemaMetadata).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok, "failed to clone metadata")finalMetadata := model.NewDatabaseMetadata(metadata, nil, nil, dbType, isCaseSensitive)@@ -505,11 +506,11 @@ func (*MockDriver) SyncInstance(_ context.Context) (*database.InstanceMetadata,}// SyncDBSchema implements the Driver interface.-func (*MockDriver) SyncDBSchema(_ context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (*MockDriver) SyncDBSchema(_ context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {return nil, nil}// Dump implements the Driver interface.-func (*MockDriver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*MockDriver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/bigquery/dump.go b/backend/plugin/db/bigquery/dump.goindex f39a56aad1..45b624ef00 100644--- a/backend/plugin/db/bigquery/dump.go+++ b/backend/plugin/db/bigquery/dump.go@@ -4,10 +4,10 @@ import ("context""io"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// Dump dumps the database.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/bigquery/sync.go b/backend/plugin/db/bigquery/sync.goindex ff7f19565b..cdd7037e8a 100644--- a/backend/plugin/db/bigquery/sync.go+++ b/backend/plugin/db/bigquery/sync.go@@ -5,16 +5,16 @@ import ("fmt""cloud.google.com/go/bigquery"+ metadatapb "github.com/bytebase/omni/metadata""google.golang.org/api/iterator"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/util")// SyncInstance syncs the instance.func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error) {- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatait := d.client.Datasets(ctx)for {@@ -25,7 +25,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)if err != nil {return nil, err}- databases = append(databases, &storepb.DatabaseSchemaMetadata{Name: dataset.DatasetID})+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: dataset.DatasetID})}return &db.InstanceMetadata{@@ -44,10 +44,10 @@ type columnRow struct {}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{}+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{}- columnMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+ columnMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)q := d.client.Query(fmt.Sprintf(`SELECTtable_name,@@ -76,7 +76,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}- column := &storepb.ColumnMetadata{+ column := &metadatapb.ColumnMetadata{Name: row.ColumnName,Position: row.OrdinalPosition,Nullable: nullableBool,@@ -110,7 +110,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, err}- schemaMetadata.Tables = append(schemaMetadata.Tables, &storepb.TableMetadata{+ schemaMetadata.Tables = append(schemaMetadata.Tables, &metadatapb.TableMetadata{Name: t.TableID,Columns: columns,RowCount: int64(tmd.NumRows),@@ -118,8 +118,8 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadDataSize: tmd.NumBytes,})}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}, nil}diff --git a/backend/plugin/db/cassandra/dump.go b/backend/plugin/db/cassandra/dump.goindex 9ee82f3cfe..50d438d5d8 100644--- a/backend/plugin/db/cassandra/dump.go+++ b/backend/plugin/db/cassandra/dump.go@@ -4,9 +4,9 @@ import ("context""io"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")-func (*Driver) Dump(context.Context, io.Writer, *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(context.Context, io.Writer, *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/cassandra/sync.go b/backend/plugin/db/cassandra/sync.goindex de27526c1f..3fafd8465f 100644--- a/backend/plugin/db/cassandra/sync.go+++ b/backend/plugin/db/cassandra/sync.go@@ -5,9 +5,9 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")@@ -47,7 +47,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrapf(err, "failed to get databases")}- var filteredDatabases []*storepb.DatabaseSchemaMetadata+ var filteredDatabases []*metadatapb.DatabaseSchemaMetadatafor _, database := range databases {if isSystemDatabase(database.Name) {continue@@ -69,13 +69,13 @@ type primaryKey struct {}type columnOrderInfo struct {- column *storepb.ColumnMetadata+ column *metadatapb.ColumnMetadatakind string // "partition_key", "clustering", or "regular"position int // Position within partition/clustering keys}-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}@@ -106,7 +106,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, errors.Wrapf(err, "failed to scan column")}columnOrderMap[tableName] = append(columnOrderMap[tableName], columnOrderInfo{- column: &storepb.ColumnMetadata{+ column: &metadatapb.ColumnMetadata{Name: columnName,Type: columnType,Nullable: true,@@ -173,7 +173,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadcolumnOrderMap[tableName] = columns}- indexMap := map[string][]*storepb.IndexMetadata{}+ indexMap := map[string][]*metadatapb.IndexMetadata{}indexScanner := d.session.Query(`SELECTtable_name,@@ -195,7 +195,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, errors.Wrapf(err, "failed to scan index")}- indexMap[tableName] = append(indexMap[tableName], &storepb.IndexMetadata{+ indexMap[tableName] = append(indexMap[tableName], &metadatapb.IndexMetadata{Name: indexName,Type: kind,Expressions: []string{options},@@ -236,7 +236,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}return 1})- pk := &storepb.IndexMetadata{+ pk := &metadatapb.IndexMetadata{Name: "PRIMARY KEY",Expressions: getPKExpressions(pks),Descending: getPKDescending(pks),@@ -245,12 +245,12 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Extract the sorted column metadata- var sortedColumns []*storepb.ColumnMetadata+ var sortedColumns []*metadatapb.ColumnMetadatafor _, colInfo := range columnOrderMap[tableName] {sortedColumns = append(sortedColumns, colInfo.column)}- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: tableName,Comment: comment,Columns: sortedColumns,@@ -264,9 +264,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, errors.Wrapf(err, "table scanner err")}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.config.ConnectionContext.DatabaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}, nil}@@ -330,12 +330,12 @@ func (d *Driver) getVersion(ctx context.Context) (string, error) {return version, nil}-func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) getDatabases(ctx context.Context) ([]*metadatapb.DatabaseSchemaMetadata, error) {scanner := d.session.Query("SELECT keyspace_name FROM system_schema.keyspaces").IterContext(ctx).Scanner()- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor scanner.Next() {- var database storepb.DatabaseSchemaMetadata+ var database metadatapb.DatabaseSchemaMetadataif err := scanner.Scan(&database.Name); err != nil {return nil, errors.Wrapf(err, "failed to scan")}diff --git a/backend/plugin/db/clickhouse/dump.go b/backend/plugin/db/clickhouse/dump.goindex 4e298a3a22..ae4694a958 100644--- a/backend/plugin/db/clickhouse/dump.go+++ b/backend/plugin/db/clickhouse/dump.go@@ -7,9 +7,8 @@ import ("io""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// Dump and restore.@@ -27,7 +26,7 @@ const ()// Dump dumps the database.-func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {txn, err := d.db.BeginTx(ctx, &sql.TxOptions{})if err != nil {return errdiff --git a/backend/plugin/db/clickhouse/sync.go b/backend/plugin/db/clickhouse/sync.goindex 9ceb423db0..c8c00a48e1 100644--- a/backend/plugin/db/clickhouse/sync.go+++ b/backend/plugin/db/clickhouse/sync.go@@ -6,6 +6,8 @@ import ("strings""time"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/util"@@ -23,7 +25,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, err}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadata// Query db infowhere := fmt.Sprintf("schema_name NOT IN (%s)", systemDatabaseClause)query := `@@ -37,7 +39,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}defer rows.Close()for rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name,); err != nil {@@ -59,14 +61,14 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}// Query column info// tableName -> columnList map- columnMap := make(map[string][]*storepb.ColumnMetadata)+ columnMap := make(map[string][]*metadatapb.ColumnMetadata)columnQuery := `SELECTtable_name,@@ -87,7 +89,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer columnRows.Close()for columnRows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}// Reference: https://clickhouse.com/docs/en/operations/system-tables/information_schema#columns// defaultValueExpression is an expression for the default value, or an empty string if it is not defined.var tableName, nullable, defaultValueExpression string@@ -161,14 +163,14 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// For view, the engine is "View".if engine == "View" {- schemaMetadata.Views = append(schemaMetadata.Views, &storepb.ViewMetadata{+ schemaMetadata.Views = append(schemaMetadata.Views, &metadatapb.ViewMetadata{Name: name,Columns: columnMap[name],Definition: definition,Comment: comment,})} else {- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: name,Columns: columnMap[name],Engine: engine,@@ -185,7 +187,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadprimaryKeys := strings.Split(primaryKey, ", ")// Clickhouse save primary keys in `system`.`tables` instead of an index.// This is a workaround to make it compatible with our metadata design.- table.Indexes = append(table.Indexes, &storepb.IndexMetadata{+ table.Indexes = append(table.Indexes, &metadatapb.IndexMetadata{Primary: true,Expressions: primaryKeys,})@@ -200,13 +202,13 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, util.FormatErrorWithQuery(err, tableQuery)}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}, nil}-func (d *Driver) getDataSkippingIndices(ctx context.Context, database string, table string) ([]*storepb.IndexMetadata, error) {+func (d *Driver) getDataSkippingIndices(ctx context.Context, database string, table string) ([]*metadatapb.IndexMetadata, error) {// Select basic fields of the data skipping index.// References:// * https://clickhouse.com/docs/en/operations/system-tables/data_skipping_indices@@ -226,10 +228,10 @@ func (d *Driver) getDataSkippingIndices(ctx context.Context, database string, ta}defer rows.Close()- var indices []*storepb.IndexMetadata+ var indices []*metadatapb.IndexMetadatafor rows.Next() {var expr string- index := &storepb.IndexMetadata{}+ index := &metadatapb.IndexMetadata{}if err := rows.Scan(&index.Name,&index.Type,diff --git a/backend/plugin/db/cockroachdb/cockroachdb.go b/backend/plugin/db/cockroachdb/cockroachdb.goindex 0ac847e59e..bdb36625a3 100644--- a/backend/plugin/db/cockroachdb/cockroachdb.go+++ b/backend/plugin/db/cockroachdb/cockroachdb.go@@ -12,6 +12,7 @@ import ("time""unicode"+ metadatapb "github.com/bytebase/omni/metadata""github.com/cockroachdb/cockroach-go/v2/crdb""github.com/jackc/pgx/v5""github.com/jackc/pgx/v5/stdlib"@@ -194,8 +195,8 @@ func (d *Driver) GetDB() *sql.DB {}// getDatabases gets all databases of an instance.-func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetadata, error) {- var databases []*storepb.DatabaseSchemaMetadata+func (d *Driver) getDatabases(ctx context.Context) ([]*metadatapb.DatabaseSchemaMetadata, error) {+ var databases []*metadatapb.DatabaseSchemaMetadataif err := crdb.Execute(func() error {rows, err := d.db.QueryContext(ctx, "SELECT datname, pg_encoding_to_char(encoding), datcollate FROM pg_database;")if err != nil {@@ -204,7 +205,7 @@ func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetdefer rows.Close()for rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name, &database.CharacterSet, &database.Collation); err != nil {return err}diff --git a/backend/plugin/db/cockroachdb/dump.go b/backend/plugin/db/cockroachdb/dump.goindex d5e675144c..14d8dfc8f0 100644--- a/backend/plugin/db/cockroachdb/dump.go+++ b/backend/plugin/db/cockroachdb/dump.go@@ -6,13 +6,12 @@ import ("io""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/cockroachdb/cockroach-go/v2/crdb"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// Dump dumps the database.-func (d *Driver) Dump(ctx context.Context, w io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, w io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {sb := &strings.Builder{}if err := crdb.ExecuteTx(ctx, d.db, &sql.TxOptions{ReadOnly: true,diff --git a/backend/plugin/db/cockroachdb/sync.go b/backend/plugin/db/cockroachdb/sync.goindex af3df141dd..9888136eef 100644--- a/backend/plugin/db/cockroachdb/sync.go+++ b/backend/plugin/db/cockroachdb/sync.go@@ -9,6 +9,7 @@ import ("strings""github.com/blang/semver/v4"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"crrawparser "github.com/cockroachdb/cockroachdb-parser/pkg/sql/parser"@@ -41,7 +42,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrap(err, "failed to get databases")}- var filteredDatabases []*storepb.DatabaseSchemaMetadata+ var filteredDatabases []*metadatapb.DatabaseSchemaMetadatafor _, database := range databases {// Skip all system databasesif crparser.IsSystemDatabase(database.Name) {@@ -60,14 +61,14 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {// Query db infodatabases, err := d.getDatabases(ctx)if err != nil {return nil, errors.Wrap(err, "failed to get databases")}- var databaseMetadata *storepb.DatabaseSchemaMetadata+ var databaseMetadata *metadatapb.DatabaseSchemaMetadatafor _, database := range databases {if database.Name == d.databaseName {databaseMetadata = database@@ -97,7 +98,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, errors.Wrapf(err, "failed to get tables from database %q", d.databaseName)}- var tablePartitionMap map[db.TableKey][]*storepb.TablePartitionMetadata+ var tablePartitionMap map[db.TableKey][]*metadatapb.TablePartitionMetadataif isAtLeastPG10 {tablePartitionMap, err = getTablePartitions(txn)if err != nil {@@ -137,7 +138,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadtable.Partitions = warpTablePartitions(tablePartitionMap, schemaName, table.Name)}}- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tables,ExternalTables: externalTableMap[schemaName],@@ -152,7 +153,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn databaseMetadata, err}-func warpTablePartitions(m map[db.TableKey][]*storepb.TablePartitionMetadata, schemaName, tableName string) []*storepb.TablePartitionMetadata {+func warpTablePartitions(m map[db.TableKey][]*metadatapb.TablePartitionMetadata, schemaName, tableName string) []*metadatapb.TablePartitionMetadata {key := db.TableKey{Schema: schemaName, Table: tableName}if partitions, exists := m[key]; exists {defer delete(m, key)@@ -161,7 +162,7 @@ func warpTablePartitions(m map[db.TableKey][]*storepb.TablePartitionMetadata, sc}return partitions}- return []*storepb.TablePartitionMetadata{}+ return []*metadatapb.TablePartitionMetadata{}}var listForeignKeyQuery = `@@ -187,8 +188,8 @@ WHEREAND c.contype = 'f'ORDER BY fk_schema, fk_table, fk_name;`, crparser.SystemSchemaWhereClause)-func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {- foreignKeysMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {+ foreignKeysMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)rows, err := txn.Query(listForeignKeyQuery)if err != nil {return nil, err@@ -196,7 +197,7 @@ func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata,defer rows.Close()for rows.Next() {- var fkMetadata storepb.ForeignKeyMetadata+ var fkMetadata metadatapb.ForeignKeyMetadatavar fkSchema, fkTable, fkDefinition stringif err := rows.Scan(&fkSchema,@@ -356,7 +357,7 @@ func getListTableQuery(isAtLeastPG10 bool) string {}// getTables gets all tables of a database.-func getTables(txn *sql.Tx, isAtLeastPG10 bool, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.TableMetadata, map[string][]*storepb.ExternalTableMetadata, error) {+func getTables(txn *sql.Tx, isAtLeastPG10 bool, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.TableMetadata, map[string][]*metadatapb.ExternalTableMetadata, error) {indexMap, err := getIndexes(txn)if err != nil {return nil, nil, errors.Wrapf(err, "failed to get indexes")@@ -370,7 +371,7 @@ func getTables(txn *sql.Tx, isAtLeastPG10 bool, columnMap map[db.TableKey][]*storeturn nil, nil, errors.Wrapf(err, "failed to get foreign tables")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)query := getListTableQuery(isAtLeastPG10)rows, err := txn.Query(query)if err != nil {@@ -379,7 +380,7 @@ func getTables(txn *sql.Tx, isAtLeastPG10 bool, columnMap map[db.TableKey][]*stodefer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var schemaName stringvar comment sql.NullStringif err := rows.Scan(&schemaName, &table.Name, &table.RowCount, &comment); err != nil {@@ -405,7 +406,7 @@ func getTables(txn *sql.Tx, isAtLeastPG10 bool, columnMap map[db.TableKey][]*storeturn tableMap, foreignTablesMap, nil}-func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ExternalTableMetadata, error) {+func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ExternalTableMetadata, error) {query := getListForeignTableQuery()rows, err := txn.Query(query)if err != nil {@@ -415,7 +416,7 @@ func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMe}defer rows.Close()- foreignTablesMap := make(map[string][]*storepb.ExternalTableMetadata)+ foreignTablesMap := make(map[string][]*metadatapb.ExternalTableMetadata)for rows.Next() {var schemaName, tableName, foreignServerCatalog, foreignServerName string@@ -423,7 +424,7 @@ func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMeslog.Error("failed to scan foreign table: %v", log.BBError(err))return nil, nil}- externalTable := &storepb.ExternalTableMetadata{+ externalTable := &metadatapb.ExternalTableMetadata{Name: tableName,ExternalServerName: foreignServerName,ExternalDatabaseName: foreignServerCatalog,@@ -465,8 +466,8 @@ WHEREAND n.nspname NOT IN (%s)ORDER BY c.oid;`, crparser.SystemSchemaWhereClause)-func getTablePartitions(txn *sql.Tx) (map[db.TableKey][]*storepb.TablePartitionMetadata, error) {- result := make(map[db.TableKey][]*storepb.TablePartitionMetadata)+func getTablePartitions(txn *sql.Tx) (map[db.TableKey][]*metadatapb.TablePartitionMetadata, error) {+ result := make(map[db.TableKey][]*metadatapb.TablePartitionMetadata)rows, err := txn.Query(listTablePartitionQuery)if err != nil {return nil, err@@ -482,17 +483,17 @@ func getTablePartitions(txn *sql.Tx) (map[db.TableKey][]*storepb.TablePartitionMcontinue}key := db.TableKey{Schema: inhSchemaName, Table: inhTableName}- metadata := &storepb.TablePartitionMetadata{+ metadata := &metadatapb.TablePartitionMetadata{Name: tableName,Expression: relPartBound,}switch strings.ToLower(partitionType) {case "l":- metadata.Type = storepb.TablePartitionMetadata_LIST+ metadata.Type = metadatapb.TablePartitionMetadata_LISTcase "r":- metadata.Type = storepb.TablePartitionMetadata_RANGE+ metadata.Type = metadatapb.TablePartitionMetadata_RANGEcase "h":- metadata.Type = storepb.TablePartitionMetadata_HASH+ metadata.Type = metadatapb.TablePartitionMetadata_HASHdefault:return nil, errors.Errorf("invalid partition type %q", partitionType)}@@ -526,15 +527,15 @@ WHERE cols.table_schema NOT IN (%s)ORDER BY cols.table_schema, cols.table_name, cols.ordinal_position;`, crparser.SystemSchemaWhereClause)// getTableColumns gets the columns of a table.-func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)rows, err := txn.Query(listColumnQuery)if err != nil {return nil, err}defer rows.Close()for rows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var schemaName, tableName, nullable stringvar characterMaxLength, defaultStr, collation, udtSchema, udtName, comment sql.NullStringif err := rows.Scan(&schemaName, &tableName, &column.Name, &column.Type, &characterMaxLength, &column.Position, &defaultStr, &nullable, &collation, &udtSchema, &udtName, &comment); err != nil {@@ -586,8 +587,8 @@ LEFT JOIN pg_class c ON c.relname = m.matviewname AND c.relnamespace = n.oid ANDWHERE m.schemaname NOT IN (%s)ORDER BY m.schemaname, m.matviewname;`, crparser.SystemSchemaWhereClause)-func getMaterializedViews(txn *sql.Tx) (map[string][]*storepb.MaterializedViewMetadata, error) {- matviewMap := make(map[string][]*storepb.MaterializedViewMetadata)+func getMaterializedViews(txn *sql.Tx) (map[string][]*metadatapb.MaterializedViewMetadata, error) {+ matviewMap := make(map[string][]*metadatapb.MaterializedViewMetadata)rows, err := txn.Query(listMaterializedViewQuery)if err != nil {@@ -595,7 +596,7 @@ func getMaterializedViews(txn *sql.Tx) (map[string][]*storepb.MaterializedViewMe}defer rows.Close()for rows.Next() {- matview := &storepb.MaterializedViewMetadata{}+ matview := &metadatapb.MaterializedViewMetadata{}var schemaName stringvar def, comment sql.NullStringif err := rows.Scan(&schemaName, &matview.Name, &def, &comment); err != nil {@@ -643,8 +644,8 @@ WHERE v.schemaname NOT IN (%s)ORDER BY v.schemaname, v.viewname;`, crparser.SystemSchemaWhereClause)// getViews gets all views of a database.-func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ViewMetadata, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ViewMetadata, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)rows, err := txn.Query(listViewQuery)if err != nil {@@ -652,7 +653,7 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)}defer rows.Close()for rows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var schemaName stringvar def, comment sql.NullStringif err := rows.Scan(&schemaName, &view.Name, &def, &comment); err != nil {@@ -696,8 +697,8 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)}// getViewDependencies gets the dependencies of a view.-func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.DependencyColumn, error) {- var result []*storepb.DependencyColumn+func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*metadatapb.DependencyColumn, error) {+ var result []*metadatapb.DependencyColumnquery := fmt.Sprintf(`SELECT source_ns.nspname as source_schema,@@ -726,7 +727,7 @@ func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.D}defer rows.Close()for rows.Next() {- dependencyColumn := &storepb.DependencyColumn{}+ dependencyColumn := &metadatapb.DependencyColumn{}if err := rows.Scan(&dependencyColumn.Schema, &dependencyColumn.Table, &dependencyColumn.Column); err != nil {return nil, err}@@ -739,8 +740,8 @@ func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.D}// getExtensions gets all extensions of a database.-func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {- var extensions []*storepb.ExtensionMetadata+func getExtensions(txn *sql.Tx) ([]*metadatapb.ExtensionMetadata, error) {+ var extensions []*metadatapb.ExtensionMetadataquery := `SELECT e.extname, e.extversion, n.nspname, c.description@@ -755,7 +756,7 @@ func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {}defer rows.Close()for rows.Next() {- e := &storepb.ExtensionMetadata{}+ e := &metadatapb.ExtensionMetadata{}var description sql.NullStringif err := rows.Scan(&e.Name, &e.Version, &e.Schema, &description); err != nil {return nil, err@@ -773,7 +774,7 @@ func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {}// getSequences gets all sequences of a database.-func getSequences(txn *sql.Tx) (map[string][]*storepb.SequenceMetadata, error) {+func getSequences(txn *sql.Tx) (map[string][]*metadatapb.SequenceMetadata, error) {query := `SELECT sequence_schema, sequence_name, data_type FROM information_schema.sequences;`rows, err := txn.Query(query)if err != nil {@@ -781,9 +782,9 @@ func getSequences(txn *sql.Tx) (map[string][]*storepb.SequenceMetadata, error) {}defer rows.Close()- sequenceMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceMap := make(map[string][]*metadatapb.SequenceMetadata)for rows.Next() {- sequence := &storepb.SequenceMetadata{}+ sequence := &metadatapb.SequenceMetadata{}var schemaName stringif err := rows.Scan(&schemaName, &sequence.Name, &sequence.DataType); err != nil {return nil, err@@ -813,8 +814,8 @@ WHERE idx.schemaname NOT IN (%s)ORDER BY idx.schemaname, idx.tablename, idx.indexname;`, crparser.SystemSchemaWhereClause)// getIndexes gets all indices of a database.-func getIndexes(txn *sql.Tx) (map[db.TableKey][]*storepb.IndexMetadata, error) {- indexMap := make(map[db.TableKey][]*storepb.IndexMetadata)+func getIndexes(txn *sql.Tx) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {+ indexMap := make(map[db.TableKey][]*metadatapb.IndexMetadata)rows, err := txn.Query(listIndexQuery)if err != nil {@@ -822,7 +823,7 @@ func getIndexes(txn *sql.Tx) (map[db.TableKey][]*storepb.IndexMetadata, error) {}defer rows.Close()for rows.Next() {- index := &storepb.IndexMetadata{}+ index := &metadatapb.IndexMetadata{}var schemaName, tableName, statement stringvar constraintType sql.NullStringvar comment sql.NullString@@ -908,8 +909,8 @@ where n.nspname not in (%s)order by function_schema, function_name;`, crparser.SystemSchemaWhereClause)// getFunctions gets all functions of a database.-func getFunctions(txn *sql.Tx) (map[string][]*storepb.FunctionMetadata, error) {- functionMap := make(map[string][]*storepb.FunctionMetadata)+func getFunctions(txn *sql.Tx) (map[string][]*metadatapb.FunctionMetadata, error) {+ functionMap := make(map[string][]*metadatapb.FunctionMetadata)rows, err := txn.Query(listFunctionQuery)if err != nil {@@ -917,7 +918,7 @@ func getFunctions(txn *sql.Tx) (map[string][]*storepb.FunctionMetadata, error) {}defer rows.Close()for rows.Next() {- function := &storepb.FunctionMetadata{}+ function := &metadatapb.FunctionMetadata{}var schemaName stringif err := rows.Scan(&schemaName, &function.Name, &function.Definition); err != nil {return nil, errdiff --git a/backend/plugin/db/cosmosdb/cosmosdb.go b/backend/plugin/db/cosmosdb/cosmosdb.goindex 5059126270..c5ef0a7648 100644--- a/backend/plugin/db/cosmosdb/cosmosdb.go+++ b/backend/plugin/db/cosmosdb/cosmosdb.go@@ -11,6 +11,7 @@ import ("time""connectrpc.com/connect"+ metadatapb "github.com/bytebase/omni/metadata""google.golang.org/protobuf/types/known/durationpb""github.com/Azure/azure-sdk-for-go/sdk/azcore"@@ -138,7 +139,7 @@ func (*Driver) Execute(_ context.Context, _ string, _ db.ExecuteOptions) (int64,}// Dump dumps the database.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/cosmosdb/sync.go b/backend/plugin/db/cosmosdb/sync.goindex 98941421c5..9ef7459ab9 100644--- a/backend/plugin/db/cosmosdb/sync.go+++ b/backend/plugin/db/cosmosdb/sync.go@@ -3,10 +3,10 @@ package cosmosdbimport ("context"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")@@ -17,7 +17,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return d.syncInstanceViaREST()}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadataqueryPager := d.client.NewQueryDatabasesPager("select * from dbs d", nil)for queryPager.More() {queryResponse, err := queryPager.NextPage(ctx)@@ -25,7 +25,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrapf(err, "failed to get next page in database list")}for _, database := range queryResponse.Databases {- databases = append(databases, &storepb.DatabaseSchemaMetadata{+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: database.ID,})}@@ -44,9 +44,9 @@ func (d *Driver) syncInstanceViaREST() (*db.InstanceMetadata, error) {if err != nil {return nil, err}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor _, name := range names {- databases = append(databases, &storepb.DatabaseSchemaMetadata{+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: name,})}@@ -56,13 +56,13 @@ func (d *Driver) syncInstanceViaREST() (*db.InstanceMetadata, error) {}// SyncDBSchema syncs the database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {endpoint := d.connCfg.DataSource.Hostif common.IsDev() && isLocalhostEndpoint(endpoint) {return d.syncDBSchemaViaREST()}- var containers []*storepb.TableMetadata+ var containers []*metadatapb.TableMetadatadatabase, err := d.client.NewDatabase(d.databaseName)if err != nil {return nil, errors.Wrapf(err, "failed to get database %q", d.databaseName)@@ -74,14 +74,14 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, errors.Wrapf(err, "failed to get next page in container list")}for _, container := range queryResponse.Containers {- containers = append(containers, &storepb.TableMetadata{+ containers = append(containers, &metadatapb.TableMetadata{Name: container.ID,})}}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Tables: containers,},@@ -89,7 +89,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}, nil}-func (d *Driver) syncDBSchemaViaREST() (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) syncDBSchemaViaREST() (*metadatapb.DatabaseSchemaMetadata, error) {client, err := newEmulatorRESTClient(d.connCfg.DataSource.Host)if err != nil {return nil, err@@ -98,15 +98,15 @@ func (d *Driver) syncDBSchemaViaREST() (*storepb.DatabaseSchemaMetadata, error)if err != nil {return nil, err}- var containers []*storepb.TableMetadata+ var containers []*metadatapb.TableMetadatafor _, name := range names {- containers = append(containers, &storepb.TableMetadata{+ containers = append(containers, &metadatapb.TableMetadata{Name: name,})}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Tables: containers,},diff --git a/backend/plugin/db/databricks/dump.go b/backend/plugin/db/databricks/dump.goindex 66b926ebfa..366d086b2f 100644--- a/backend/plugin/db/databricks/dump.go+++ b/backend/plugin/db/databricks/dump.go@@ -8,9 +8,8 @@ import ("regexp""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/databricks/databricks-sdk-go/service/catalog"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")const (@@ -27,7 +26,7 @@ var (dftSchema = "default")-func (d *Driver) Dump(ctx context.Context, writer io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, writer io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {catalogMap, err := d.listCatologTables(ctx, "")if err != nil {return err@@ -141,7 +140,7 @@ func (d *Driver) showCreateTable(ctx context.Context, qualifiedTblName string) (return rows[0][0], nil}-func genMaterializedViewDDL(qualifiedName string, mtViewMeta *storepb.MaterializedViewMetadata, tblProperties string) (string, error) {+func genMaterializedViewDDL(qualifiedName string, mtViewMeta *metadatapb.MaterializedViewMetadata, tblProperties string) (string, error) {builder := strings.Builder{}if _, err := builder.WriteString(""); err != nil {return "", errdiff --git a/backend/plugin/db/databricks/sync.go b/backend/plugin/db/databricks/sync.goindex 371b22d824..f21fc0d3f5 100644--- a/backend/plugin/db/databricks/sync.go+++ b/backend/plugin/db/databricks/sync.go@@ -5,18 +5,18 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/databricks/databricks-sdk-go/service/catalog""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")type tableUnion struct {- externalTable *storepb.ExternalTableMetadata- table *storepb.TableMetadata- view *storepb.ViewMetadata- materialView *storepb.MaterializedViewMetadata+ externalTable *metadatapb.ExternalTableMetadata+ table *metadatapb.TableMetadata+ view *metadatapb.ViewMetadata+ materialView *metadatapb.MaterializedViewMetadatatypeName catalog.TableTypename string}@@ -25,7 +25,7 @@ type databricksSchemaMap = map[string][]*tableUniontype databricksCatalogMap = map[string]databricksSchemaMap// sync catalog.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {// return nothing if no catalogs are specified.if d.curCatalog == "" {return nil, nil@@ -37,7 +37,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}- dbMetadataMeta := storepb.DatabaseSchemaMetadata{}+ dbMetadataMeta := metadatapb.DatabaseSchemaMetadata{}schemaMap, ok := (catalogMap)[d.curCatalog]if !ok {return nil, errors.Errorf("cannot find metadata for catalog '%s'", d.curCatalog)@@ -74,7 +74,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}for catalogName, schemaMap := range catalogMap {- dbMetadataMeta := storepb.DatabaseSchemaMetadata{}+ dbMetadataMeta := metadatapb.DatabaseSchemaMetadata{}schemas := convertToStorepbSchemas(schemaMap)dbMetadataMeta.Name = catalogNamedbMetadataMeta.Schemas = schemas@@ -147,24 +147,24 @@ func appendSchemaTables(catalogMap databricksCatalogMap, tablesInfo []catalog.Taswitch tableInfo.TableType {case catalog.TableTypeView:- table.view = &storepb.ViewMetadata{+ table.view = &metadatapb.ViewMetadata{Name: table.name,Definition: tableInfo.ViewDefinition,Comment: tableInfo.Comment,DependencyColumns: convertToDependencyColumns(tableInfo.SchemaName, tableInfo.Name, tableInfo.Columns),}case catalog.TableTypeMaterializedView:- table.materialView = &storepb.MaterializedViewMetadata{+ table.materialView = &metadatapb.MaterializedViewMetadata{Name: table.name,Definition: tableInfo.ViewDefinition,Comment: tableInfo.Comment,}case catalog.TableTypeExternal:- table.externalTable = &storepb.ExternalTableMetadata{+ table.externalTable = &metadatapb.ExternalTableMetadata{Name: table.name,}case catalog.TableTypeManaged:- table.table = &storepb.TableMetadata{+ table.table = &metadatapb.TableMetadata{Name: table.name,Columns: convertToColumnMetadata(tableInfo.Columns),Comment: tableInfo.Comment,@@ -185,10 +185,10 @@ func appendSchemaTables(catalogMap databricksCatalogMap, tablesInfo []catalog.Tareturn nil}-func convertToColumnMetadata(columnInfo []catalog.ColumnInfo) []*storepb.ColumnMetadata {- columns := []*storepb.ColumnMetadata{}+func convertToColumnMetadata(columnInfo []catalog.ColumnInfo) []*metadatapb.ColumnMetadata {+ columns := []*metadatapb.ColumnMetadata{}for _, col := range columnInfo {- columns = append(columns, &storepb.ColumnMetadata{+ columns = append(columns, &metadatapb.ColumnMetadata{Name: col.Name,Position: int32(col.Position),Nullable: col.Nullable,@@ -199,10 +199,10 @@ func convertToColumnMetadata(columnInfo []catalog.ColumnInfo) []*storepb.ColumnMreturn columns}-func convertToDependencyColumns(schema, table string, columnInfo []catalog.ColumnInfo) []*storepb.DependencyColumn {- columns := []*storepb.DependencyColumn{}+func convertToDependencyColumns(schema, table string, columnInfo []catalog.ColumnInfo) []*metadatapb.DependencyColumn {+ columns := []*metadatapb.DependencyColumn{}for _, col := range columnInfo {- columns = append(columns, &storepb.DependencyColumn{+ columns = append(columns, &metadatapb.DependencyColumn{Schema: schema,Table: table,Column: col.Name,@@ -211,10 +211,10 @@ func convertToDependencyColumns(schema, table string, columnInfo []catalog.Columreturn columns}-func convertToStorepbSchemas(schemaMap databricksSchemaMap) []*storepb.SchemaMetadata {- schemas := []*storepb.SchemaMetadata{}+func convertToStorepbSchemas(schemaMap databricksSchemaMap) []*metadatapb.SchemaMetadata {+ schemas := []*metadatapb.SchemaMetadata{}for schemaName, tableList := range schemaMap {- schemaMetadata := &storepb.SchemaMetadata{+ schemaMetadata := &metadatapb.SchemaMetadata{Name: schemaName,}diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.goindex 083ef2e313..d5f03a0f59 100644--- a/backend/plugin/db/driver.go+++ b/backend/plugin/db/driver.go@@ -10,6 +10,7 @@ import ("sync""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""google.golang.org/protobuf/types/known/durationpb"@@ -22,7 +23,7 @@ import (type InstanceMetadata struct {Version string// Simplified database metadata.- Databases []*storepb.DatabaseSchemaMetadata+ Databases []*metadatapb.DatabaseSchemaMetadataMetadata *storepb.Instance}@@ -35,7 +36,7 @@ type TableKey struct {type TableKeyWithColumns struct {Schema stringTable string- Columns []*storepb.ColumnMetadata+ Columns []*metadatapb.ColumnMetadata}// ColumnKey is the map key for table metadata.@@ -154,10 +155,10 @@ type Driver interface {// SyncInstance syncs the instance metadata.SyncInstance(ctx context.Context) (*InstanceMetadata, error)// SyncDBSchema syncs a single database schema.- SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error)+ SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error)// Dump dumps the schema of database.- Dump(ctx context.Context, out io.Writer, dbMetadata *storepb.DatabaseSchemaMetadata) error+ Dump(ctx context.Context, out io.Writer, dbMetadata *metadatapb.DatabaseSchemaMetadata) error}// Register makes a database driver available by the provided type.diff --git a/backend/plugin/db/dynamodb/dump.go b/backend/plugin/db/dynamodb/dump.goindex 1f69818d75..f040aeb225 100644--- a/backend/plugin/db/dynamodb/dump.go+++ b/backend/plugin/db/dynamodb/dump.go@@ -4,10 +4,10 @@ import ("context""io"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// Dump dumps the database.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/dynamodb/sync.go b/backend/plugin/db/dynamodb/sync.goindex 51e8132fc8..bf6b06923f 100644--- a/backend/plugin/db/dynamodb/sync.go+++ b/backend/plugin/db/dynamodb/sync.go@@ -8,9 +8,9 @@ import ("github.com/aws/aws-sdk-go-v2/service/dynamodb""github.com/aws/aws-sdk-go-v2/service/dynamodb/types""github.com/aws/aws-sdk-go-v2/service/sts"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")@@ -33,7 +33,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)databaseName := formatDatabaseName(*identity.Account, region)return &db.InstanceMetadata{- Databases: []*storepb.DatabaseSchemaMetadata{+ Databases: []*metadatapb.DatabaseSchemaMetadata{{Name: databaseName,},@@ -42,8 +42,8 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{}+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{}tableNames, err := d.listAllTables(ctx)if err != nil {@@ -63,16 +63,16 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.config.ConnectionContext.DatabaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata,},}, nil}-func (d *Driver) syncTable(ctx context.Context, tableName string) (*storepb.TableMetadata, error) {- tableMetadata := &storepb.TableMetadata{+func (d *Driver) syncTable(ctx context.Context, tableName string) (*metadatapb.TableMetadata, error) {+ tableMetadata := &metadatapb.TableMetadata{Name: tableName,}out, err := d.client.DescribeTable(ctx, &dynamodb.DescribeTableInput{@@ -99,12 +99,12 @@ func (d *Driver) syncTable(ctx context.Context, tableName string) (*storepb.Tabl// Unknown key type, ignore}}- tableMetadata.Indexes = append(tableMetadata.Indexes, &storepb.IndexMetadata{+ tableMetadata.Indexes = append(tableMetadata.Indexes, &metadatapb.IndexMetadata{Name: strings.Join(hashKeyAttributes, ","),Expressions: append([]string{}, hashKeyAttributes...),Type: "HASH",})- tableMetadata.Indexes = append(tableMetadata.Indexes, &storepb.IndexMetadata{+ tableMetadata.Indexes = append(tableMetadata.Indexes, &metadatapb.IndexMetadata{Name: strings.Join(rangeKeyAttributes, ","),Expressions: append([]string{}, rangeKeyAttributes...),Type: "RANGE",@@ -121,9 +121,9 @@ func (d *Driver) syncTable(ctx context.Context, tableName string) (*storepb.TablsortedColumns = append(sortedColumns, key)}slices.Sort(sortedColumns)- tableMetadata.Columns = make([]*storepb.ColumnMetadata, 0, len(sortedColumns))+ tableMetadata.Columns = make([]*metadatapb.ColumnMetadata, 0, len(sortedColumns))for _, key := range sortedColumns {- tableMetadata.Columns = append(tableMetadata.Columns, &storepb.ColumnMetadata{+ tableMetadata.Columns = append(tableMetadata.Columns, &metadatapb.ColumnMetadata{Name: key,})}diff --git a/backend/plugin/db/elasticsearch/dump.go b/backend/plugin/db/elasticsearch/dump.goindex 9a677bea24..d16fc4c386 100644--- a/backend/plugin/db/elasticsearch/dump.go+++ b/backend/plugin/db/elasticsearch/dump.go@@ -4,10 +4,10 @@ import ("context""io"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// Dump() is not applicable to Elasticsearch.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/elasticsearch/sync.go b/backend/plugin/db/elasticsearch/sync.goindex 0855d7ad55..8b47612a35 100644--- a/backend/plugin/db/elasticsearch/sync.go+++ b/backend/plugin/db/elasticsearch/sync.go@@ -9,6 +9,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/elastic/go-elasticsearch/v7/esapi""github.com/opensearch-project/opensearch-go/v4/opensearchapi""github.com/pkg/errors"@@ -36,7 +37,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return &db.InstanceMetadata{Version: version,- Databases: []*storepb.DatabaseSchemaMetadata{dbMetadata},+ Databases: []*metadatapb.DatabaseSchemaMetadata{dbMetadata},Metadata: &storepb.Instance{Roles: instanceRoles,},@@ -44,8 +45,8 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema implements db.Driver.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- var dbMetadataProto storepb.DatabaseSchemaMetadata+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ var dbMetadataProto metadatapb.DatabaseSchemaMetadata// indices.indices, err := d.getIndices(ctx)@@ -55,7 +56,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad// TODO(tommy): database name?dbMetadataProto.Name = "node"- dbMetadataProto.Schemas = append(dbMetadataProto.Schemas, &storepb.SchemaMetadata{Tables: indices})+ dbMetadataProto.Schemas = append(dbMetadataProto.Schemas, &metadatapb.SchemaMetadata{Tables: indices})return &dbMetadataProto, nil}@@ -202,8 +203,8 @@ func (d *Driver) getHiddenIndices(ctx context.Context) (map[string]bool, error)return hiddenIndices, nil}-func (d *Driver) getIndices(ctx context.Context) ([]*storepb.TableMetadata, error) {- var indicesMetadata []*storepb.TableMetadata+func (d *Driver) getIndices(ctx context.Context) ([]*metadatapb.TableMetadata, error) {+ var indicesMetadata []*metadatapb.TableMetadata// Get hidden indices to filter them out.hiddenIndices, err := d.getHiddenIndices(ctx)@@ -235,7 +236,7 @@ func (d *Driver) getIndices(ctx context.Context) ([]*storepb.TableMetadata, errodocCount = int64(*idx.DocsCount)}- indicesMetadata = append(indicesMetadata, &storepb.TableMetadata{+ indicesMetadata = append(indicesMetadata, &metadatapb.TableMetadata{Name: idx.Index,DataSize: datasize,RowCount: docCount,@@ -277,7 +278,7 @@ func (d *Driver) getIndices(ctx context.Context) ([]*storepb.TableMetadata, erroif err != nil {return nil, err}- indicesMetadata = append(indicesMetadata, &storepb.TableMetadata{+ indicesMetadata = append(indicesMetadata, &metadatapb.TableMetadata{Name: m.Index,DataSize: datasize,RowCount: docCount,@@ -327,7 +328,7 @@ func (d *Driver) getIndices(ctx context.Context) ([]*storepb.TableMetadata, erroif err != nil {return nil, err}- indicesMetadata = append(indicesMetadata, &storepb.TableMetadata{+ indicesMetadata = append(indicesMetadata, &metadatapb.TableMetadata{Name: m.Index,DataSize: datasize,RowCount: docCount,diff --git a/backend/plugin/db/hive/dump.go b/backend/plugin/db/hive/dump.goindex d7386604ed..f52d14bd65 100644--- a/backend/plugin/db/hive/dump.go+++ b/backend/plugin/db/hive/dump.go@@ -8,9 +8,8 @@ import (// Import gohive v2 driver for database/sql registration._ "github.com/beltran/gohive/v2"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")const (@@ -56,7 +55,7 @@ type MaterializedViewDDLOptions struct {as string}-func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {if d.db == nil {return errors.New("connection not initialized")}diff --git a/backend/plugin/db/hive/sync.go b/backend/plugin/db/hive/sync.goindex 698df05ec7..466ccdaa69 100644--- a/backend/plugin/db/hive/sync.go+++ b/backend/plugin/db/hive/sync.go@@ -7,10 +7,10 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common/log"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")@@ -30,7 +30,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}for _, v := range databaseNames {- instanceMetadata.Databases = append(instanceMetadata.Databases, &storepb.DatabaseSchemaMetadata{+ instanceMetadata.Databases = append(instanceMetadata.Databases, &metadatapb.DatabaseSchemaMetadata{Name: v,})}@@ -39,7 +39,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return &instanceMetadata, nil}-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {dbName := d.config.ConnectionContext.DatabaseNameif dbName == "" {dbName = "default"@@ -49,9 +49,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, errors.Wrapf(err, "failed to get info from database %s", dbName)}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: dbName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}, nil}@@ -106,17 +106,17 @@ func (d *Driver) listTablesNames(ctx context.Context, databaseName string) ([]st// getTables fetches table info and returns structed table data.func (d *Driver) getTables(ctx context.Context, databaseName string) (- []*storepb.TableMetadata,- []*storepb.ExternalTableMetadata,- []*storepb.ViewMetadata,- []*storepb.MaterializedViewMetadata,+ []*metadatapb.TableMetadata,+ []*metadatapb.ExternalTableMetadata,+ []*metadatapb.ViewMetadata,+ []*metadatapb.MaterializedViewMetadata,error,) {var (- tableMetadatas []*storepb.TableMetadata- extTableMetadatas []*storepb.ExternalTableMetadata- viewMetadatas []*storepb.ViewMetadata- mtViewMetadatas []*storepb.MaterializedViewMetadata+ tableMetadatas []*metadatapb.TableMetadata+ extTableMetadatas []*metadatapb.ExternalTableMetadata+ viewMetadatas []*metadatapb.ViewMetadata+ mtViewMetadatas []*metadatapb.MaterializedViewMetadata)// list tables' names.@@ -140,19 +140,19 @@ func (d *Driver) getTables(ctx context.Context, databaseName string) (// different processing way according to the type of the table.switch tableInfo.tableType {case "MATERIALIZED_VIEW":- mtViewMetadatas = append(mtViewMetadatas, &storepb.MaterializedViewMetadata{+ mtViewMetadatas = append(mtViewMetadatas, &metadatapb.MaterializedViewMetadata{Name: tableName,Definition: tableInfo.viewDef,Comment: tableInfo.comment,})case "VIRTUAL_VIEW":- viewMetadatas = append(viewMetadatas, &storepb.ViewMetadata{+ viewMetadatas = append(viewMetadatas, &metadatapb.ViewMetadata{Name: tableName,Definition: tableInfo.viewDef,Comment: tableInfo.comment,})case "EXTERNAL_TABLE":- extTableMetadatas = append(extTableMetadatas, &storepb.ExternalTableMetadata{+ extTableMetadatas = append(extTableMetadatas, &metadatapb.ExternalTableMetadata{Name: tableName,Columns: tableInfo.colMetadatas,})@@ -163,7 +163,7 @@ func (d *Driver) getTables(ctx context.Context, databaseName string) (slog.Debug("failed to get partitions", log.BBError(err))continue}- tableMetadatas = append(tableMetadatas, &storepb.TableMetadata{+ tableMetadatas = append(tableMetadatas, &metadatapb.TableMetadata{Engine: "HDFS",Comment: tableInfo.comment,Columns: tableInfo.colMetadatas,@@ -180,7 +180,7 @@ func (d *Driver) getTables(ctx context.Context, databaseName string) (return tableMetadatas, extTableMetadatas, viewMetadatas, mtViewMetadatas, nil}-func (d *Driver) getPartitions(ctx context.Context, databaseName, tableName string) ([]*storepb.TablePartitionMetadata, error) {+func (d *Driver) getPartitions(ctx context.Context, databaseName, tableName string) ([]*metadatapb.TablePartitionMetadata, error) {// partitions.partitionResult, err := d.queryStatementWithLimit(ctx, fmt.Sprintf("SHOW PARTITIONS `%s`.`%s`", databaseName, tableName), 0)if err != nil {@@ -190,12 +190,12 @@ func (d *Driver) getPartitions(ctx context.Context, databaseName, tableName striif partitionResult == nil {return nil, nil}- var partitions []*storepb.TablePartitionMetadata+ var partitions []*metadatapb.TablePartitionMetadatafor _, row := range partitionResult.Rows {if row == nil || len(row.Values) == 0 {return nil, errors.New("partitions result row has zero length")}- partitions = append(partitions, &storepb.TablePartitionMetadata{+ partitions = append(partitions, &metadatapb.TablePartitionMetadata{Name: row.Values[0].GetStringValue(),})}@@ -203,14 +203,14 @@ func (d *Driver) getPartitions(ctx context.Context, databaseName, tableName stri}// This function gets certain database info by name.-func (d *Driver) getDatabaseInfoByName(ctx context.Context, databaseName string) (*storepb.SchemaMetadata, error) {+func (d *Driver) getDatabaseInfoByName(ctx context.Context, databaseName string) (*metadatapb.SchemaMetadata, error) {// fetch table metadata.tableMetadata, extTabMetadata, viewMetadata, mtViewMetadata, err := d.getTables(ctx, databaseName)if err != nil {return nil, errors.Wrapf(err, "failed to get table metadata from database %s", databaseName)}- return &storepb.SchemaMetadata{+ return &metadatapb.SchemaMetadata{Name: databaseName,Tables: tableMetadata,ExternalTables: extTabMetadata,@@ -221,7 +221,7 @@ func (d *Driver) getDatabaseInfoByName(ctx context.Context, databaseName string)type TableInfo struct {tableType string- colMetadatas []*storepb.ColumnMetadata+ colMetadatas []*metadatapb.ColumnMetadatanumRows intviewDef stringtotalSize int@@ -273,7 +273,7 @@ func (d *Driver) getTableInfo(ctx context.Context, tableName string, databaseNamif colName != "" && dataType != "" {// Column metadata.position := len(tableInfo.colMetadatas) + 1- tableInfo.colMetadatas = append(tableInfo.colMetadatas, &storepb.ColumnMetadata{+ tableInfo.colMetadatas = append(tableInfo.colMetadatas, &metadatapb.ColumnMetadata{Name: colName,Type: dataType,Comment: comment,diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.goindex af29d50b6c..bbc0cdf4a8 100644--- a/backend/plugin/db/mongodb/mongodb.go+++ b/backend/plugin/db/mongodb/mongodb.go@@ -12,6 +12,7 @@ import ("time""github.com/bytebase/gomongo"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""go.mongodb.org/mongo-driver/v2/bson""go.mongodb.org/mongo-driver/v2/mongo"@@ -120,7 +121,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, opts db.ExecuteO}// Dump dumps the database.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/mongodb/sync.go b/backend/plugin/db/mongodb/sync.goindex 29cd1bfcf5..fcf0f20f8e 100644--- a/backend/plugin/db/mongodb/sync.go+++ b/backend/plugin/db/mongodb/sync.go@@ -7,6 +7,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""go.mongodb.org/mongo-driver/v2/bson""go.mongodb.org/mongo-driver/v2/mongo"@@ -52,13 +53,13 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)if err != nil {return nil, err}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatadatabaseNames, err := d.getNonSystemDatabaseList(ctx)if err != nil {return nil, err}for _, databaseName := range databaseNames {- databases = append(databases, &storepb.DatabaseSchemaMetadata{+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: databaseName,})}@@ -73,8 +74,8 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs the database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}@@ -174,7 +175,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, errors.Wrapf(err, "failed to get index schema of collection %s", collectionName)}- schemaMetadata.Tables = append(schemaMetadata.Tables, &storepb.TableMetadata{+ schemaMetadata.Tables = append(schemaMetadata.Tables, &metadatapb.TableMetadata{Name: collectionName,RowCount: count,DataSize: dataSize64,@@ -184,23 +185,23 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}for _, viewName := range viewNames {- schemaMetadata.Views = append(schemaMetadata.Views, &storepb.ViewMetadata{Name: viewName})+ schemaMetadata.Views = append(schemaMetadata.Views, &metadatapb.ViewMetadata{Name: viewName})}- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}, nil}// getIndexes returns all indexes schema of a collection.// https://www.mongodb.com/docs/manual/reference/command/listIndexes/#output-func getIndexes(ctx context.Context, collection *mongo.Collection) ([]*storepb.IndexMetadata, error) {+func getIndexes(ctx context.Context, collection *mongo.Collection) ([]*metadatapb.IndexMetadata, error) {indexCursor, err := collection.Indexes().List(ctx)if err != nil {return nil, errors.Wrap(err, "failed to list indexes")}- indexMap := make(map[string]*storepb.IndexMetadata)+ indexMap := make(map[string]*metadatapb.IndexMetadata)defer indexCursor.Close(ctx)for indexCursor.Next(ctx) {var indexInfo bson.M@@ -232,7 +233,7 @@ func getIndexes(ctx context.Context, collection *mongo.Collection) ([]*storepb.I}if _, ok := indexMap[indexName]; !ok {- indexMap[indexName] = &storepb.IndexMetadata{+ indexMap[indexName] = &metadatapb.IndexMetadata{Name: indexName,Unique: unique,}@@ -240,7 +241,7 @@ func getIndexes(ctx context.Context, collection *mongo.Collection) ([]*storepb.IindexMap[indexName].Expressions = append(indexMap[indexName].Expressions, string(expression))}- var indexes []*storepb.IndexMetadata+ var indexes []*metadatapb.IndexMetadatavar indexNames []stringfor name := range indexMap {indexNames = append(indexNames, name)diff --git a/backend/plugin/db/mssql/dump.go b/backend/plugin/db/mssql/dump.goindex f210e1527b..514aaa1e39 100644--- a/backend/plugin/db/mssql/dump.go+++ b/backend/plugin/db/mssql/dump.go@@ -4,6 +4,7 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,7 +12,7 @@ import ()// Dump dumps the database.-func (*Driver) Dump(_ context.Context, out io.Writer, metadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, metadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_MSSQL, schema.GetDefinitionContext{}, metadata)if err != nil {return errors.Wrap(err, "failed to get database definition")diff --git a/backend/plugin/db/mssql/sync.go b/backend/plugin/db/mssql/sync.goindex fad64adfeb..6eed03e54b 100644--- a/backend/plugin/db/mssql/sync.go+++ b/backend/plugin/db/mssql/sync.go@@ -7,9 +7,9 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/util")@@ -28,7 +28,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatarows, err := d.db.QueryContext(ctx, "SELECT name, collation_name FROM sys.databases WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb', 'rdscore')")if err != nil {return nil, err@@ -36,7 +36,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)defer rows.Close()for rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}var collation sql.NullStringif err := rows.Scan(&database.Name, &collation); err != nil {return nil, err@@ -57,7 +57,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {txn, err := d.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -117,11 +117,11 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,}for _, schemaName := range schemaNames {- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tableMap[schemaName],Views: viewMap[schemaName],@@ -159,7 +159,7 @@ func getSchemas(txn *sql.Tx) ([]string, error) {}// getTables gets all tables of a database.-func getTables(txn *sql.Tx, schemas []string, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.TableMetadata, error) {+func getTables(txn *sql.Tx, schemas []string, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.TableMetadata, error) {indexMap, err := getKeyAndIndexes(txn, schemas)if err != nil {return nil, errors.Wrapf(err, "failed to get indices")@@ -250,7 +250,7 @@ func getTables(txn *sql.Tx, schemas []string, columnMap map[db.TableKey][]*store}}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)query := `SELECTt.object_id,@@ -265,7 +265,7 @@ func getTables(txn *sql.Tx, schemas []string, columnMap map[db.TableKey][]*storedefer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var objectID intvar schemaName stringif err := rows.Scan(&objectID, &schemaName, &table.Name); err != nil {@@ -295,8 +295,8 @@ func getTables(txn *sql.Tx, schemas []string, columnMap map[db.TableKey][]*storereturn tableMap, nil}-func getChecks(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.CheckConstraintMetadata, error) {- checkMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)+func getChecks(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.CheckConstraintMetadata, error) {+ checkMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)// Get check constraint comments separatelycheckCommentsMap := make(map[int]string)@@ -381,7 +381,7 @@ func getChecks(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.CheckCcontinue}key := db.TableKey{Schema: obj.Schema, Table: obj.Table}- check := &storepb.CheckConstraintMetadata{+ check := &metadatapb.CheckConstraintMetadata{Name: checkName.String,Expression: definition.String,}@@ -416,8 +416,8 @@ func referentialAction(action int) string {}}-func getForeignKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {- fkMap := make(map[db.TableKey]map[string]*storepb.ForeignKeyMetadata)+func getForeignKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {+ fkMap := make(map[db.TableKey]map[string]*metadatapb.ForeignKeyMetadata)// Get foreign key comments separatelyfkCommentsMap := make(map[int]string)@@ -485,11 +485,11 @@ func getForeignKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.F}outerKey := db.TableKey{Schema: schemaName.String, Table: tableName.String}if _, ok := fkMap[outerKey]; !ok {- fkMap[outerKey] = make(map[string]*storepb.ForeignKeyMetadata)+ fkMap[outerKey] = make(map[string]*metadatapb.ForeignKeyMetadata)}if _, ok := fkMap[outerKey][fkName.String]; !ok {- fk := &storepb.ForeignKeyMetadata{+ fk := &metadatapb.ForeignKeyMetadata{Name: fkName.String,ReferencedSchema: referencedSchemaName.String,ReferencedTable: referencedTableName.String,@@ -522,7 +522,7 @@ func getForeignKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.F}// Aggregate the map to a slice.- result := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+ result := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)for k, m := range fkMap {var foreignkeyNames []stringfor _, v := range m {@@ -550,8 +550,8 @@ func quoteList(schemas []string) string {}// getTableColumns gets the columns of a table.-func getTableColumns(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getTableColumns(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)// Get column comments separatelycolumnCommentsMap := make(map[struct{ ObjectID, ColumnID int }]string)@@ -680,7 +680,7 @@ func getTableColumns(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.if !schemaName.Valid || !tableName.Valid || !columnName.Valid || !typeName.Valid {continue}- column := &storepb.ColumnMetadata{+ column := &metadatapb.ColumnMetadata{Name: columnName.String,}@@ -797,9 +797,9 @@ func getColumnType(definition, typeName sql.NullString, isComputed, isPersistedreturn buf.String(), nil}-func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMetadata, error) {+func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {// MSSQL doesn't support function-based indexes.- indexMap := make(map[db.TableKey]map[string]*storepb.IndexMetadata)+ indexMap := make(map[db.TableKey]map[string]*metadatapb.IndexMetadata)// Get index comments separatelyindexCommentsMap := make(map[struct{ ObjectID, IndexID int }]string)@@ -868,12 +868,12 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.Indexkey := db.TableKey{Schema: schemaName.String, Table: tableName.String}if _, ok := indexMap[key]; !ok {- indexMap[key] = make(map[string]*storepb.IndexMetadata)+ indexMap[key] = make(map[string]*metadatapb.IndexMetadata)}if _, ok := indexMap[key][indexName.String]; !ok {// This query excludes primary keys and unique constraints, which are// reported separately, so is_unique here means a CREATE UNIQUE INDEX.- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: indexName.String,Unique: isUnique.Valid && isUnique.Bool,Primary: false,@@ -883,13 +883,13 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.Indexindex.Type = typeDesc.String// If this is a spatial index, populate basic spatial configif typeDesc.String == "SPATIAL" {- index.SpatialConfig = &storepb.SpatialIndexConfig{+ index.SpatialConfig = &metadatapb.SpatialIndexConfig{Method: "SPATIAL",- Tessellation: &storepb.TessellationConfig{+ Tessellation: &metadatapb.TessellationConfig{Scheme: "UNKNOWN", // Will be updated by getSpatialIndexes if available},- Storage: &storepb.StorageConfig{},- Dimensional: &storepb.DimensionalConfig{+ Storage: &metadatapb.StorageConfig{},+ Dimensional: &metadatapb.DimensionalConfig{DataType: "GEOMETRY", // Default, will be updated if availableDimensions: 2,},@@ -916,12 +916,12 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.Indexreturn nil, err}- tableIndexes := make(map[db.TableKey][]*storepb.IndexMetadata)+ tableIndexes := make(map[db.TableKey][]*metadatapb.IndexMetadata)for k, m := range indexMap {for _, v := range m {tableIndexes[k] = append(tableIndexes[k], v)}- slices.SortFunc(tableIndexes[k], func(a, b *storepb.IndexMetadata) int {+ slices.SortFunc(tableIndexes[k], func(a, b *metadatapb.IndexMetadata) int {if a.Name < b.Name {return -1}@@ -938,7 +938,7 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexspatialIndexes, err := getSpatialIndexes(txn, schemas)if err != nil {// Ignore error - spatial indexes might have been found by regular index query- spatialIndexes = make(map[db.TableKey][]*storepb.IndexMetadata)+ spatialIndexes = make(map[db.TableKey][]*metadatapb.IndexMetadata)}// Merge spatial indexes with regular indexes@@ -947,11 +947,11 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.Indexfor k, spatialIdxs := range spatialIndexes {// Process table spatial indexesif _, ok := tableIndexes[k]; !ok {- tableIndexes[k] = make([]*storepb.IndexMetadata, 0)+ tableIndexes[k] = make([]*metadatapb.IndexMetadata, 0)}// Remove any spatial indexes from regular indexes first- var nonSpatialIndexes []*storepb.IndexMetadata+ var nonSpatialIndexes []*metadatapb.IndexMetadatafor _, idx := range tableIndexes[k] {if idx.Type != "SPATIAL" {nonSpatialIndexes = append(nonSpatialIndexes, idx)@@ -966,8 +966,8 @@ func getIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.Indexreturn tableIndexes, nil}-func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMetadata, error) {- indexMap := make(map[db.TableKey]map[string]*storepb.IndexMetadata)+func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {+ indexMap := make(map[db.TableKey]map[string]*metadatapb.IndexMetadata)// Get spatial index comments separatelyspatialCommentsMap := make(map[struct{ ObjectID, IndexID int }]string)@@ -1103,17 +1103,17 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepkey := db.TableKey{Schema: schemaName.String, Table: tableName.String}if _, ok := indexMap[key]; !ok {- indexMap[key] = make(map[string]*storepb.IndexMetadata)+ indexMap[key] = make(map[string]*metadatapb.IndexMetadata)}if _, ok := indexMap[key][indexName.String]; !ok {// Create new spatial index metadata- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: indexName.String,Type: "SPATIAL",Unique: false,Primary: false,- SpatialConfig: &storepb.SpatialIndexConfig{+ SpatialConfig: &metadatapb.SpatialIndexConfig{Method: "SPATIAL",},}@@ -1137,7 +1137,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep}// Configure tessellation with complete metadata- index.SpatialConfig.Tessellation = &storepb.TessellationConfig{}+ index.SpatialConfig.Tessellation = &metadatapb.TessellationConfig{}if tessellationScheme.Valid {index.SpatialConfig.Tessellation.Scheme = tessellationScheme.String@@ -1153,7 +1153,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep// Add bounding box (for GEOMETRY indexes or when explicitly provided)if tessData.BoundingBox[0] != 0 || tessData.BoundingBox[1] != 0 ||tessData.BoundingBox[2] != 0 || tessData.BoundingBox[3] != 0 {- index.SpatialConfig.Tessellation.BoundingBox = &storepb.BoundingBox{+ index.SpatialConfig.Tessellation.BoundingBox = &metadatapb.BoundingBox{Xmin: tessData.BoundingBox[0],Ymin: tessData.BoundingBox[1],Xmax: tessData.BoundingBox[2],@@ -1162,10 +1162,10 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep}// Add grid levels with proper descriptions- gridLevels := []*storepb.GridLevel{}+ gridLevels := []*metadatapb.GridLevel{}for i, level := range tessData.GridLevels {if level != "" {- gridLevels = append(gridLevels, &storepb.GridLevel{Level: int32(i + 1), Density: level})+ gridLevels = append(gridLevels, &metadatapb.GridLevel{Level: int32(i + 1), Density: level})}}index.SpatialConfig.Tessellation.GridLevels = gridLevels@@ -1178,7 +1178,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep}// Configure storage options - always create storage config- index.SpatialConfig.Storage = &storepb.StorageConfig{}+ index.SpatialConfig.Storage = &metadatapb.StorageConfig{}if fillFactor.Valid && fillFactor.Int32 > 0 {index.SpatialConfig.Storage.Fillfactor = fillFactor.Int32@@ -1197,7 +1197,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep}// Configure dimensional properties- index.SpatialConfig.Dimensional = &storepb.DimensionalConfig{+ index.SpatialConfig.Dimensional = &metadatapb.DimensionalConfig{DataType: dataType,Dimensions: 2, // SQL Server spatial indexes are always 2D}@@ -1218,7 +1218,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep}// Convert to slice format- tableIndexes := make(map[db.TableKey][]*storepb.IndexMetadata)+ tableIndexes := make(map[db.TableKey][]*metadatapb.IndexMetadata)for k, m := range indexMap {for _, v := range m {tableIndexes[k] = append(tableIndexes[k], v)@@ -1239,7 +1239,7 @@ func getSpatialIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storep// enhanceSpatialIndexesWithXMLPlan attempts to extract additional spatial index options// that are not available in system tables but might be visible in execution plans-func enhanceSpatialIndexesWithXMLPlan(txn *sql.Tx, spatialIndexes map[db.TableKey][]*storepb.IndexMetadata) error {+func enhanceSpatialIndexesWithXMLPlan(txn *sql.Tx, spatialIndexes map[db.TableKey][]*metadatapb.IndexMetadata) error {// This is a best-effort function, so we ignore errors// Collect all spatial indexes that need enhancementtype indexKey struct {@@ -1247,7 +1247,7 @@ func enhanceSpatialIndexesWithXMLPlan(txn *sql.Tx, spatialIndexes map[db.TableKetable stringindex string}- indexMap := make(map[indexKey]*storepb.IndexMetadata)+ indexMap := make(map[indexKey]*metadatapb.IndexMetadata)for tableKey, indexes := range spatialIndexes {for _, index := range indexes {@@ -1310,7 +1310,7 @@ func enhanceSpatialIndexesWithXMLPlan(txn *sql.Tx, spatialIndexes map[db.TableKe// If we don't have storage config yet, create a basic one// These properties give us hints about the index creation contextif (ansiNulls.Valid || quotedIdent.Valid) && index.SpatialConfig.Storage == nil {- index.SpatialConfig.Storage = &storepb.StorageConfig{}+ index.SpatialConfig.Storage = &metadatapb.StorageConfig{}// These are indirect indicators but better than nothingindex.SpatialConfig.Storage.AllowRowLocks = trueindex.SpatialConfig.Storage.AllowPageLocks = true@@ -1323,8 +1323,8 @@ func enhanceSpatialIndexesWithXMLPlan(txn *sql.Tx, spatialIndexes map[db.TableKereturn nil}-func getKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMetadata, error) {- indexMap := make(map[db.TableKey]map[string]*storepb.IndexMetadata)+func getKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {+ indexMap := make(map[db.TableKey]map[string]*metadatapb.IndexMetadata)dumpKeySQL := fmt.Sprintf(`SELECTs.name AS schema_name,@@ -1365,10 +1365,10 @@ func getKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMet}key := db.TableKey{Schema: schemaName.String, Table: tableName.String}if _, ok := indexMap[key]; !ok {- indexMap[key] = make(map[string]*storepb.IndexMetadata)+ indexMap[key] = make(map[string]*metadatapb.IndexMetadata)}if _, ok := indexMap[key][indexName.String]; !ok {- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: indexName.String,Unique: false,Primary: false,@@ -1401,12 +1401,12 @@ func getKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMetreturn nil, err}- tableIndexes := make(map[db.TableKey][]*storepb.IndexMetadata)+ tableIndexes := make(map[db.TableKey][]*metadatapb.IndexMetadata)for k, m := range indexMap {for _, v := range m {tableIndexes[k] = append(tableIndexes[k], v)}- slices.SortFunc(tableIndexes[k], func(a, b *storepb.IndexMetadata) int {+ slices.SortFunc(tableIndexes[k], func(a, b *metadatapb.IndexMetadata) int {if a.Name < b.Name {return -1}@@ -1420,7 +1420,7 @@ func getKeys(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMet}// getIndexes gets all indices of a database.-func getKeyAndIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb.IndexMetadata, error) {+func getKeyAndIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {keys, err := getKeys(txn, schemas)if err != nil {return nil, errors.Wrapf(err, "failed to get keys")@@ -1436,8 +1436,8 @@ func getKeyAndIndexes(txn *sql.Tx, schemas []string) (map[db.TableKey][]*storepb}// getViews gets all views of a database.-func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ViewMetadata, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ViewMetadata, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)// Get view comments separatelyviewCommentsMap := make(map[int]string)@@ -1482,7 +1482,7 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)}defer rows.Close()for rows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var schemaName stringvar objectID sql.NullInt32var definition sql.NullString@@ -1521,7 +1521,7 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)return viewMap, nil}-func getTriggers(txn *sql.Tx) (map[db.TableKey][]*storepb.TriggerMetadata, map[db.TableKey][]*storepb.TriggerMetadata, error) {+func getTriggers(txn *sql.Tx) (map[db.TableKey][]*metadatapb.TriggerMetadata, map[db.TableKey][]*metadatapb.TriggerMetadata, error) {// Get trigger comments separatelytriggerCommentsMap := make(map[int]string)commentsQuery := `@@ -1577,8 +1577,8 @@ JOIN sys.schemas AS ss ON so.schema_id = ss.schema_idWHERE st.is_disabled = 0 AND st.is_ms_shipped = 0 AND st.parent_id <> 0 AND so.type IN ('U', 'V')ORDER BY st.name;`- tableTriggers := make(map[db.TableKey][]*storepb.TriggerMetadata)- viewTriggers := make(map[db.TableKey][]*storepb.TriggerMetadata)+ tableTriggers := make(map[db.TableKey][]*metadatapb.TriggerMetadata)+ viewTriggers := make(map[db.TableKey][]*metadatapb.TriggerMetadata)rows, err := txn.Query(query)if err != nil {return nil, nil, err@@ -1599,7 +1599,7 @@ ORDER BY st.name;if parentType == "V" {m = viewTriggers}- trigger := &storepb.TriggerMetadata{+ trigger := &metadatapb.TriggerMetadata{Name: name,Event: events,Timing: timing,@@ -1621,7 +1621,7 @@ ORDER BY st.name;}// getSequences gets all sequences of a database.-func getSequences(txn *sql.Tx) (map[string][]*storepb.SequenceMetadata, error) {+func getSequences(txn *sql.Tx) (map[string][]*metadatapb.SequenceMetadata, error) {query := `SELECTs.name,@@ -1645,9 +1645,9 @@ func getSequences(txn *sql.Tx) (map[string][]*storepb.SequenceMetadata, error) {}defer rows.Close()- sequenceMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceMap := make(map[string][]*metadatapb.SequenceMetadata)for rows.Next() {- sequence := &storepb.SequenceMetadata{}+ sequence := &metadatapb.SequenceMetadata{}var schemaName stringvar comment sql.NullStringif err := rows.Scan(&schemaName, &sequence.Name, &sequence.DataType, &comment); err != nil {@@ -1665,8 +1665,8 @@ func getSequences(txn *sql.Tx) (map[string][]*storepb.SequenceMetadata, error) {return sequenceMap, nil}-func getProcedures(txn *sql.Tx) (map[string][]*storepb.ProcedureMetadata, error) {- procedureMap := make(map[string][]*storepb.ProcedureMetadata)+func getProcedures(txn *sql.Tx) (map[string][]*metadatapb.ProcedureMetadata, error) {+ procedureMap := make(map[string][]*metadatapb.ProcedureMetadata)query := `SELECT@@ -1692,7 +1692,7 @@ func getProcedures(txn *sql.Tx) (map[string][]*storepb.ProcedureMetadata, error)}defer rows.Close()for rows.Next() {- procedure := &storepb.ProcedureMetadata{}+ procedure := &metadatapb.ProcedureMetadata{}var schemaName stringvar definition sql.NullStringif err := rows.Scan(&schemaName, &procedure.Name, &definition); err != nil {@@ -1718,8 +1718,8 @@ func getProcedures(txn *sql.Tx) (map[string][]*storepb.ProcedureMetadata, error)return procedureMap, nil}-func getFunctions(txn *sql.Tx) (map[string][]*storepb.FunctionMetadata, error) {- funcMap := make(map[string][]*storepb.FunctionMetadata)+func getFunctions(txn *sql.Tx) (map[string][]*metadatapb.FunctionMetadata, error) {+ funcMap := make(map[string][]*metadatapb.FunctionMetadata)// The CAST(...) = 0 means the function is not a system function.query := `@@ -1751,7 +1751,7 @@ func getFunctions(txn *sql.Tx) (map[string][]*storepb.FunctionMetadata, error) {}defer rows.Close()for rows.Next() {- function := &storepb.FunctionMetadata{}+ function := &metadatapb.FunctionMetadata{}var schemaName stringvar definition, comment sql.NullStringif err := rows.Scan(&schemaName, &function.Name, &definition, &comment); err != nil {diff --git a/backend/plugin/db/mssql/sync_test.go b/backend/plugin/db/mssql/sync_test.goindex 0e04128e5d..3e16fc1531 100644--- a/backend/plugin/db/mssql/sync_test.go+++ b/backend/plugin/db/mssql/sync_test.go@@ -5,13 +5,13 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/google/go-cmp/cmp"_ "github.com/microsoft/go-mssqldb""github.com/stretchr/testify/require""google.golang.org/protobuf/testing/protocmp""github.com/bytebase/bytebase/backend/common/testcontainer"- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// TestSyncUniqueIndex covers which synced indexes carry Unique. SQL Server@@ -47,7 +47,7 @@ GOrequire.NoError(t, err)table := requireTable(t, metadata, "dbo", "index_kinds")- byName := make(map[string]*storepb.IndexMetadata)+ byName := make(map[string]*metadatapb.IndexMetadata)for _, index := range table.Indexes {byName[index.Name] = index}@@ -67,7 +67,7 @@ GO// The UNIQUE column constraint keeps arriving through the constraint query,// which is the only path that sets IsConstraint.- var columnConstraint *storepb.IndexMetadata+ var columnConstraint *metadatapb.IndexMetadatafor name, index := range byName {if index.IsConstraint && !index.Primary {require.Nilf(t, columnConstraint, "expected one unique constraint, also got %s", name)@@ -78,7 +78,7 @@ GOrequire.True(t, columnConstraint.Unique)require.Equal(t, []string{"code"}, columnConstraint.Expressions)- var primary *storepb.IndexMetadata+ var primary *metadatapb.IndexMetadatafor _, index := range byName {if index.Primary {primary = index@@ -107,7 +107,7 @@ func TestSyncSpatialIndex(t *testing.T) {testCases := []struct {name stringsetupSQL string- validate func(*testing.T, *storepb.DatabaseSchemaMetadata)+ validate func(*testing.T, *metadatapb.DatabaseSchemaMetadata)}{{name: "geometry_and_geography_indexes",@@ -167,11 +167,11 @@ WITH ();GO`,- validate: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ validate: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {table := requireTable(t, metadata, "geo", "locations")require.Len(t, table.Columns, 6)- columns := make(map[string]*storepb.ColumnMetadata)+ columns := make(map[string]*metadatapb.ColumnMetadata)for _, column := range table.Columns {columns[column.Name] = column}@@ -262,7 +262,7 @@ WITH ();GO`,- validate: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ validate: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {table := requireTable(t, metadata, "dbo", "spatial_edge_cases")require.Len(t, spatialIndexes(table), 4)@@ -329,7 +329,7 @@ GOCREATE NONCLUSTERED COLUMNSTORE INDEX idx_columnstore ON dbo.mixed_indexes(id, name, status);GO`,- validate: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ validate: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {table := requireTable(t, metadata, "dbo", "mixed_indexes")// Spatial indexes must not disturb how sync classifies the@@ -395,10 +395,10 @@ CREATE INDEX idx_area ON dbo.spatial_computed(area);CREATE INDEX idx_center ON dbo.spatial_computed(center_x, center_y);GO`,- validate: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ validate: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {table := requireTable(t, metadata, "dbo", "spatial_computed")- columns := make(map[string]*storepb.ColumnMetadata)+ columns := make(map[string]*metadatapb.ColumnMetadata)for _, column := range table.Columns {columns[column.Name] = column}@@ -495,8 +495,8 @@ GO// Keyed by name because sync assembles indexes out of a map, so their// order within a table is not itself part of the contract.- byName := func(metadata *storepb.DatabaseSchemaMetadata) map[string]*storepb.IndexMetadata {- indexes := make(map[string]*storepb.IndexMetadata)+ byName := func(metadata *metadatapb.DatabaseSchemaMetadata) map[string]*metadatapb.IndexMetadata {+ indexes := make(map[string]*metadatapb.IndexMetadata)for _, index := range spatialIndexes(requireTable(t, metadata, "spatial_test", "mixed_spatial")) {indexes[index.Name] = index}@@ -505,8 +505,8 @@ GOrequire.Empty(t, cmp.Diff(byName(first), byName(second), protocmp.Transform()))}-func spatialIndexes(table *storepb.TableMetadata) []*storepb.IndexMetadata {- var indexes []*storepb.IndexMetadata+func spatialIndexes(table *metadatapb.TableMetadata) []*metadatapb.IndexMetadata {+ var indexes []*metadatapb.IndexMetadatafor _, index := range table.Indexes {if index.Type == "SPATIAL" {indexes = append(indexes, index)@@ -518,10 +518,10 @@ func spatialIndexes(table *storepb.TableMetadata) []*storepb.IndexMetadata {// requireSpatialIndex asserts the properties every synced spatial index carries// and returns it for the case-specific configuration checks. dataType is// GEOMETRY or GEOGRAPHY; only GEOMETRY indexes carry a bounding box.-func requireSpatialIndex(t *testing.T, table *storepb.TableMetadata, name, column, dataType string) *storepb.IndexMetadata {+func requireSpatialIndex(t *testing.T, table *metadatapb.TableMetadata, name, column, dataType string) *metadatapb.IndexMetadata {t.Helper()- var index *storepb.IndexMetadata+ var index *metadatapb.IndexMetadatafor _, candidate := range table.Indexes {if candidate.Name == name {index = candidate@@ -551,7 +551,7 @@ func requireSpatialIndex(t *testing.T, table *storepb.TableMetadata, name, columreturn index}-func requireBoundingBox(t *testing.T, index *storepb.IndexMetadata, xmin, ymin, xmax, ymax float64) {+func requireBoundingBox(t *testing.T, index *metadatapb.IndexMetadata, xmin, ymin, xmax, ymax float64) {t.Helper()bbox := index.SpatialConfig.Tessellation.BoundingBox@@ -562,7 +562,7 @@ func requireBoundingBox(t *testing.T, index *storepb.IndexMetadata, xmin, ymin,require.Equal(t, ymax, bbox.Ymax)}-func requireGridLevels(t *testing.T, index *storepb.IndexMetadata, level1, level2, level3, level4 string) {+func requireGridLevels(t *testing.T, index *metadatapb.IndexMetadata, level1, level2, level3, level4 string) {t.Helper()densities := make(map[int32]string)diff --git a/backend/plugin/db/mssql/testutil_test.go b/backend/plugin/db/mssql/testutil_test.goindex dd120b2d6d..ecd46cdfa8 100644--- a/backend/plugin/db/mssql/testutil_test.go+++ b/backend/plugin/db/mssql/testutil_test.go@@ -6,6 +6,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/google/uuid""github.com/stretchr/testify/require"@@ -66,7 +67,7 @@ func executeBatches(ctx context.Context, t *testing.T, driver *Driver, script st}}-func requireTable(t *testing.T, metadata *storepb.DatabaseSchemaMetadata, schemaName, tableName string) *storepb.TableMetadata {+func requireTable(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata, schemaName, tableName string) *metadatapb.TableMetadata {t.Helper()for _, schema := range metadata.Schemas {diff --git a/backend/plugin/db/mysql/dump.go b/backend/plugin/db/mysql/dump.goindex 302a622c5b..42a7aebd61 100644--- a/backend/plugin/db/mysql/dump.go+++ b/backend/plugin/db/mysql/dump.go@@ -4,6 +4,7 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,7 +12,7 @@ import ()// Dump dumps the database.-func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_MYSQL, schema.GetDefinitionContext{PrintHeader: true,}, dbMetadata)diff --git a/backend/plugin/db/mysql/sync.go b/backend/plugin/db/mysql/sync.goindex f50b1d57b8..6fbef7422c 100644--- a/backend/plugin/db/mysql/sync.go+++ b/backend/plugin/db/mysql/sync.go@@ -14,6 +14,7 @@ import ("unicode""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata""golang.org/x/text/encoding/charmap""golang.org/x/text/transform"@@ -113,9 +114,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}defer rows.Close()- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name,&database.CharacterSet,@@ -187,8 +188,8 @@ func utf8ToISO88591(utf8Str string) (string, error) {}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}@@ -225,7 +226,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query index info.- indexMap := make(map[db.TableKey]map[string]*storepb.IndexMetadata)+ indexMap := make(map[db.TableKey]map[string]*metadatapb.IndexMetadata)indexQuery := `SELECTTABLE_NAME,@@ -307,10 +308,10 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadkey := db.TableKey{Schema: "", Table: tableName}if _, ok := indexMap[key]; !ok {- indexMap[key] = make(map[string]*storepb.IndexMetadata)+ indexMap[key] = make(map[string]*metadatapb.IndexMetadata)}if _, ok := indexMap[key][indexName]; !ok {- indexMap[key][indexName] = &storepb.IndexMetadata{+ indexMap[key][indexName] = &metadatapb.IndexMetadata{Name: indexName,Type: indexType,Unique: !nonUnique,@@ -333,7 +334,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad// 8.0.0–8.0.2 lack it, as do 5.7/5.6, MariaDB, OceanBase, and TiDB (which may report// an 8.x MySQL-compat version), so selecting it there would fail the whole sync —// they select NULL instead.- columnMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+ columnMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)sridSelect := "NULL"if atLeast803 && stockMySQL {sridSelect = "SRS_ID"@@ -381,7 +382,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer columnRows.Close()for columnRows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var tableName, nullable, extra, tp stringvar defaultStr sql.NullStringvar generationExpr []byte@@ -439,13 +440,13 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad// I have no idea why it does that. But we need to unescape it. -_-text = strings.ReplaceAll(text, `\'`, `'`)if extra != "" && strings.Contains(strings.ToUpper(extra), virtualGenerated) && len(generationExpr) != 0 {- column.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_VIRTUAL,+ column.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_VIRTUAL,Expression: text,}} else if extra != "" && strings.Contains(strings.ToUpper(extra), storedGenerated) && len(generationExpr) != 0 {- column.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ column.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: text,}}@@ -455,7 +456,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Check constraints info.- checkMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)+ checkMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)if atLeast8_0_16 {checkQuery := getCheckConstraintQuery(isMariaDB)checkRows, err := d.db.QueryContext(ctx, checkQuery, d.databaseName)@@ -464,7 +465,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer checkRows.Close()for checkRows.Next() {- check := &storepb.CheckConstraintMetadata{}+ check := &metadatapb.CheckConstraintMetadata{}var tableName stringif err := checkRows.Scan(&tableName,@@ -483,7 +484,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query view info.- viewMap := make(map[db.TableKey]*storepb.ViewMetadata)+ viewMap := make(map[db.TableKey]*metadatapb.ViewMetadata)viewQuery := `SELECTTABLE_NAME,@@ -496,7 +497,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer viewRows.Close()for viewRows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}if err := viewRows.Scan(&view.Name,&view.Definition,@@ -542,7 +543,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}- partitionTables := make(map[db.TableKey][]*storepb.TablePartitionMetadata)+ partitionTables := make(map[db.TableKey][]*metadatapb.TablePartitionMetadata)// Query partition info.if d.dbType == storepb.Engine_MYSQL {partitionTables, err = d.listPartitionTables(ctx, d.databaseName)@@ -614,7 +615,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadswitch tableType {case baseTableType:columns := columnMap[key]- tableMetadata := &storepb.TableMetadata{+ tableMetadata := &metadatapb.TableMetadata{Name: tableName,Columns: columns,ForeignKeys: foreignKeysMap[key],@@ -658,9 +659,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, util.FormatErrorWithQuery(err, tableQuery)}- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}// Query db info.databaseQuery := `@@ -682,7 +683,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn databaseMetadata, err}-func (d *Driver) getEventList(ctx context.Context, databaseName string) ([]*storepb.EventMetadata, error) {+func (d *Driver) getEventList(ctx context.Context, databaseName string) ([]*metadatapb.EventMetadata, error) {listEventsQuery := `SELECTEVENT_NAME,@@ -699,7 +700,7 @@ func (d *Driver) getEventList(ctx context.Context, databaseName string) ([]*storreturn nil, util.FormatErrorWithQuery(err, listEventsQuery)}defer eventRows.Close()- var events []*storepb.EventMetadata+ var events []*metadatapb.EventMetadatafor eventRows.Next() {var name, timeZone, sqlMode, charsetClient, collationConnection stringif err := eventRows.Scan(@@ -715,7 +716,7 @@ func (d *Driver) getEventList(ctx context.Context, databaseName string) ([]*storif err != nil {return nil, err}- event := &storepb.EventMetadata{+ event := &metadatapb.EventMetadata{Name: name,TimeZone: timeZone,Definition: eventDef,@@ -783,7 +784,7 @@ func (d *Driver) getCreateEventStmt(ctx context.Context, databaseName string, nareturn "", nil}-func (d *Driver) getTriggerList(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.TriggerMetadata, error) {+func (d *Driver) getTriggerList(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.TriggerMetadata, error) {// Prune to a single database on MariaDB: filter by EVENT_OBJECT_SCHEMA (the// trigger's table schema), not TRIGGER_SCHEMA, which scans every database's// table metadata. A trigger lives in its table's schema, so they are equivalent.@@ -806,7 +807,7 @@ func (d *Driver) getTriggerList(ctx context.Context, databaseName string) (map[dreturn nil, util.FormatErrorWithQuery(err, triggersQuery)}defer triggerRows.Close()- triggerMap := make(map[db.TableKey][]*storepb.TriggerMetadata)+ triggerMap := make(map[db.TableKey][]*metadatapb.TriggerMetadata)for triggerRows.Next() {var name, table, event, timing, statement, sqlMode, charsetClient, collationConnection stringif err := triggerRows.Scan(@@ -821,7 +822,7 @@ func (d *Driver) getTriggerList(ctx context.Context, databaseName string) (map[d); err != nil {return nil, err}- trigger := &storepb.TriggerMetadata{+ trigger := &metadatapb.TriggerMetadata{Name: name,Event: event,Timing: timing,@@ -840,7 +841,7 @@ func (d *Driver) getTriggerList(ctx context.Context, databaseName string) (map[dreturn triggerMap, nil}-func (d *Driver) syncRoutines(ctx context.Context, databaseName string) ([]*storepb.FunctionMetadata, []*storepb.ProcedureMetadata, error) {+func (d *Driver) syncRoutines(ctx context.Context, databaseName string) ([]*metadatapb.FunctionMetadata, []*metadatapb.ProcedureMetadata, error) {// Query functions and procedure info.routinesQuery := `SELECT@@ -861,8 +862,8 @@ func (d *Driver) syncRoutines(ctx context.Context, databaseName string) ([]*storreturn nil, nil, util.FormatErrorWithQuery(err, routinesQuery)}defer routineRows.Close()- var functions []*storepb.FunctionMetadata- var procedures []*storepb.ProcedureMetadata+ var functions []*metadatapb.FunctionMetadata+ var procedures []*metadatapb.ProcedureMetadatafor routineRows.Next() {var name, routineType, routineComment stringvar sqlMode, charsetClient, collationConnection, databaseCollation sql.NullString@@ -882,7 +883,7 @@ func (d *Driver) syncRoutines(ctx context.Context, databaseName string) ([]*storif err != nil {return nil, nil, err}- procedures = append(procedures, &storepb.ProcedureMetadata{+ procedures = append(procedures, &metadatapb.ProcedureMetadata{Name: name,Definition: procedureDef,SqlMode: sqlMode.String,@@ -896,7 +897,7 @@ func (d *Driver) syncRoutines(ctx context.Context, databaseName string) ([]*storif err != nil {return nil, nil, err}- functions = append(functions, &storepb.FunctionMetadata{+ functions = append(functions, &metadatapb.FunctionMetadata{Name: name,Definition: functionDef,SqlMode: sqlMode.String,@@ -1109,7 +1110,7 @@ const (binaryDefaultHexNotation)-func setColumnMetadataDefault(column *storepb.ColumnMetadata, defaultStr sql.NullString, nullableBool bool, extra string, binaryFormat binaryDefaultFormat) {+func setColumnMetadataDefault(column *metadatapb.ColumnMetadata, defaultStr sql.NullString, nullableBool bool, extra string, binaryFormat binaryDefaultFormat) {if defaultStr.Valid {// MySQL handles these defaults differently:// 1. CURRENT_TIMESTAMP functions - stored as function names, need QUOTE() unescaping only@@ -1330,7 +1331,7 @@ func getViewDefFromCreateView(createView string) (string, error) {return "", errors.Errorf("failed to match view definition, %s", createView)}-func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.TablePartitionMetadata, error) {+func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.TablePartitionMetadata, error) {const query string = `SELECTTABLE_NAME,@@ -1363,7 +1364,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (}partitionMap := make(map[partitionKey]int)- result := make(map[db.TableKey][]*storepb.TablePartitionMetadata)+ result := make(map[db.TableKey][]*metadatapb.TablePartitionMetadata)for rows.Next() {var tableName, partitionName, partitionMethod string@@ -1386,7 +1387,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (if _, ok := partitionMap[partitionKey]; !ok {// Partitiontp := convertToStorepbTablePartitionType(partitionMethod)- if tp == storepb.TablePartitionMetadata_TYPE_UNSPECIFIED {+ if tp == metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED {slog.Warn("unknown partition type", slog.String("partitionMethod", partitionMethod))continue}@@ -1401,12 +1402,12 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (value = partitionDescription.String}- partition := &storepb.TablePartitionMetadata{+ partition := &metadatapb.TablePartitionMetadata{Name: partitionName,Type: tp,Expression: expression,Value: value,- Subpartitions: []*storepb.TablePartitionMetadata{},+ Subpartitions: []*metadatapb.TablePartitionMetadata{},}partitionMap[partitionKey] = len(result[tableKey])result[tableKey] = append(result[tableKey], partition)@@ -1414,7 +1415,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (if subpartitionName.Valid {tp := convertToStorepbTablePartitionType(subpartitionMethod.String)- if tp == storepb.TablePartitionMetadata_TYPE_UNSPECIFIED {+ if tp == metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED {slog.Warn("unknown subpartition type", slog.String("subpartitionMethod", subpartitionMethod.String))continue}@@ -1424,12 +1425,12 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (expression = subpartitionExpression.String}- subPartition := &storepb.TablePartitionMetadata{+ subPartition := &metadatapb.TablePartitionMetadata{Name: subpartitionName.String,Type: tp,Expression: expression,Value: "",- Subpartitions: []*storepb.TablePartitionMetadata{},+ Subpartitions: []*metadatapb.TablePartitionMetadata{},}if idx, ok := partitionMap[partitionKey]; !ok {@@ -1499,30 +1500,30 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (return result, nil}-func convertToStorepbTablePartitionType(tp string) storepb.TablePartitionMetadata_Type {+func convertToStorepbTablePartitionType(tp string) metadatapb.TablePartitionMetadata_Type {switch strings.ToUpper(tp) {case "RANGE":- return storepb.TablePartitionMetadata_RANGE+ return metadatapb.TablePartitionMetadata_RANGEcase "RANGE COLUMNS":- return storepb.TablePartitionMetadata_RANGE_COLUMNS+ return metadatapb.TablePartitionMetadata_RANGE_COLUMNScase "LIST":- return storepb.TablePartitionMetadata_LIST+ return metadatapb.TablePartitionMetadata_LISTcase "LIST COLUMNS":- return storepb.TablePartitionMetadata_LIST_COLUMNS+ return metadatapb.TablePartitionMetadata_LIST_COLUMNScase "HASH":- return storepb.TablePartitionMetadata_HASH+ return metadatapb.TablePartitionMetadata_HASHcase "KEY":- return storepb.TablePartitionMetadata_KEY+ return metadatapb.TablePartitionMetadata_KEYcase "LINEAR HASH":- return storepb.TablePartitionMetadata_LINEAR_HASH+ return metadatapb.TablePartitionMetadata_LINEAR_HASHcase "LINEAR KEY":- return storepb.TablePartitionMetadata_LINEAR_KEY+ return metadatapb.TablePartitionMetadata_LINEAR_KEYdefault:- return storepb.TablePartitionMetadata_TYPE_UNSPECIFIED+ return metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED}}-func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {+func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {// Prune to a single database on MariaDB instead of opening every database's// table metadata (Error 1969 on large instances). REFERENTIAL_CONSTRAINTS prunes// on CONSTRAINT_SCHEMA; KEY_COLUMN_USAGE prunes only on TABLE_SCHEMA. A foreign@@ -1556,10 +1557,10 @@ func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (mareturn nil, util.FormatErrorWithQuery(err, fkQuery)}defer fkRows.Close()- fkMap := make(map[db.IndexKey]*storepb.ForeignKeyMetadata)+ fkMap := make(map[db.IndexKey]*metadatapb.ForeignKeyMetadata)for fkRows.Next() {var tableName string- var fk storepb.ForeignKeyMetadata+ var fk metadatapb.ForeignKeyMetadataif err := fkRows.Scan(&tableName,&fk.Name,@@ -1601,15 +1602,15 @@ func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (maif err := kcuQueryRows.Err(); err != nil {return nil, util.FormatErrorWithQuery(err, kcuQuery)}- unordered := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+ unordered := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)for key, fk := range fkMap {tableKey := db.TableKey{Schema: "", Table: key.Table}unordered[tableKey] = append(unordered[tableKey], fk)}- orderedResult := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+ orderedResult := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)for key, fks := range unordered {- slices.SortFunc(fks, func(x, y *storepb.ForeignKeyMetadata) int {+ slices.SortFunc(fks, func(x, y *metadatapb.ForeignKeyMetadata) int {if x.Name < y.Name {return -1} else if x.Name > y.Name {diff --git a/backend/plugin/db/mysql/sync_test.go b/backend/plugin/db/mysql/sync_test.goindex afc9ab0cc2..969d71f0d3 100644--- a/backend/plugin/db/mysql/sync_test.go+++ b/backend/plugin/db/mysql/sync_test.go@@ -5,9 +5,8 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")func TestSetColumnMetadataDefault(t *testing.T) {@@ -90,7 +89,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {// binaryFormat is how the server encodes binary-family defaults; zero value// (binaryDefaultVerbatim) matches the legacy MariaDB/OceanBase path.binaryFormat binaryDefaultFormat- want *storepb.ColumnMetadata+ want *metadatapb.ColumnMetadata}{// MySQL 8.0.{@@ -98,7 +97,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "auto_increment",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "AUTO_INCREMENT",},},@@ -107,7 +106,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -116,7 +115,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -125,7 +124,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "hello"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "hello",},},@@ -134,14 +133,14 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "age1",defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -150,7 +149,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -159,7 +158,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -168,7 +167,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -177,7 +176,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0.00"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0.00",},},@@ -186,7 +185,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -195,14 +194,14 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "time2",defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: false,extra: "DEFAULT_GENERATED",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -211,7 +210,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: false,extra: "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -221,7 +220,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: true,extra: "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -231,7 +230,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP(6)"},nullableBool: true,extra: "DEFAULT_GENERATED",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -240,7 +239,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP(6)"},nullableBool: true,extra: "DEFAULT_GENERATED",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -249,7 +248,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: true,extra: "DEFAULT_GENERATED",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -259,7 +258,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "auto_increment",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "AUTO_INCREMENT",},},@@ -268,7 +267,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -277,7 +276,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -286,7 +285,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "hello"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "hello",},},@@ -295,14 +294,14 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "age1",defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -311,7 +310,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -320,7 +319,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -329,7 +328,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -338,7 +337,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0.00"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0.00",},},@@ -347,7 +346,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -356,7 +355,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "time2",@@ -364,7 +363,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,// Different from 8.0, DEFAULT_GENERATED.extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -374,7 +373,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,// Different from 8.0, DEFAULT_GENERATED on update CURRENT_TIMESTAMP.extra: "on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -385,7 +384,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: true,// Different from 8.0, DEFAULT_GENERATED on update CURRENT_TIMESTAMP.extra: "on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -396,7 +395,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: true,// Different from 8.0, DEFAULT_GENERATED.extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -406,7 +405,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: true,// Different from 8.0, DEFAULT_GENERATED.extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -416,7 +415,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: true,// Different from 8.0, DEFAULT_GENERATED.extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -437,7 +436,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "binary(16)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "binary(16)",Default: "''",},@@ -449,7 +448,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "binary(16)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "binary(16)",Default: "'ab'",},@@ -461,7 +460,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'ab'",},@@ -473,7 +472,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "''",},@@ -485,7 +484,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "0xab",},@@ -497,7 +496,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: `'a\'b'`,},@@ -510,7 +509,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'0x6162'",},@@ -523,7 +522,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varchar(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varchar(24)",Default: "'0x6162'",},@@ -537,7 +536,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {extra: "DEFAULT_GENERATED",columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "(0x6162)",},@@ -550,7 +549,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {extra: "DEFAULT_GENERATED",columnType: "binary(16)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "binary(16)",Default: "(uuid_to_bin(uuid()))",},@@ -562,7 +561,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultHexNotation,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'zz'",},@@ -576,7 +575,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "binary(16)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "binary(16)",Default: "''",},@@ -588,7 +587,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "binary(16)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "binary(16)",Default: "'ab'",},@@ -600,7 +599,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'ab'",},@@ -612,7 +611,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "''",},@@ -625,7 +624,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(8)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(8)",Default: "0x6100",},@@ -637,7 +636,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: `'a\'b'`,},@@ -650,7 +649,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'0x6162'",},@@ -663,7 +662,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(20)",binaryFormat: binaryDefaultRawBytes,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(20)",Default: "'CURRENT_TIMESTAMP'",},@@ -676,7 +675,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {nullableBool: false,columnType: "varbinary(24)",binaryFormat: binaryDefaultVerbatim,- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Type: "varbinary(24)",Default: "'0x6162'",},@@ -685,7 +684,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {a := require.New(t)for _, tc := range tests {- column := &storepb.ColumnMetadata{Type: tc.columnType}+ column := &metadatapb.ColumnMetadata{Type: tc.columnType}setColumnMetadataDefault(column, tc.defaultStr, tc.nullableBool, tc.extra, tc.binaryFormat)a.Equal(tc.want, column, tc.name)}diff --git a/backend/plugin/db/oracle/dump.go b/backend/plugin/db/oracle/dump.goindex c8695eaa08..ca01d4378d 100644--- a/backend/plugin/db/oracle/dump.go+++ b/backend/plugin/db/oracle/dump.go@@ -4,12 +4,14 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")// Dump dumps the database.-func (*Driver) Dump(_ context.Context, out io.Writer, metadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, metadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_ORACLE, schema.GetDefinitionContext{}, metadata)if err != nil {return errdiff --git a/backend/plugin/db/oracle/sync.go b/backend/plugin/db/oracle/sync.goindex 766f4352a2..c9f5d40c6e 100644--- a/backend/plugin/db/oracle/sync.go+++ b/backend/plugin/db/oracle/sync.go@@ -9,10 +9,10 @@ import ("strings""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/util""github.com/bytebase/bytebase/backend/plugin/parser/plsql"@@ -58,9 +58,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)if err != nil {return nil, errors.Wrapf(err, "failed to get schemas from database %q", d.databaseName)}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor _, schema := range schemas {- databases = append(databases, &storepb.DatabaseSchemaMetadata{+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{// The driver can hand back raw non-UTF-8 bytes for dictionary// strings on non-UTF-8 charsets (e.g. ZHS16GBK values ending in a// truncated multi-byte character); proto string fields reject them@@ -81,7 +81,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {txn, err := d.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -130,12 +130,12 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,ServiceName: d.serviceName,LinkedDatabases: dbLinks,}- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: "",Tables: tableMap[d.databaseName],Views: viewMap[d.databaseName],@@ -154,7 +154,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn databaseMetadata, nil}-func getDBLinks(txn *sql.Tx) ([]*storepb.LinkedDatabaseMetadata, error) {+func getDBLinks(txn *sql.Tx) ([]*metadatapb.LinkedDatabaseMetadata, error) {query := `SELECT DB_LINK, HOST, USERNAMEFROM all_db_links@@ -166,9 +166,9 @@ func getDBLinks(txn *sql.Tx) ([]*storepb.LinkedDatabaseMetadata, error) {}defer rows.Close()- var result []*storepb.LinkedDatabaseMetadata+ var result []*metadatapb.LinkedDatabaseMetadatafor rows.Next() {- dbLink := &storepb.LinkedDatabaseMetadata{}+ dbLink := &metadatapb.LinkedDatabaseMetadata{}var name, host, username sql.NullStringif err := rows.Scan(&name, &host, &username); err != nil {return nil, err@@ -225,9 +225,9 @@ func getSchemas(txn *sql.Tx) ([]string, error) {return result, nil}-func getTriggers(txn *sql.Tx, schemaName string) (map[db.TableKey][]*storepb.TriggerMetadata, map[db.TableKey][]*storepb.TriggerMetadata, error) {- tableTriggerMap := make(map[db.TableKey][]*storepb.TriggerMetadata)- viewTriggerMap := make(map[db.TableKey][]*storepb.TriggerMetadata)+func getTriggers(txn *sql.Tx, schemaName string) (map[db.TableKey][]*metadatapb.TriggerMetadata, map[db.TableKey][]*metadatapb.TriggerMetadata, error) {+ tableTriggerMap := make(map[db.TableKey][]*metadatapb.TriggerMetadata)+ viewTriggerMap := make(map[db.TableKey][]*metadatapb.TriggerMetadata)// Get trigger commentstriggerCommentMap, err := getTriggerComments(txn, schemaName)@@ -257,7 +257,7 @@ func getTriggers(txn *sql.Tx, schemaName string) (map[db.TableKey][]*storepb.Tricontinue}key := db.TableKey{Schema: schemaName, Table: tableName.String}- trigger := &storepb.TriggerMetadata{+ trigger := &metadatapb.TriggerMetadata{Name: triggerName.String,Body: sanitizeOracleMetadataString(schemaName,@@ -301,7 +301,7 @@ func constructTriggerBody(description, triggerBody string) string {}// getTables gets all tables of a database.-func getTables(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*storepb.ColumnMetadata, triggerMap map[db.TableKey][]*storepb.TriggerMetadata) (map[string][]*storepb.TableMetadata, error) {+func getTables(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata, triggerMap map[db.TableKey][]*metadatapb.TriggerMetadata) (map[string][]*metadatapb.TableMetadata, error) {indexMap, checkConstraintMap, foreignKeyMap, err := getIndexesAndConstraints(txn, schemaName)if err != nil {return nil, errors.Wrapf(err, "failed to get indices")@@ -322,7 +322,7 @@ func getTables(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*storif err != nil {return nil, errors.Wrapf(err, "failed to get table comments")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)query := fmt.Sprintf(`SELECT OWNER, TABLE_NAME, NUM_ROWS@@ -341,7 +341,7 @@ func getTables(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*stordefer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var schemaName string// https://github.com/rana/ora/issues/57#issuecomment-179909837// NUMBER in Oracle can hold 38 decimal digits, so int64 is not enough with its 19 decimal digits.@@ -457,8 +457,8 @@ func getTableColumnComments(txn *sql.Tx, schemaName string) (map[db.ColumnKey]st}// getTableColumns gets the columns of a table.-func getTableColumns(txn *sql.Tx, schemaName string, version *plsql.Version) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getTableColumns(txn *sql.Tx, schemaName string, version *plsql.Version) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)// https://github.com/bytebase/bytebase/issues/6663// Invisible columns don't have column ID so that we need to filter out them.@@ -510,7 +510,7 @@ func getTableColumns(txn *sql.Tx, schemaName string, version *plsql.Version) (ma}defer rows.Close()for rows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var schemaName, tableName, nullable stringvar defaultStr, collation, defaultOnNull sql.NullStringvar dataLength, dataPrecision, dataScale sql.NullInt64@@ -635,9 +635,9 @@ func getOuterSchemaRColumns(txn *sql.Tx, outerRTableMap map[db.ConstraintKey]str}func getConstraints(txn *sql.Tx, schemaName string) (- map[db.TableKey][]*storepb.IndexMetadata,- map[db.TableKey][]*storepb.CheckConstraintMetadata,- map[db.TableKey][]*storepb.ForeignKeyMetadata,+ map[db.TableKey][]*metadatapb.IndexMetadata,+ map[db.TableKey][]*metadatapb.CheckConstraintMetadata,+ map[db.TableKey][]*metadatapb.ForeignKeyMetadata,map[db.IndexKey]bool,error,) {@@ -693,9 +693,9 @@ func getConstraints(txn *sql.Tx, schemaName string) (return nil, nil, nil, nil, util.FormatErrorWithQuery(err, queryConstraints)}defer constraintRows.Close()- indexMap := make(map[db.TableKey][]*storepb.IndexMetadata)- checkConstraintMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)- foreignKeyMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+ indexMap := make(map[db.TableKey][]*metadatapb.IndexMetadata)+ checkConstraintMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)+ foreignKeyMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)isConstraint := make(map[db.IndexKey]bool)outerRColumnMap := make(map[db.ConstraintKey][]string)outerRTableMap := make(map[db.ConstraintKey]string)@@ -709,7 +709,7 @@ func getConstraints(txn *sql.Tx, schemaName string) (constraintKey := db.ConstraintKey{Schema: schemaName, Constraint: constraintName}switch constraintType {case "P":- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: constraintName,Primary: true,Unique: true,@@ -721,7 +721,7 @@ func getConstraints(txn *sql.Tx, schemaName string) (indexMap[key] = append(indexMap[key], index)isConstraint[db.IndexKey{Schema: schemaName, Table: tableName, Index: constraintName}] = truecase "U":- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: constraintName,Unique: true,IsConstraint: true,@@ -736,7 +736,7 @@ func getConstraints(txn *sql.Tx, schemaName string) (if strings.HasPrefix(constraintName, "SYS_C") {continue}- constraint := &storepb.CheckConstraintMetadata{+ constraint := &metadatapb.CheckConstraintMetadata{Name: constraintName,}if searchCondition.Valid {@@ -745,7 +745,7 @@ func getConstraints(txn *sql.Tx, schemaName string) (checkConstraintMap[key] = append(checkConstraintMap[key], constraint)case "R":if rOwner.Valid && rConstraintName.Valid {- foreignKey := &storepb.ForeignKeyMetadata{+ foreignKey := &metadatapb.ForeignKeyMetadata{Name: constraintName,Columns: constraintColumnMap[constraintKey],}@@ -779,7 +779,7 @@ func getConstraints(txn *sql.Tx, schemaName string) (}// getIndexes gets all indices and constraints of a database.-func getIndexesAndConstraints(txn *sql.Tx, schemaName string) (map[db.TableKey][]*storepb.IndexMetadata, map[db.TableKey][]*storepb.CheckConstraintMetadata, map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {+func getIndexesAndConstraints(txn *sql.Tx, schemaName string) (map[db.TableKey][]*metadatapb.IndexMetadata, map[db.TableKey][]*metadatapb.CheckConstraintMetadata, map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {indexMap, checkConstraintMap, foreignKeyMap, isConstraint, err := getConstraints(txn, schemaName)if err != nil {return nil, nil, nil, errors.Wrapf(err, "failed to get constraints")@@ -870,7 +870,7 @@ func getIndexesAndConstraints(txn *sql.Tx, schemaName string) (map[db.TableKey][}defer rows.Close()for rows.Next() {- index := &storepb.IndexMetadata{}+ index := &metadatapb.IndexMetadata{}var schemaName, tableName, unique stringvar visibility sql.NullString// INDEX_TYPE is NORMAL, or FUNCTION-BASED NORMAL.@@ -966,8 +966,8 @@ func getIndexesAndConstraints(txn *sql.Tx, schemaName string) (map[db.TableKey][}// getViews gets all views of a database.-func getViews(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*storepb.ColumnMetadata, triggerMap map[db.TableKey][]*storepb.TriggerMetadata) (map[string][]*storepb.ViewMetadata, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getViews(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata, triggerMap map[db.TableKey][]*metadatapb.TriggerMetadata) (map[string][]*metadatapb.ViewMetadata, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)// Get view commentsviewCommentMap, err := getViewComments(txn, schemaName)@@ -989,7 +989,7 @@ func getViews(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*store}defer rows.Close()for rows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var schemaName stringif err := rows.Scan(&schemaName, &view.Name, &view.Definition); err != nil {return nil, err@@ -1031,8 +1031,8 @@ func getViews(txn *sql.Tx, schemaName string, columnMap map[db.TableKey][]*store}// getAllViewDependencies gets all view dependencies for a schema in a single query.-func getAllViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*storepb.DependencyColumn, error) {- dependenciesMap := make(map[db.TableKey][]*storepb.DependencyColumn)+func getAllViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*metadatapb.DependencyColumn, error) {+ dependenciesMap := make(map[db.TableKey][]*metadatapb.DependencyColumn)query := fmt.Sprintf(`SELECT@@ -1055,7 +1055,7 @@ func getAllViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*for rows.Next() {var viewName string- dependencyColumn := &storepb.DependencyColumn{}+ dependencyColumn := &metadatapb.DependencyColumn{}if err := rows.Scan(&viewName, &dependencyColumn.Schema, &dependencyColumn.Table, &dependencyColumn.Column); err != nil {return nil, err}@@ -1071,8 +1071,8 @@ func getAllViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*}// getAllMaterializedViewDependencies gets all materialized view dependencies for a schema in a single query.-func getAllMaterializedViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*storepb.DependencyColumn, error) {- dependenciesMap := make(map[db.TableKey][]*storepb.DependencyColumn)+func getAllMaterializedViewDependencies(txn *sql.Tx, schemaName string) (map[db.TableKey][]*metadatapb.DependencyColumn, error) {+ dependenciesMap := make(map[db.TableKey][]*metadatapb.DependencyColumn)query := fmt.Sprintf(`SELECT@@ -1095,7 +1095,7 @@ func getAllMaterializedViewDependencies(txn *sql.Tx, schemaName string) (map[db.for rows.Next() {var mviewName string- dependencyColumn := &storepb.DependencyColumn{}+ dependencyColumn := &metadatapb.DependencyColumn{}if err := rows.Scan(&mviewName, &dependencyColumn.Schema, &dependencyColumn.Table, &dependencyColumn.Column); err != nil {return nil, err}@@ -1111,8 +1111,8 @@ func getAllMaterializedViewDependencies(txn *sql.Tx, schemaName string) (map[db.}// getMaterializedViews gets all materialized views of a database.-func getMaterializedViews(txn *sql.Tx, schemaName string, _ map[db.TableKey][]*storepb.ColumnMetadata) ([]*storepb.MaterializedViewMetadata, error) {- var materializedViews []*storepb.MaterializedViewMetadata+func getMaterializedViews(txn *sql.Tx, schemaName string, _ map[db.TableKey][]*metadatapb.ColumnMetadata) ([]*metadatapb.MaterializedViewMetadata, error) {+ var materializedViews []*metadatapb.MaterializedViewMetadata// Get materialized view commentsmaterializedViewCommentMap, err := getMaterializedViewComments(txn, schemaName)@@ -1135,7 +1135,7 @@ func getMaterializedViews(txn *sql.Tx, schemaName string, _ map[db.TableKey][]*sdefer rows.Close()for rows.Next() {- materializedView := &storepb.MaterializedViewMetadata{}+ materializedView := &metadatapb.MaterializedViewMetadata{}var schemaName stringif err := rows.Scan(&schemaName, &materializedView.Name, &materializedView.Definition); err != nil {return nil, err@@ -1185,8 +1185,8 @@ func getMaterializedViews(txn *sql.Tx, schemaName string, _ map[db.TableKey][]*s}// getSequences gets all sequences of a database.-func getSequences(txn *sql.Tx, schemaName string) ([]*storepb.SequenceMetadata, error) {- var sequences []*storepb.SequenceMetadata+func getSequences(txn *sql.Tx, schemaName string) ([]*metadatapb.SequenceMetadata, error) {+ var sequences []*metadatapb.SequenceMetadata// Get sequence commentssequenceCommentMap, err := getSequenceComments(txn, schemaName)@@ -1207,7 +1207,7 @@ func getSequences(txn *sql.Tx, schemaName string) ([]*storepb.SequenceMetadata,defer rows.Close()for rows.Next() {- seq := &storepb.SequenceMetadata{}+ seq := &metadatapb.SequenceMetadata{}if err := rows.Scan(&seq.Name); err != nil {return nil, err}@@ -1231,10 +1231,10 @@ func getSequences(txn *sql.Tx, schemaName string) ([]*storepb.SequenceMetadata,return sequences, nil}-func getRoutines(txn *sql.Tx, schemaName string) ([]*storepb.FunctionMetadata, []*storepb.ProcedureMetadata, []*storepb.PackageMetadata, error) {- var functions []*storepb.FunctionMetadata- var procedures []*storepb.ProcedureMetadata- var packages []*storepb.PackageMetadata+func getRoutines(txn *sql.Tx, schemaName string) ([]*metadatapb.FunctionMetadata, []*metadatapb.ProcedureMetadata, []*metadatapb.PackageMetadata, error) {+ var functions []*metadatapb.FunctionMetadata+ var procedures []*metadatapb.ProcedureMetadata+ var packages []*metadatapb.PackageMetadata// Get function commentsfunctionCommentMap, err := getFunctionComments(txn, schemaName)@@ -1274,7 +1274,7 @@ func getRoutines(txn *sql.Tx, schemaName string) ([]*storepb.FunctionMetadata, [// Oracle may include a trailing C-string null terminator via the go-ora driver.switch currentType {case "FUNCTION":- function := &storepb.FunctionMetadata{+ function := &metadatapb.FunctionMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "FUNCTION", currentName, strings.Join(defText, "")),}@@ -1284,12 +1284,12 @@ func getRoutines(txn *sql.Tx, schemaName string) ([]*storepb.FunctionMetadata, [}functions = append(functions, function)case "PROCEDURE":- procedures = append(procedures, &storepb.ProcedureMetadata{+ procedures = append(procedures, &metadatapb.ProcedureMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "PROCEDURE", currentName, strings.Join(defText, "")),})case "PACKAGE":- packages = append(packages, &storepb.PackageMetadata{+ packages = append(packages, &metadatapb.PackageMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "PACKAGE", currentName, strings.Join(defText, "")),})@@ -1304,7 +1304,7 @@ func getRoutines(txn *sql.Tx, schemaName string) ([]*storepb.FunctionMetadata, [// Oracle may include a trailing C-string null terminator via the go-ora driver.switch currentType {case "FUNCTION":- function := &storepb.FunctionMetadata{+ function := &metadatapb.FunctionMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "FUNCTION", currentName, strings.Join(defText, "")),}@@ -1314,12 +1314,12 @@ func getRoutines(txn *sql.Tx, schemaName string) ([]*storepb.FunctionMetadata, [}functions = append(functions, function)case "PROCEDURE":- procedures = append(procedures, &storepb.ProcedureMetadata{+ procedures = append(procedures, &metadatapb.ProcedureMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "PROCEDURE", currentName, strings.Join(defText, "")),})case "PACKAGE":- packages = append(packages, &storepb.PackageMetadata{+ packages = append(packages, &metadatapb.PackageMetadata{Name: currentName,Definition: sanitizeOracleDefinition(schemaName, "PACKAGE", currentName, strings.Join(defText, "")),})diff --git a/backend/plugin/db/oracle/sync_test.go b/backend/plugin/db/oracle/sync_test.goindex a1824e9403..3ae371e116 100644--- a/backend/plugin/db/oracle/sync_test.go+++ b/backend/plugin/db/oracle/sync_test.go@@ -5,10 +5,9 @@ import ("log/slog""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""google.golang.org/protobuf/encoding/protojson"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// corruptedVietnamese simulates Vietnamese text encoded in Windows-1258@@ -23,12 +22,12 @@ func TestOracleDefinitionSanitizedUTF8MarshalSuccess(t *testing.T) {defer slog.SetDefault(originalLogger)corruptedDefinition := corruptedVietnamese + "\nSELECT 1 FROM DUAL"- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "TESTDB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "TEST_SCHEMA",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "V_CUSTOMER",Definition: sanitizeOracleDefinition(@@ -39,7 +38,7 @@ func TestOracleDefinitionSanitizedUTF8MarshalSuccess(t *testing.T) {),},},- MaterializedViews: []*storepb.MaterializedViewMetadata{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "MV_CUSTOMER",Definition: sanitizeOracleDefinition(@@ -50,7 +49,7 @@ func TestOracleDefinitionSanitizedUTF8MarshalSuccess(t *testing.T) {),},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "FN_VALIDATE",Definition: sanitizeOracleDefinition(@@ -61,7 +60,7 @@ func TestOracleDefinitionSanitizedUTF8MarshalSuccess(t *testing.T) {),},},- Procedures: []*storepb.ProcedureMetadata{+ Procedures: []*metadatapb.ProcedureMetadata{{Name: "PR_VALIDATE",Definition: sanitizeOracleDefinition(@@ -72,7 +71,7 @@ func TestOracleDefinitionSanitizedUTF8MarshalSuccess(t *testing.T) {),},},- Packages: []*storepb.PackageMetadata{+ Packages: []*metadatapb.PackageMetadata{{Name: "PKG_VALIDATE",Definition: sanitizeOracleDefinition(@@ -106,15 +105,15 @@ func TestOracleTriggerBodySanitizedUTF8MarshalSuccess(t *testing.T) {slog.SetDefault(slog.New(slog.NewTextHandler(&logBuf, &slog.HandlerOptions{Level: slog.LevelWarn})))defer slog.SetDefault(originalLogger)- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "TESTDB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "TEST_SCHEMA",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "CUSTOMER",- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "TRG_CUSTOMER",Body: sanitizeOracleMetadataString(diff --git a/backend/plugin/db/pg/dump.go b/backend/plugin/db/pg/dump.goindex ee7d3f27fc..c7ccff819f 100644--- a/backend/plugin/db/pg/dump.go+++ b/backend/plugin/db/pg/dump.go@@ -4,6 +4,7 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,7 +12,7 @@ import ()// Dump dumps the database.-func (*Driver) Dump(_ context.Context, out io.Writer, metadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, metadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_POSTGRES, schema.GetDefinitionContext{SkipBackupSchema: true,PrintHeader: true,diff --git a/backend/plugin/db/pg/pg.go b/backend/plugin/db/pg/pg.goindex 558228f186..42aadbd842 100644--- a/backend/plugin/db/pg/pg.go+++ b/backend/plugin/db/pg/pg.go@@ -14,6 +14,7 @@ import ("unicode""github.com/aws/aws-sdk-go-v2/feature/rds/auth"+ metadatapb "github.com/bytebase/omni/metadata""github.com/jackc/pgx/v5""github.com/jackc/pgx/v5/pgconn""github.com/jackc/pgx/v5/stdlib"@@ -315,8 +316,8 @@ func (d *Driver) GetDB() *sql.DB {}// getDatabases gets all databases of an instance.-func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetadata, error) {- var databases []*storepb.DatabaseSchemaMetadata+func (d *Driver) getDatabases(ctx context.Context) ([]*metadatapb.DatabaseSchemaMetadata, error) {+ var databases []*metadatapb.DatabaseSchemaMetadatarows, err := d.db.QueryContext(ctx, "SELECT datname, pg_encoding_to_char(encoding), datcollate, pg_catalog.pg_get_userbyid(datdba) as db_owner FROM pg_database;")if err != nil {return nil, err@@ -324,7 +325,7 @@ func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetdefer rows.Close()for rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name, &database.CharacterSet, &database.Collation, &database.Owner); err != nil {return nil, err}diff --git a/backend/plugin/db/pg/sync.go b/backend/plugin/db/pg/sync.goindex 2e1310f861..4fbfb720aa 100644--- a/backend/plugin/db/pg/sync.go+++ b/backend/plugin/db/pg/sync.go@@ -10,6 +10,7 @@ import ("strings""github.com/blang/semver/v4"+ metadatapb "github.com/bytebase/omni/metadata""github.com/lib/pq""github.com/pkg/errors"@@ -39,7 +40,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrap(err, "failed to get databases")}- var filteredDatabases []*storepb.DatabaseSchemaMetadata+ var filteredDatabases []*metadatapb.DatabaseSchemaMetadatafor _, database := range databases {// Skip all system databasesif pgparser.IsSystemDatabase(database.Name) {@@ -58,14 +59,14 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {// Query db infodatabases, err := d.getDatabases(ctx)if err != nil {return nil, errors.Wrap(err, "failed to get databases")}- var databaseMetadata *storepb.DatabaseSchemaMetadata+ var databaseMetadata *metadatapb.DatabaseSchemaMetadatafor _, database := range databases {if database.Name == d.databaseName {databaseMetadata = database@@ -141,7 +142,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, errors.Wrapf(err, "failed to get tables from database %q", d.databaseName)}- var tablePartitionMap map[db.TableKey][]*storepb.TablePartitionMetadata+ var tablePartitionMap map[db.TableKey][]*metadatapb.TablePartitionMetadataif isAtLeastPG10 {tablePartitionMap, err = getTablePartitions(txn, indexMap, checksMap, excludesMap)if err != nil {@@ -213,7 +214,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadkey := db.TableKey{Schema: schemaName, Table: view.Name}view.Rules = ruleMap[key]}- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tables,ExternalTables: externalTableMap[schemaName],@@ -234,7 +235,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn databaseMetadata, err}-func warpTablePartitions(m map[db.TableKey][]*storepb.TablePartitionMetadata, schemaName, tableName string) []*storepb.TablePartitionMetadata {+func warpTablePartitions(m map[db.TableKey][]*metadatapb.TablePartitionMetadata, schemaName, tableName string) []*metadatapb.TablePartitionMetadata {key := db.TableKey{Schema: schemaName, Table: tableName}if partitions, exists := m[key]; exists {defer delete(m, key)@@ -243,7 +244,7 @@ func warpTablePartitions(m map[db.TableKey][]*storepb.TablePartitionMetadata, sc}return partitions}- return []*storepb.TablePartitionMetadata{}+ return []*metadatapb.TablePartitionMetadata{}}var listExtensionDependQuery = `@@ -286,8 +287,8 @@ SELECT nsp.nspname, rel.relname, con.conname, pg_get_constraintdef(con.oid, trueAND nsp.nspname NOT LIKE 'pg_toast%%'ORDER BY nsp.nspname, rel.relname, con.conname`, pgparser.SystemSchemaWhereClause)-func getChecks(txn *sql.Tx) (map[db.TableKey][]*storepb.CheckConstraintMetadata, error) {- checksMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)+func getChecks(txn *sql.Tx) (map[db.TableKey][]*metadatapb.CheckConstraintMetadata, error) {+ checksMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)rows, err := txn.Query(listCheckQuery)if err != nil {return nil, err@@ -295,7 +296,7 @@ func getChecks(txn *sql.Tx) (map[db.TableKey][]*storepb.CheckConstraintMetadata,defer rows.Close()for rows.Next() {- var checkMetadata storepb.CheckConstraintMetadata+ var checkMetadata metadatapb.CheckConstraintMetadatavar schemaName, tableName, checkDefinition stringif err := rows.Scan(&schemaName, &tableName, &checkMetadata.Name, &checkDefinition); err != nil {return nil, err@@ -320,8 +321,8 @@ SELECT nsp.nspname, rel.relname, con.conname, pg_get_constraintdef(con.oid, trueAND nsp.nspname NOT LIKE 'pg_temp%%'AND nsp.nspname NOT LIKE 'pg_toast%%'`, pgparser.SystemSchemaWhereClause)-func getExcludeConstraints(txn *sql.Tx) (map[db.TableKey][]*storepb.ExcludeConstraintMetadata, error) {- excludesMap := make(map[db.TableKey][]*storepb.ExcludeConstraintMetadata)+func getExcludeConstraints(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ExcludeConstraintMetadata, error) {+ excludesMap := make(map[db.TableKey][]*metadatapb.ExcludeConstraintMetadata)rows, err := txn.Query(listExcludeConstraintsQuery)if err != nil {return nil, err@@ -329,7 +330,7 @@ func getExcludeConstraints(txn *sql.Tx) (map[db.TableKey][]*storepb.ExcludeConstdefer rows.Close()for rows.Next() {- var excludeMetadata storepb.ExcludeConstraintMetadata+ var excludeMetadata metadatapb.ExcludeConstraintMetadatavar schemaName, tableName stringif err := rows.Scan(&schemaName, &tableName, &excludeMetadata.Name, &excludeMetadata.Expression); err != nil {return nil, err@@ -371,8 +372,8 @@ WHEREAND c.conparentid = 0ORDER BY fk_schema, fk_table, fk_name;`, pgparser.SystemSchemaWhereClause)-func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {- foreignKeysMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {+ foreignKeysMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)rows, err := txn.Query(listForeignKeyQuery)if err != nil {return nil, err@@ -380,7 +381,7 @@ func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata,defer rows.Close()for rows.Next() {- var fkMetadata storepb.ForeignKeyMetadata+ var fkMetadata metadatapb.ForeignKeyMetadatavar fkSchema, fkTable, fkDefinition stringvar fkRefSchema sql.NullStringif err := rows.Scan(@@ -578,13 +579,13 @@ func getListTableQuery(isAtLeastPG10 bool) string {func getTables(txn *sql.Tx,isAtLeastPG10 bool,- columnMap map[db.TableKey][]*storepb.ColumnMetadata,- indexMap map[db.TableKey][]*storepb.IndexMetadata,- triggerMap map[db.TableKey][]*storepb.TriggerMetadata,- checksMap map[db.TableKey][]*storepb.CheckConstraintMetadata,- excludesMap map[db.TableKey][]*storepb.ExcludeConstraintMetadata,+ columnMap map[db.TableKey][]*metadatapb.ColumnMetadata,+ indexMap map[db.TableKey][]*metadatapb.IndexMetadata,+ triggerMap map[db.TableKey][]*metadatapb.TriggerMetadata,+ checksMap map[db.TableKey][]*metadatapb.CheckConstraintMetadata,+ excludesMap map[db.TableKey][]*metadatapb.ExcludeConstraintMetadata,extensionDepend map[int]bool,-) (map[string][]*storepb.TableMetadata, map[string][]*storepb.ExternalTableMetadata, map[int]*db.TableKeyWithColumns, error) {+) (map[string][]*metadatapb.TableMetadata, map[string][]*metadatapb.ExternalTableMetadata, map[int]*db.TableKeyWithColumns, error) {foreignKeysMap, err := getForeignKeys(txn)if err != nil {return nil, nil, nil, errors.Wrapf(err, "failed to get foreign keys")@@ -594,7 +595,7 @@ func getTables(return nil, nil, nil, errors.Wrapf(err, "failed to get foreign tables")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)tableOidMap := make(map[int]*db.TableKeyWithColumns)query := getListTableQuery(isAtLeastPG10)rows, err := txn.Query(query)@@ -604,7 +605,7 @@ func getTables(defer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var oid intvar schemaName stringvar dataSize, indexSize sql.NullInt64@@ -644,7 +645,7 @@ func getTables(return tableMap, foreignTablesMap, tableOidMap, nil}-func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ExternalTableMetadata, error) {+func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ExternalTableMetadata, error) {query := getListForeignTableQuery()rows, err := txn.Query(query)if err != nil {@@ -654,7 +655,7 @@ func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMe}defer rows.Close()- foreignTablesMap := make(map[string][]*storepb.ExternalTableMetadata)+ foreignTablesMap := make(map[string][]*metadatapb.ExternalTableMetadata)for rows.Next() {var schemaName, tableName, foreignServerCatalog, foreignServerName string@@ -662,7 +663,7 @@ func getForeignTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMeslog.Error("failed to scan foreign table: %v", log.BBError(err))return nil, nil}- externalTable := &storepb.ExternalTableMetadata{+ externalTable := &metadatapb.ExternalTableMetadata{Name: tableName,ExternalServerName: foreignServerName,ExternalDatabaseName: foreignServerCatalog,@@ -707,8 +708,8 @@ WHEREAND n.nspname NOT LIKE 'pg_toast%%'ORDER BY c.oid;`, pgparser.SystemSchemaWhereClause)-func getTablePartitions(txn *sql.Tx, indexMap map[db.TableKey][]*storepb.IndexMetadata, checksMap map[db.TableKey][]*storepb.CheckConstraintMetadata, excludesMap map[db.TableKey][]*storepb.ExcludeConstraintMetadata) (map[db.TableKey][]*storepb.TablePartitionMetadata, error) {- result := make(map[db.TableKey][]*storepb.TablePartitionMetadata)+func getTablePartitions(txn *sql.Tx, indexMap map[db.TableKey][]*metadatapb.IndexMetadata, checksMap map[db.TableKey][]*metadatapb.CheckConstraintMetadata, excludesMap map[db.TableKey][]*metadatapb.ExcludeConstraintMetadata) (map[db.TableKey][]*metadatapb.TablePartitionMetadata, error) {+ result := make(map[db.TableKey][]*metadatapb.TablePartitionMetadata)rows, err := txn.Query(listTablePartitionQuery)if err != nil {return nil, err@@ -725,7 +726,7 @@ func getTablePartitions(txn *sql.Tx, indexMap map[db.TableKey][]*storepb.IndexMe}key := db.TableKey{Schema: schemaName, Table: tableName}inhKey := db.TableKey{Schema: inhSchemaName, Table: inhTableName}- metadata := &storepb.TablePartitionMetadata{+ metadata := &metadatapb.TablePartitionMetadata{Name: tableName,Expression: partKeyDef,Value: relPartBound,@@ -735,11 +736,11 @@ func getTablePartitions(txn *sql.Tx, indexMap map[db.TableKey][]*storepb.IndexMe}switch strings.ToLower(partitionType) {case "l":- metadata.Type = storepb.TablePartitionMetadata_LIST+ metadata.Type = metadatapb.TablePartitionMetadata_LISTcase "r":- metadata.Type = storepb.TablePartitionMetadata_RANGE+ metadata.Type = metadatapb.TablePartitionMetadata_RANGEcase "h":- metadata.Type = storepb.TablePartitionMetadata_HASH+ metadata.Type = metadatapb.TablePartitionMetadata_HASHdefault:return nil, errors.Errorf("invalid partition type %q", partitionType)}@@ -867,15 +868,15 @@ ORDER BY nc.nspname, c.relname, a.attnum;`, columnDefault, pgparser.SystemSchema}// getTableColumns gets the columns of a table.-func getTableColumns(txn *sql.Tx, isAtLeastPG12 bool) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getTableColumns(txn *sql.Tx, isAtLeastPG12 bool) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)rows, err := txn.Query(getListColumnQuery(isAtLeastPG12))if err != nil {return nil, err}defer rows.Close()for rows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var schemaName, tableName, nullable stringvar characterMaxLength, numericPrecision, numericScale, datetimePrecision, defaultStr, collation, udtSchema, udtName, identityGeneration, comment sql.NullStringif err := rows.Scan(&schemaName, &tableName, &column.Name, &column.Type, &characterMaxLength, &numericPrecision, &numericScale, &datetimePrecision, &column.Position, &defaultStr, &nullable, &collation, &udtSchema, &udtName, &identityGeneration, &comment); err != nil {@@ -941,9 +942,9 @@ func getTableColumns(txn *sql.Tx, isAtLeastPG12 bool) (map[db.TableKey][]*storepif identityGeneration.Valid {switch strings.ToUpper(identityGeneration.String) {case "ALWAYS":- column.IdentityGeneration = storepb.ColumnMetadata_ALWAYS+ column.IdentityGeneration = metadatapb.ColumnMetadata_ALWAYScase "BY DEFAULT":- column.IdentityGeneration = storepb.ColumnMetadata_BY_DEFAULT+ column.IdentityGeneration = metadatapb.ColumnMetadata_BY_DEFAULTdefault:// Keep the default value}@@ -969,8 +970,8 @@ WHERE m.schemaname NOT IN (%s)AND m.schemaname NOT LIKE 'pg_toast%%'ORDER BY m.schemaname, m.matviewname;`, pgparser.SystemSchemaWhereClause)-func getMaterializedViews(txn *sql.Tx, indexMap map[db.TableKey][]*storepb.IndexMetadata, triggerMap map[db.TableKey][]*storepb.TriggerMetadata, extensionDepend map[int]bool) (map[string][]*storepb.MaterializedViewMetadata, map[int]*db.TableKey, error) {- matviewMap := make(map[string][]*storepb.MaterializedViewMetadata)+func getMaterializedViews(txn *sql.Tx, indexMap map[db.TableKey][]*metadatapb.IndexMetadata, triggerMap map[db.TableKey][]*metadatapb.TriggerMetadata, extensionDepend map[int]bool) (map[string][]*metadatapb.MaterializedViewMetadata, map[int]*db.TableKey, error) {+ matviewMap := make(map[string][]*metadatapb.MaterializedViewMetadata)materializedViewOidMap := make(map[int]*db.TableKey)rows, err := txn.Query(listMaterializedViewQuery)@@ -979,7 +980,7 @@ func getMaterializedViews(txn *sql.Tx, indexMap map[db.TableKey][]*storepb.Index}defer rows.Close()for rows.Next() {- matview := &storepb.MaterializedViewMetadata{}+ matview := &metadatapb.MaterializedViewMetadata{}var oid intvar schemaName stringvar def, comment sql.NullString@@ -1037,8 +1038,8 @@ WHERE v.schemaname NOT IN (%s)ORDER BY v.schemaname, v.viewname;`, pgparser.SystemSchemaWhereClause)// getViews gets all views of a database.-func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata, triggerMap map[db.TableKey][]*storepb.TriggerMetadata, extensionDepend map[int]bool) (map[string][]*storepb.ViewMetadata, map[int]*db.TableKey, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata, triggerMap map[db.TableKey][]*metadatapb.TriggerMetadata, extensionDepend map[int]bool) (map[string][]*metadatapb.ViewMetadata, map[int]*db.TableKey, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)viewOidMap := make(map[int]*db.TableKey)rows, err := txn.Query(listViewQuery)@@ -1047,7 +1048,7 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata,}defer rows.Close()for rows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var oid intvar schemaName stringvar def, comment sql.NullString@@ -1097,8 +1098,8 @@ func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata,}// getViewDependencies gets the dependencies of a view.-func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.DependencyColumn, error) {- var result []*storepb.DependencyColumn+func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*metadatapb.DependencyColumn, error) {+ var result []*metadatapb.DependencyColumnquery := fmt.Sprintf(`SELECT source_ns.nspname as source_schema,@@ -1127,7 +1128,7 @@ func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.D}defer rows.Close()for rows.Next() {- dependencyColumn := &storepb.DependencyColumn{}+ dependencyColumn := &metadatapb.DependencyColumn{}if err := rows.Scan(&dependencyColumn.Schema, &dependencyColumn.Table, &dependencyColumn.Column); err != nil {return nil, err}@@ -1140,8 +1141,8 @@ func getViewDependencies(txn *sql.Tx, schemaName, viewName string) ([]*storepb.D}// getRules gets all rules for tables and views in a database.-func getRules(txn *sql.Tx) (map[db.TableKey][]*storepb.RuleMetadata, error) {- ruleMap := make(map[db.TableKey][]*storepb.RuleMetadata)+func getRules(txn *sql.Tx) (map[db.TableKey][]*metadatapb.RuleMetadata, error) {+ ruleMap := make(map[db.TableKey][]*metadatapb.RuleMetadata)// Use CTE to avoid calling pg_get_ruledef multiple times per row.// Extract condition from definition using string functions instead of pg_get_expr,@@ -1196,7 +1197,7 @@ func getRules(txn *sql.Tx) (map[db.TableKey][]*storepb.RuleMetadata, error) {defer rows.Close()for rows.Next() {- rule := &storepb.RuleMetadata{}+ rule := &metadatapb.RuleMetadata{}var schemaName, tableName stringvar condition sql.NullString@@ -1234,8 +1235,8 @@ func getRules(txn *sql.Tx) (map[db.TableKey][]*storepb.RuleMetadata, error) {}// getExtensions gets all extensions of a database.-func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {- var extensions []*storepb.ExtensionMetadata+func getExtensions(txn *sql.Tx) ([]*metadatapb.ExtensionMetadata, error) {+ var extensions []*metadatapb.ExtensionMetadataquery := `SELECT e.extname, e.extversion, n.nspname, c.description@@ -1250,7 +1251,7 @@ func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {}defer rows.Close()for rows.Next() {- e := &storepb.ExtensionMetadata{}+ e := &metadatapb.ExtensionMetadata{}var description sql.NullStringif err := rows.Scan(&e.Name, &e.Version, &e.Schema, &description); err != nil {return nil, err@@ -1267,7 +1268,7 @@ func getExtensions(txn *sql.Tx) ([]*storepb.ExtensionMetadata, error) {return extensions, nil}-func getEnumTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*storepb.EnumTypeMetadata, error) {+func getEnumTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*metadatapb.EnumTypeMetadata, error) {query := `SELECTpt.oid,@@ -1288,7 +1289,7 @@ func getEnumTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*stor}defer rows.Close()- enumTypes := make(map[string][]*storepb.EnumTypeMetadata)+ enumTypes := make(map[string][]*metadatapb.EnumTypeMetadata)currentEnumSchema := ""currentEnumNmae := ""currentEnumComment := ""@@ -1304,7 +1305,7 @@ func getEnumTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*storif currentEnumSchema != schemaName || currentEnumNmae != enumName {if currentEnumSchema != "" {- enumTypes[currentEnumSchema] = append(enumTypes[currentEnumSchema], &storepb.EnumTypeMetadata{+ enumTypes[currentEnumSchema] = append(enumTypes[currentEnumSchema], &metadatapb.EnumTypeMetadata{Name: currentEnumNmae,Values: currentEnumValues,Comment: currentEnumComment,@@ -1328,7 +1329,7 @@ func getEnumTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*stor}if currentEnumSchema != "" {- enumTypes[currentEnumSchema] = append(enumTypes[currentEnumSchema], &storepb.EnumTypeMetadata{+ enumTypes[currentEnumSchema] = append(enumTypes[currentEnumSchema], &metadatapb.EnumTypeMetadata{Name: currentEnumNmae,Values: currentEnumValues,Comment: currentEnumComment,@@ -1379,15 +1380,15 @@ const listCompositeTypeQuery = `AND pn.nspname NOT LIKE 'pg_toast%'ORDER BY pn.nspname, pt.typname, a.attnum;`-func getCompositeTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*storepb.CompositeTypeMetadata, error) {+func getCompositeTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]*metadatapb.CompositeTypeMetadata, error) {rows, err := txn.Query(listCompositeTypeQuery)if err != nil {return nil, err}defer rows.Close()- compositeTypes := make(map[string][]*storepb.CompositeTypeMetadata)- var current *storepb.CompositeTypeMetadata+ compositeTypes := make(map[string][]*metadatapb.CompositeTypeMetadata)+ var current *metadatapb.CompositeTypeMetadatacurrentSchema := ""for rows.Next() {var typeOid, classOid int@@ -1401,7 +1402,7 @@ func getCompositeTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]}if current == nil || currentSchema != schemaName || current.Name != typeName {- current = &storepb.CompositeTypeMetadata{+ current = &metadatapb.CompositeTypeMetadata{Name: typeName,Comment: typeComment.String,SkipDump: extensionDepend[typeOid] || extensionDepend[classOid],@@ -1414,7 +1415,7 @@ func getCompositeTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]if !attributeName.Valid {continue}- current.Attributes = append(current.Attributes, &storepb.CompositeTypeAttribute{+ current.Attributes = append(current.Attributes, &metadatapb.CompositeTypeAttribute{Name: attributeName.String,Type: attributeType.String,Collation: attributeCollation.String,@@ -1429,7 +1430,7 @@ func getCompositeTypes(txn *sql.Tx, extensionDepend map[int]bool) (map[string][]}// getSequences gets all sequences of a database.-func getSequences(txn *sql.Tx, tableOidMap map[int]*db.TableKeyWithColumns, extensionDepend map[int]bool) (map[string][]*storepb.SequenceMetadata, error) {+func getSequences(txn *sql.Tx, tableOidMap map[int]*db.TableKeyWithColumns, extensionDepend map[int]bool) (map[string][]*metadatapb.SequenceMetadata, error) {sequenceOwnerMap, err := getSequenceOwners(txn)if err != nil {return nil, errors.Wrapf(err, "failed to get sequence owners")@@ -1461,7 +1462,7 @@ func getSequences(txn *sql.Tx, tableOidMap map[int]*db.TableKeyWithColumns, extereturn nil, err}defer rows.Close()- sequenceMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceMap := make(map[string][]*metadatapb.SequenceMetadata)for rows.Next() {var oid intvar schemaName, sequenceName, dataType string@@ -1484,7 +1485,7 @@ func getSequences(txn *sql.Tx, tableOidMap map[int]*db.TableKeyWithColumns, exteif comment.Valid {sequenceComment = comment.String}- sequence := &storepb.SequenceMetadata{+ sequence := &metadatapb.SequenceMetadata{Name: sequenceName,DataType: dataType,Start: strconv.FormatInt(startValue, 10),@@ -1554,7 +1555,7 @@ func getSequenceOwners(txn *sql.Tx) (map[int]ColumnOidKey, error) {return sequenceOwnerMap, nil}-func getTriggers(txn *sql.Tx, extensionDepend map[int]bool) (map[db.TableKey][]*storepb.TriggerMetadata, error) {+func getTriggers(txn *sql.Tx, extensionDepend map[int]bool) (map[db.TableKey][]*metadatapb.TriggerMetadata, error) {query := `SELECTpt.oid,@@ -1574,9 +1575,9 @@ func getTriggers(txn *sql.Tx, extensionDepend map[int]bool) (map[db.TableKey][]*}defer rows.Close()- triggersMap := make(map[db.TableKey][]*storepb.TriggerMetadata)+ triggersMap := make(map[db.TableKey][]*metadatapb.TriggerMetadata)for rows.Next() {- trigger := &storepb.TriggerMetadata{}+ trigger := &metadatapb.TriggerMetadata{}var oid intvar schemaName, tableName stringvar comment sql.NullString@@ -1599,7 +1600,7 @@ func getTriggers(txn *sql.Tx, extensionDepend map[int]bool) (map[db.TableKey][]*return triggersMap, nil}-func getEventTriggers(txn *sql.Tx, extensionDepend map[int]bool) ([]*storepb.EventTriggerMetadata, error) {+func getEventTriggers(txn *sql.Tx, extensionDepend map[int]bool) ([]*metadatapb.EventTriggerMetadata, error) {query := `SELECTet.oid,@@ -1621,7 +1622,7 @@ func getEventTriggers(txn *sql.Tx, extensionDepend map[int]bool) ([]*storepb.Eve}defer rows.Close()- var eventTriggers []*storepb.EventTriggerMetadata+ var eventTriggers []*metadatapb.EventTriggerMetadatafor rows.Next() {var oid intvar name, eventType, functionSchema, functionName, enabled string@@ -1633,7 +1634,7 @@ func getEventTriggers(txn *sql.Tx, extensionDepend map[int]bool) ([]*storepb.Evereturn nil, err}- eventTrigger := &storepb.EventTriggerMetadata{+ eventTrigger := &metadatapb.EventTriggerMetadata{Name: name,Event: eventType,Tags: []string(tags),@@ -1664,7 +1665,7 @@ func getEventTriggers(txn *sql.Tx, extensionDepend map[int]bool) ([]*storepb.Eve}// buildEventTriggerDefinition constructs the CREATE EVENT TRIGGER statement from metadata.-func buildEventTriggerDefinition(et *storepb.EventTriggerMetadata) string {+func buildEventTriggerDefinition(et *metadatapb.EventTriggerMetadata) string {var buf strings.Builderbuf.WriteString("CREATE EVENT TRIGGER ")fmt.Fprintf(&buf, "%q", et.Name)@@ -1774,8 +1775,8 @@ func parseIndexOptions(optionsStr string, keyCount int) ([]bool, []bool) {}// getIndexes gets all indices of a database.-func getIndexes(txn *sql.Tx, indexInheritanceMap map[db.IndexKey]*db.IndexKey) (map[db.TableKey][]*storepb.IndexMetadata, error) {- indexMap := make(map[db.TableKey][]*storepb.IndexMetadata)+func getIndexes(txn *sql.Tx, indexInheritanceMap map[db.IndexKey]*db.IndexKey) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {+ indexMap := make(map[db.TableKey][]*metadatapb.IndexMetadata)rows, err := txn.Query(listIndexQuery)if err != nil {@@ -1783,7 +1784,7 @@ func getIndexes(txn *sql.Tx, indexInheritanceMap map[db.IndexKey]*db.IndexKey) (}defer rows.Close()for rows.Next() {- index := &storepb.IndexMetadata{}+ index := &metadatapb.IndexMetadata{}var schemaName, tableName, indexMethod, indexDefinition stringvar isUnique, isPrimary, isConstraint boolvar keyExpressions pq.StringArray@@ -1918,8 +1919,8 @@ func getFunctions(tableOidMap map[int]*db.TableKeyWithColumns,viewOidMap, materializedViewOidMap map[int]*db.TableKey,extensionDepend map[int]bool,-) (map[string][]*storepb.FunctionMetadata, error) {- functionMap := make(map[string][]*storepb.FunctionMetadata)+) (map[string][]*metadatapb.FunctionMetadata, error) {+ functionMap := make(map[string][]*metadatapb.FunctionMetadata)rows, err := txn.Query(listFunctionQuery)if err != nil {@@ -1927,7 +1928,7 @@ func getFunctions(}defer rows.Close()for rows.Next() {- function := &storepb.FunctionMetadata{}+ function := &metadatapb.FunctionMetadata{}var oid intvar schemaName, arguments stringvar comment sql.NullString@@ -1948,17 +1949,17 @@ func getFunctions(function.Signature = fmt.Sprintf("%s(%s)", function.Name, arguments)for _, tableOid := range functionDependencyTables[oid] {if table, ok := tableOidMap[tableOid]; ok {- function.DependencyTables = append(function.DependencyTables, &storepb.DependencyTable{+ function.DependencyTables = append(function.DependencyTables, &metadatapb.DependencyTable{Schema: table.Schema,Table: table.Table,})} else if view, ok := viewOidMap[tableOid]; ok {- function.DependencyTables = append(function.DependencyTables, &storepb.DependencyTable{+ function.DependencyTables = append(function.DependencyTables, &metadatapb.DependencyTable{Schema: view.Schema,Table: view.Table,})} else if matview, ok := materializedViewOidMap[tableOid]; ok {- function.DependencyTables = append(function.DependencyTables, &storepb.DependencyTable{+ function.DependencyTables = append(function.DependencyTables, &metadatapb.DependencyTable{Schema: matview.Schema,Table: matview.Table,})diff --git a/backend/plugin/db/pg/sync_test.go b/backend/plugin/db/pg/sync_test.goindex 8b975de850..af50a0bd26 100644--- a/backend/plugin/db/pg/sync_test.go+++ b/backend/plugin/db/pg/sync_test.go@@ -8,6 +8,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""github.com/bytebase/bytebase/backend/common/testcontainer"@@ -325,7 +326,7 @@ CREATE INDEX idx_secret_name ON restricted.secret_table (name);metadata, err := pgDriver.SyncDBSchema(ctx)require.NoError(t, err)- var secretTable *storepb.TableMetadata+ var secretTable *metadatapb.TableMetadatafor _, schema := range metadata.Schemas {if schema.Name != "restricted" {continue@@ -456,7 +457,7 @@ COMMENT ON TABLE test_defaults IS 'Test table for column default schema qualificrequire.NotNil(t, metadata)// Find our test table- var testTable *storepb.TableMetadata+ var testTable *metadatapb.TableMetadatafor _, schema := range metadata.Schemas {if schema.Name == "public" {for _, table := range schema.Tables {@@ -470,7 +471,7 @@ COMMENT ON TABLE test_defaults IS 'Test table for column default schema qualificrequire.NotNil(t, testTable, "test_defaults table should be found")// Create a map for easier column lookup- columnMap := make(map[string]*storepb.ColumnMetadata)+ columnMap := make(map[string]*metadatapb.ColumnMetadata)for _, col := range testTable.Columns {columnMap[col.Name] = col}@@ -644,7 +645,7 @@ CREATE TABLE critical_test (require.NoError(t, err)// Find the test table- var testTable *storepb.TableMetadata+ var testTable *metadatapb.TableMetadatafor _, schema := range metadata.Schemas {if schema.Name == "public" {for _, table := range schema.Tables {@@ -658,7 +659,7 @@ CREATE TABLE critical_test (require.NotNil(t, testTable)// Verify cross-schema qualification- columnMap := make(map[string]*storepb.ColumnMetadata)+ columnMap := make(map[string]*metadatapb.ColumnMetadata)for _, col := range testTable.Columns {columnMap[col.Name] = col}@@ -746,9 +747,9 @@ CREATE TYPE coll_qualified AS (v text COLLATE locale.mycoll);metadata, err := pgDriver.SyncDBSchema(ctx)require.NoError(t, err)- compositesBySchema := make(map[string]map[string]*storepb.CompositeTypeMetadata)+ compositesBySchema := make(map[string]map[string]*metadatapb.CompositeTypeMetadata)for _, schemaMeta := range metadata.Schemas {- m := make(map[string]*storepb.CompositeTypeMetadata)+ m := make(map[string]*metadatapb.CompositeTypeMetadata)for _, composite := range schemaMeta.CompositeTypes {m[composite.Name] = composite}@@ -913,7 +914,7 @@ func TestSyncForeignTablesWithoutTablePrivilege(t *testing.T) {metadata, err := pgDriver.SyncDBSchema(ctx)require.NoError(t, err)- var fdwSchema *storepb.SchemaMetadata+ var fdwSchema *metadatapb.SchemaMetadatafor _, schema := range metadata.Schemas {if schema.Name == "fdw_schema" {fdwSchema = schemadiff --git a/backend/plugin/db/redis/redis.go b/backend/plugin/db/redis/redis.goindex e99fb113b5..05509d3f0f 100644--- a/backend/plugin/db/redis/redis.go+++ b/backend/plugin/db/redis/redis.go@@ -11,6 +11,7 @@ import ("strings""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/google/shlex""github.com/pkg/errors""github.com/redis/go-redis/v9"@@ -210,7 +211,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, opts db.ExecuteO// Dump and restore// Dump the database, if dbName is empty, then dump all databases.// Redis is schemaless, we don't support dump Redis data currently.-func (*Driver) Dump(_ context.Context, _ io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, _ io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/redis/sync.go b/backend/plugin/db/redis/sync.goindex db23508e26..49fa94efbb 100644--- a/backend/plugin/db/redis/sync.go+++ b/backend/plugin/db/redis/sync.go@@ -6,9 +6,9 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")@@ -27,9 +27,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)if err != nil {return nil, errors.Wrap(err, "failed to get databases")}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor _, n := range databaseNumbers {- databases = append(databases, &storepb.DatabaseSchemaMetadata{+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: strconv.Itoa(n),})}@@ -39,8 +39,8 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(context.Context) (*storepb.DatabaseSchemaMetadata, error) {- return &storepb.DatabaseSchemaMetadata{Name: d.databaseName}, nil+func (d *Driver) SyncDBSchema(context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ return &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName}, nil}func (d *Driver) getVersion(ctx context.Context) (string, error) {diff --git a/backend/plugin/db/redshift/dump.go b/backend/plugin/db/redshift/dump.goindex 4148e38df2..f57fda5050 100644--- a/backend/plugin/db/redshift/dump.go+++ b/backend/plugin/db/redshift/dump.go@@ -5,10 +5,10 @@ import ("context""io"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// Dump dumps the database to the writer. But not implemented yet.-func (*Driver) Dump(context.Context, io.Writer, *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(context.Context, io.Writer, *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/plugin/db/redshift/sync.go b/backend/plugin/db/redshift/sync.goindex 4ff896cb9c..bcda5d8fbc 100644--- a/backend/plugin/db/redshift/sync.go+++ b/backend/plugin/db/redshift/sync.go@@ -9,6 +9,7 @@ import ("regexp""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -33,7 +34,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrap(err, "failed to get databases")}- var filteredDatabases []*storepb.DatabaseSchemaMetadata+ var filteredDatabases []*metadatapb.DatabaseSchemaMetadatafor _, database := range databases {// Skip all system databasesif _, ok := excludedDatabaseList[database.Name]; ok {@@ -52,14 +53,14 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {// Query db infodatabases, err := d.getDatabases(ctx)if err != nil {return nil, errors.Wrap(err, "failed to get databases")}- var databaseMetadata *storepb.DatabaseSchemaMetadata+ var databaseMetadata *metadatapb.DatabaseSchemaMetadatafor _, database := range databases {if database.Name == d.databaseName {databaseMetadata = database@@ -80,8 +81,8 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadif err != nil {return nil, errors.Wrapf(err, "failed to get schemas from database %q", d.databaseName)}- var tableMap map[string][]*storepb.TableMetadata- var viewMap map[string][]*storepb.ViewMetadata+ var tableMap map[string][]*metadatapb.TableMetadata+ var viewMap map[string][]*metadatapb.ViewMetadataif d.datashare {tableMap, err = d.getDatashareTables(txn)if err != nil {@@ -105,7 +106,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, err}for _, schemaName := range schemaList {- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tableMap[schemaName],Views: viewMap[schemaName],@@ -115,7 +116,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn databaseMetadata, err}-func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {+func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {query := `SELECTn.nspname AS fk_schema,@@ -139,7 +140,7 @@ func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata,AND c.contype = 'f'ORDER BY fk_schema, fk_table, fk_name;`- foreignKeysMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+ foreignKeysMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)rows, err := txn.Query(query)if err != nil {return nil, err@@ -147,7 +148,7 @@ func getForeignKeys(txn *sql.Tx) (map[db.TableKey][]*storepb.ForeignKeyMetadata,defer rows.Close()for rows.Next() {- var fkMetadata storepb.ForeignKeyMetadata+ var fkMetadata metadatapb.ForeignKeyMetadatavar fkSchema, fkTable, fkDefinition stringif err := rows.Scan(&fkSchema,@@ -283,7 +284,7 @@ func (d *Driver) getSchemas(txn *sql.Tx) ([]string, error) {}// getTables gets all tables of a database.-func getTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.TableMetadata, error) {+func getTables(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.TableMetadata, error) {indexMap, err := getIndexes(txn)if err != nil {return nil, errors.Wrapf(err, "failed to get indices")@@ -293,7 +294,7 @@ func getTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)return nil, errors.Wrapf(err, "failed to get foreign keys")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)query := `SELECTptbl.schemaname,@@ -313,7 +314,7 @@ func getTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)defer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var schemaName stringvar comment sql.NullStringif err := rows.Scan(&schemaName, &table.Name, &table.DataSize, &table.IndexSize, &table.RowCount, &comment); err != nil {@@ -337,8 +338,8 @@ func getTables(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata)}// getTableColumns gets the columns of a table.-func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)query := `SELECT@@ -366,7 +367,7 @@ func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, er}defer rows.Close()for rows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var schemaName, tableName, nullable stringvar characterMaxLength, defaultStr, collation, udtSchema, udtName, comment sql.NullStringif err := rows.Scan(&schemaName, &tableName, &column.Name, &column.Type, &characterMaxLength, &column.Position, &defaultStr, &nullable, &collation, &udtSchema, &udtName, &comment); err != nil {@@ -411,13 +412,13 @@ func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, er}// getDatashareTables gets all tables of a datashare database.-func (d *Driver) getDatashareTables(txn *sql.Tx) (map[string][]*storepb.TableMetadata, error) {+func (d *Driver) getDatashareTables(txn *sql.Tx) (map[string][]*metadatapb.TableMetadata, error) {columnMap, err := d.getDatashareTableColumns(txn)if err != nil {return nil, errors.Wrap(err, "failed to get table columns")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)// table_typequery := `@@ -433,7 +434,7 @@ func (d *Driver) getDatashareTables(txn *sql.Tx) (map[string][]*storepb.TableMetdefer rows.Close()for rows.Next() {- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}var schemaName stringif err := rows.Scan(&schemaName, &table.Name); err != nil {return nil, err@@ -451,8 +452,8 @@ func (d *Driver) getDatashareTables(txn *sql.Tx) (map[string][]*storepb.TableMet}// getDatashareTableColumns gets the columns of tables in datashare database.-func (d *Driver) getDatashareTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func (d *Driver) getDatashareTableColumns(txn *sql.Tx) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)query := `SELECT@@ -472,7 +473,7 @@ func (d *Driver) getDatashareTableColumns(txn *sql.Tx) (map[db.TableKey][]*store}defer rows.Close()for rows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var schemaName, tableName, nullable stringvar defaultStr sql.NullStringvar varcharMaxLength sql.NullInt32@@ -503,8 +504,8 @@ func (d *Driver) getDatashareTableColumns(txn *sql.Tx) (map[db.TableKey][]*store}// getViews gets all views of a database.-func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ViewMetadata, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getViews(txn *sql.Tx, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ViewMetadata, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)query := `SELECT@@ -523,7 +524,7 @@ ORDER BY pgv.schemaname, pgv.viewname;`}defer rows.Close()for rows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var schemaName stringvar def, comment sql.NullStringif err := rows.Scan(&schemaName, &view.Name, &def, &comment); err != nil {@@ -551,8 +552,8 @@ ORDER BY pgv.schemaname, pgv.viewname;`}// getIndexes gets all indices of a database.-func getIndexes(txn *sql.Tx) (map[db.TableKey][]*storepb.IndexMetadata, error) {- indexMap := make(map[db.TableKey][]*storepb.IndexMetadata)+func getIndexes(txn *sql.Tx) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {+ indexMap := make(map[db.TableKey][]*metadatapb.IndexMetadata)// Use generate_series to mimic PostgreSQL's generate_subscripts for getting column expressions// Combined with pg_get_indexdef to get accurate column expressions@@ -594,7 +595,7 @@ func getIndexes(txn *sql.Tx) (map[db.TableKey][]*storepb.IndexMetadata, error) {table stringindex string}- indexData := make(map[indexKey]*storepb.IndexMetadata)+ indexData := make(map[indexKey]*metadatapb.IndexMetadata)indexColumns := make(map[indexKey][]string)for rows.Next() {@@ -613,7 +614,7 @@ func getIndexes(txn *sql.Tx) (map[db.TableKey][]*storepb.IndexMetadata, error) {// Create index metadata on first encounterif _, exists := indexData[key]; !exists {- indexData[key] = &storepb.IndexMetadata{+ indexData[key] = &metadatapb.IndexMetadata{Name: indexName,Definition: indexDef,Type: getIndexMethodType(indexDef),@@ -721,7 +722,7 @@ func buildRedshiftVersionString(redshiftVersion, postgresVersion string) string}// getDatabases gets all databases of an instance.-func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) getDatabases(ctx context.Context) ([]*metadatapb.DatabaseSchemaMetadata, error) {consumerDatabases := make(map[string]bool)dsRows, err := d.db.QueryContext(ctx, `SELECT consumer_database FROM SVV_DATASHARES WHERE share_type = 'INBOUND';@@ -742,7 +743,7 @@ func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetreturn nil, err}- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatarows, err := d.db.QueryContext(ctx, `SELECT datname,pg_encoding_to_char(encoding)@@ -754,7 +755,7 @@ func (d *Driver) getDatabases(ctx context.Context) ([]*storepb.DatabaseSchemaMetdefer rows.Close()for rows.Next() {- database := storepb.DatabaseSchemaMetadata{}+ database := metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name, &database.CharacterSet); err != nil {return nil, err}diff --git a/backend/plugin/db/snowflake/dump.go b/backend/plugin/db/snowflake/dump.goindex 29a24c9923..d38b0e0f2b 100644--- a/backend/plugin/db/snowflake/dump.go+++ b/backend/plugin/db/snowflake/dump.go@@ -7,12 +7,13 @@ import ("io""strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata"+"github.com/bytebase/bytebase/backend/plugin/db/util")// Dump dumps database.-func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {txn, err := d.db.BeginTx(ctx, &sql.TxOptions{})if err != nil {return errdiff --git a/backend/plugin/db/snowflake/sync.go b/backend/plugin/db/snowflake/sync.goindex fba94183ce..650b373843 100644--- a/backend/plugin/db/snowflake/sync.go+++ b/backend/plugin/db/snowflake/sync.go@@ -8,6 +8,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -40,9 +41,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, err}- var databaseMetadataSlice []*storepb.DatabaseSchemaMetadata+ var databaseMetadataSlice []*metadatapb.DatabaseSchemaMetadatafor _, database := range databases {- databaseMetadataSlice = append(databaseMetadataSlice, &storepb.DatabaseSchemaMetadata{Name: database})+ databaseMetadataSlice = append(databaseMetadataSlice, &metadatapb.DatabaseSchemaMetadata{Name: database})}return &db.InstanceMetadata{@@ -55,14 +56,14 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {// Query db infodatabases, err := d.getDatabases(ctx)if err != nil {return nil, err}- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,}found := false@@ -94,7 +95,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}for _, schemaName := range schemaList {- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tableMap[schemaName],Views: viewMap[schemaName],@@ -146,8 +147,8 @@ func (d *Driver) getSchemaList(ctx context.Context, database string) ([]string,// Key: normalized schema name//// Value: stream list in the schema.-func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[string][]*storepb.StreamMetadata, error) {- streamMap := make(map[string][]*storepb.StreamMetadata)+func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[string][]*metadatapb.StreamMetadata, error) {+ streamMap := make(map[string][]*metadatapb.StreamMetadata)streamQuery := fmt.Sprintf(`SHOW STREAMS IN DATABASE "%s";`, database)streamMetaRows, err := d.db.QueryContext(ctx, streamQuery)@@ -206,22 +207,22 @@ func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[striif err := streamMetaRows.Scan(cols...); err != nil {return nil, err}- storePbStreamType := storepb.StreamMetadata_TYPE_UNSPECIFIED+ storePbStreamType := metadatapb.StreamMetadata_TYPE_UNSPECIFIEDif tp == "DELTA" {- storePbStreamType = storepb.StreamMetadata_TYPE_DELTA+ storePbStreamType = metadatapb.StreamMetadata_TYPE_DELTA}- storePbMode := storepb.StreamMetadata_MODE_UNSPECIFIED+ storePbMode := metadatapb.StreamMetadata_MODE_UNSPECIFIEDswitch mode {case "DEFAULT":- storePbMode = storepb.StreamMetadata_MODE_DEFAULT+ storePbMode = metadatapb.StreamMetadata_MODE_DEFAULTcase "APPEND_ONLY":- storePbMode = storepb.StreamMetadata_MODE_APPEND_ONLY+ storePbMode = metadatapb.StreamMetadata_MODE_APPEND_ONLYcase "INSERT_ONLY":- storePbMode = storepb.StreamMetadata_MODE_INSERT_ONLY+ storePbMode = metadatapb.StreamMetadata_MODE_INSERT_ONLYdefault:// Keep as MODE_UNSPECIFIED for unknown modes}- streamMetadata := &storepb.StreamMetadata{+ streamMetadata := &metadatapb.StreamMetadata{Name: streamName,TableName: tableName,Owner: owner,@@ -248,7 +249,7 @@ func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[stri}for _, streamList := range streamMap {- slices.SortFunc(streamList, func(i, j *storepb.StreamMetadata) int {+ slices.SortFunc(streamList, func(i, j *metadatapb.StreamMetadata) int {if i.Name < j.Name {return -1}@@ -281,8 +282,8 @@ func (a *ArrayString) Scan(src any) error {// Key: normalized schema name//// Value: stream list in the schema.-func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[string][]*storepb.TaskMetadata, error) {- taskMap := make(map[string][]*storepb.TaskMetadata)+func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[string][]*metadatapb.TaskMetadata, error) {+ taskMap := make(map[string][]*metadatapb.TaskMetadata)taskQuery := fmt.Sprintf(`SHOW TASKS IN DATABASE "%s";`, database)streamMetaRows, err := d.db.QueryContext(ctx, taskQuery)@@ -346,12 +347,12 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[stringif err := streamMetaRows.Scan(cols...); err != nil {return nil, err}- storePbState := storepb.TaskMetadata_STATE_UNSPECIFIED+ storePbState := metadatapb.TaskMetadata_STATE_UNSPECIFIEDswitch state {case "started":- storePbState = storepb.TaskMetadata_STATE_STARTED+ storePbState = metadatapb.TaskMetadata_STATE_STARTEDcase "suspended":- storePbState = storepb.TaskMetadata_STATE_SUSPENDED+ storePbState = metadatapb.TaskMetadata_STATE_SUSPENDEDdefault:// Keep as STATE_UNSPECIFIED for unknown states}@@ -365,7 +366,7 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[stringif nullWarehouse.Valid {warehouse = nullWarehouse.String}- taskMetadata := &storepb.TaskMetadata{+ taskMetadata := &metadatapb.TaskMetadata{Name: taskName,Id: taskID,Owner: owner,@@ -394,7 +395,7 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[string}for _, taskList := range taskMap {- slices.SortFunc(taskList, func(i, j *storepb.TaskMetadata) int {+ slices.SortFunc(taskList, func(i, j *metadatapb.TaskMetadata) int {if i.Name < j.Name {return -1}@@ -407,8 +408,8 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[stringreturn taskMap, nil}-func (d *Driver) getTableSchema(ctx context.Context, database string) (map[string][]*storepb.TableMetadata, map[string][]*storepb.ViewMetadata, error) {- tableMap, viewMap := make(map[string][]*storepb.TableMetadata), make(map[string][]*storepb.ViewMetadata)+func (d *Driver) getTableSchema(ctx context.Context, database string) (map[string][]*metadatapb.TableMetadata, map[string][]*metadatapb.ViewMetadata, error) {+ tableMap, viewMap := make(map[string][]*metadatapb.TableMetadata), make(map[string][]*metadatapb.ViewMetadata)// Query table infovar excludedSchemaList []string@@ -419,7 +420,7 @@ func (d *Driver) getTableSchema(ctx context.Context, database string) (map[strinexcludeWhere := fmt.Sprintf("LOWER(TABLE_SCHEMA) NOT IN (%s)", strings.Join(excludedSchemaList, ", "))// Query column info.- columnMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+ columnMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)columnQuery := fmt.Sprintf(`SELECTTABLE_SCHEMA,@@ -443,7 +444,7 @@ func (d *Driver) getTableSchema(ctx context.Context, database string) (map[strinfor columnRows.Next() {var schemaName, tableName, nullable stringvar defaultStr sql.NullString- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}if err := columnRows.Scan(&schemaName,&tableName,@@ -492,7 +493,7 @@ func (d *Driver) getTableSchema(ctx context.Context, database string) (map[strindefer tableRows.Close()for tableRows.Next() {var schemaName string- table := &storepb.TableMetadata{}+ table := &metadatapb.TableMetadata{}if err := tableRows.Scan(&schemaName,&table.Name,@@ -527,7 +528,7 @@ func (d *Driver) getTableSchema(ctx context.Context, database string) (map[strin}defer viewRows.Close()for viewRows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}var schemaName stringif err := viewRows.Scan(&schemaName,@@ -541,7 +542,7 @@ func (d *Driver) getTableSchema(ctx context.Context, database string) (map[strinfor _, column := range columns {// TODO(zp): We get column by query the INFORMATION_SCHEMA.COLUMNS, which does not contains the view column belongs to which database.// So in the Snowflake, one view column may belongs to different databases, it may cause some confusing behavior in the Data Masking.- view.DependencyColumns = append(view.DependencyColumns, &storepb.DependencyColumn{+ view.DependencyColumns = append(view.DependencyColumns, &metadatapb.DependencyColumn{Schema: schemaName,Table: view.Name,Column: column.Name,diff --git a/backend/plugin/db/spanner/dump.go b/backend/plugin/db/spanner/dump.goindex 2db32bdb98..b5ad09c4d1 100644--- a/backend/plugin/db/spanner/dump.go+++ b/backend/plugin/db/spanner/dump.go@@ -6,12 +6,11 @@ import ("io""cloud.google.com/go/spanner/admin/database/apiv1/databasepb"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// Dump dumps database.-func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(ctx context.Context, out io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {resp, err := d.dbClient.GetDatabaseDdl(ctx, &databasepb.GetDatabaseDdlRequest{Database: getDSN(d.instancePath(), d.databaseName),})diff --git a/backend/plugin/db/spanner/sync.go b/backend/plugin/db/spanner/sync.goindex 936354cc59..098f154678 100644--- a/backend/plugin/db/spanner/sync.go+++ b/backend/plugin/db/spanner/sync.go@@ -6,6 +6,7 @@ import ("cloud.google.com/go/spanner""cloud.google.com/go/spanner/admin/database/apiv1/databasepb"+ metadatapb "github.com/bytebase/omni/metadata""google.golang.org/api/iterator""google.golang.org/grpc/codes""google.golang.org/grpc/status"@@ -13,13 +14,12 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/db")// SyncInstance syncs the instance.func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error) {- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadataiter := d.dbClient.ListDatabases(ctx, &databasepb.ListDatabasesRequest{Parent: d.instancePath(),})@@ -45,7 +45,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrapf(err, "failed to get database name from %s", database.Name)}- databases = append(databases, &storepb.DatabaseSchemaMetadata{Name: databaseName})+ databases = append(databases, &metadatapb.DatabaseSchemaMetadata{Name: databaseName})}return &db.InstanceMetadata{@@ -54,7 +54,7 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {notFound, err := d.notFoundDatabase(ctx, d.databaseName)if err != nil {return nil, errors.Wrap(err, "failed to check if database exists")@@ -66,7 +66,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadtx := d.client.ReadOnlyTransaction()defer tx.Close()- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,}columnMap, err := getColumn(ctx, tx)@@ -95,7 +95,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}slices.Sort(schemaNames)for _, schemaName := range schemaNames {- databaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{+ databaseMetadata.Schemas = append(databaseMetadata.Schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tableMap[schemaName],Views: viewMap[schemaName],@@ -117,7 +117,7 @@ func (d *Driver) notFoundDatabase(ctx context.Context, databaseName string) (booreturn false, nil}-func getTable(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.TableMetadata, error) {+func getTable(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.TableMetadata, error) {indexMap, err := getIndex(ctx, tx)if err != nil {return nil, errors.Wrapf(err, "failed to get indices")@@ -126,7 +126,7 @@ func getTable(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap maif err != nil {return nil, errors.Wrapf(err, "failed to get foreign keys")}- tableMap := make(map[string][]*storepb.TableMetadata)+ tableMap := make(map[string][]*metadatapb.TableMetadata)query := `SELECTTABLE_SCHEMA,@@ -144,7 +144,7 @@ func getTable(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap maif err != nil {return nil, err}- var table storepb.TableMetadata+ var table metadatapb.TableMetadatavar schema stringif err := row.Columns(&schema, &table.Name); err != nil {return nil, err@@ -159,8 +159,8 @@ func getTable(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap mareturn tableMap, nil}-func getColumn(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*storepb.ColumnMetadata, error) {- columnsMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+func getColumn(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {+ columnsMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)query := `SELECTTABLE_SCHEMA,@@ -183,7 +183,7 @@ func getColumn(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.Tabif err != nil {return nil, err}- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var (schemaName stringtableName string@@ -204,7 +204,7 @@ func getColumn(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.Tabreturn columnsMap, nil}-func getIndex(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*storepb.IndexMetadata, error) {+func getIndex(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*metadatapb.IndexMetadata, error) {query := `SELECTTABLE_SCHEMA,@@ -222,7 +222,7 @@ func getIndex(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TablORDER BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME`- keyIndexMap := make(map[db.TableKey][]*storepb.IndexMetadata)+ keyIndexMap := make(map[db.TableKey][]*metadatapb.IndexMetadata)iter := tx.Query(ctx, spanner.NewStatement(query))for {@@ -233,7 +233,7 @@ func getIndex(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.Tablif err != nil {return nil, err}- var idx storepb.IndexMetadata+ var idx metadatapb.IndexMetadatavar schema, table stringif err := row.Columns(&schema,@@ -252,8 +252,8 @@ func getIndex(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.Tablreturn keyIndexMap, nil}-func getForeignKey(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {- foreignKeyMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)+func getForeignKey(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {+ foreignKeyMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)query := `WITH t AS (SELECT DISTINCT@@ -308,7 +308,7 @@ func getForeignKey(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[dbif err != nil {return nil, err}- var fk storepb.ForeignKeyMetadata+ var fk metadatapb.ForeignKeyMetadatavar schema, table stringvar columns, referencedColumns []stringif err := row.Columns(@@ -331,8 +331,8 @@ func getForeignKey(ctx context.Context, tx *spanner.ReadOnlyTransaction) (map[dbreturn foreignKeyMap, nil}-func getView(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap map[db.TableKey][]*storepb.ColumnMetadata) (map[string][]*storepb.ViewMetadata, error) {- viewMap := make(map[string][]*storepb.ViewMetadata)+func getView(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap map[db.TableKey][]*metadatapb.ColumnMetadata) (map[string][]*metadatapb.ViewMetadata, error) {+ viewMap := make(map[string][]*metadatapb.ViewMetadata)query := `SELECTTABLE_SCHEMA,@@ -361,7 +361,7 @@ func getView(ctx context.Context, tx *spanner.ReadOnlyTransaction, columnMap mapkey := db.TableKey{Schema: schema, Table: name}- viewMap[schema] = append(viewMap[schema], &storepb.ViewMetadata{+ viewMap[schema] = append(viewMap[schema], &metadatapb.ViewMetadata{Name: name,Definition: definition,Columns: columnMap[key],diff --git a/backend/plugin/db/starrocks/dump.go b/backend/plugin/db/starrocks/dump.goindex 5b83480766..55b5257118 100644--- a/backend/plugin/db/starrocks/dump.go+++ b/backend/plugin/db/starrocks/dump.go@@ -8,6 +8,7 @@ import ("log/slog""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/go-sql-driver/mysql""github.com/pkg/errors"@@ -86,7 +87,7 @@ const ()// Dump dumps the database.-func (d *Driver) Dump(_ context.Context, out io.Writer, _ *storepb.DatabaseSchemaMetadata) error {+func (d *Driver) Dump(_ context.Context, out io.Writer, _ *metadatapb.DatabaseSchemaMetadata) error {// mysqldump -u root --databases dbName --no-data --routines --events --triggers --compactslog.Debug("begin to dump database", slog.String("database", d.databaseName))diff --git a/backend/plugin/db/starrocks/sync.go b/backend/plugin/db/starrocks/sync.goindex f0b8db4c98..510f27bc8b 100644--- a/backend/plugin/db/starrocks/sync.go+++ b/backend/plugin/db/starrocks/sync.go@@ -8,6 +8,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -69,9 +70,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}defer rows.Close()- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name,&database.CharacterSet,@@ -129,7 +130,7 @@ func isSyncRollup(refreshType string) bool {// materialized views with TABLE_TYPE='VIEW', Doris with 'BASE TABLE', and some setups// with 'MATERIALIZED VIEW'; in every case, presence in materializedViewMap is the// authoritative signal.-func isMaterializedView(tableType string, key db.TableKey, materializedViewMap map[db.TableKey]*storepb.MaterializedViewMetadata) bool {+func isMaterializedView(tableType string, key db.TableKey, materializedViewMap map[db.TableKey]*metadatapb.MaterializedViewMetadata) bool {if _, ok := materializedViewMap[key]; !ok {return false}@@ -145,8 +146,8 @@ func isMaterializedView(tableType string, key db.TableKey, materializedViewMap m// table name. Doris and StarRocks expose them through different catalogs, so the query// and projection are engine-specific. The query is best-effort: an engine/version that// does not support it is logged and yields an empty set rather than failing the sync.-func (d *Driver) getMaterializedViews(ctx context.Context) (map[db.TableKey]*storepb.MaterializedViewMetadata, error) {- materializedViewMap := make(map[db.TableKey]*storepb.MaterializedViewMetadata)+func (d *Driver) getMaterializedViews(ctx context.Context) (map[db.TableKey]*metadatapb.MaterializedViewMetadata, error) {+ materializedViewMap := make(map[db.TableKey]*metadatapb.MaterializedViewMetadata)var query stringswitch d.dbType {@@ -172,7 +173,7 @@ func (d *Driver) getMaterializedViews(ctx context.Context) (map[db.TableKey]*stodefer rows.Close()for rows.Next() {- materializedView := &storepb.MaterializedViewMetadata{}+ materializedView := &metadatapb.MaterializedViewMetadata{}if d.dbType == storepb.Engine_STARROCKS {var refreshType stringif err := rows.Scan(&materializedView.Name, &refreshType, &materializedView.Definition); err != nil {@@ -194,14 +195,14 @@ func (d *Driver) getMaterializedViews(ctx context.Context) (map[db.TableKey]*sto}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}// There is not yet a way to list indexes from information_schema.// Query column info.- columnMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+ columnMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)columnQuery := fmt.Sprintf(`SELECTTABLE_NAME,@@ -223,7 +224,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer columnRows.Close()for columnRows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var tableName, nullable, extra stringvar defaultStr sql.NullStringif err := columnRows.Scan(@@ -277,7 +278,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query view info.- viewMap := make(map[db.TableKey]*storepb.ViewMetadata)+ viewMap := make(map[db.TableKey]*metadatapb.ViewMetadata)viewQuery := fmt.Sprintf(`SELECTTABLE_NAME,@@ -290,7 +291,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer viewRows.Close()for viewRows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}if err := viewRows.Scan(&view.Name,&view.Definition,@@ -363,7 +364,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}switch tableType {case baseTableType:- tableMetadata := &storepb.TableMetadata{+ tableMetadata := &metadatapb.TableMetadata{Name: tableName,Columns: columnMap[key],Engine: engine,@@ -395,9 +396,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadreturn nil, util.FormatErrorWithQuery(err, tableQuery)}- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}// Query db info.databaseQuery := fmt.Sprintf(`diff --git a/backend/plugin/db/starrocks/sync_test.go b/backend/plugin/db/starrocks/sync_test.goindex 0fe6c67f68..8a823b1e0d 100644--- a/backend/plugin/db/starrocks/sync_test.go+++ b/backend/plugin/db/starrocks/sync_test.go@@ -3,6 +3,7 @@ package starrocksimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -15,7 +16,7 @@ import (// driver previously only matched Doris's 'BASE TABLE' rows, so StarRocks MVs were// dropped. Membership in the materialized-view set is the authoritative signal.func TestIsMaterializedView(t *testing.T) {- mvMap := map[db.TableKey]*storepb.MaterializedViewMetadata{+ mvMap := map[db.TableKey]*metadatapb.MaterializedViewMetadata{{Schema: "", Table: "mv_async"}: {Name: "mv_async"},}mvKey := db.TableKey{Schema: "", Table: "mv_async"}diff --git a/backend/plugin/db/tidb/dump.go b/backend/plugin/db/tidb/dump.goindex 30b72743ec..d764e1db76 100644--- a/backend/plugin/db/tidb/dump.go+++ b/backend/plugin/db/tidb/dump.go@@ -4,6 +4,7 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,7 +12,7 @@ import ()// Dump dumps the database.-func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_TIDB, schema.GetDefinitionContext{PrintHeader: true,}, dbMetadata)diff --git a/backend/plugin/db/tidb/sync.go b/backend/plugin/db/tidb/sync.goindex ab68393106..639850c9ab 100644--- a/backend/plugin/db/tidb/sync.go+++ b/backend/plugin/db/tidb/sync.go@@ -12,6 +12,7 @@ import ("time""github.com/blang/semver/v4"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -88,9 +89,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}defer rows.Close()- var databases []*storepb.DatabaseSchemaMetadata+ var databases []*metadatapb.DatabaseSchemaMetadatafor rows.Next() {- database := &storepb.DatabaseSchemaMetadata{}+ database := &metadatapb.DatabaseSchemaMetadata{}if err := rows.Scan(&database.Name,&database.CharacterSet,@@ -131,8 +132,8 @@ func (d *Driver) getServerVariable(ctx context.Context, varName string) (string,}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {- schemaMetadata := &storepb.SchemaMetadata{+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "",}@@ -143,7 +144,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query index info.- indexMap := make(map[db.TableKey]map[string]*storepb.IndexMetadata)+ indexMap := make(map[db.TableKey]map[string]*metadatapb.IndexMetadata)indexQuery := `SELECT@@ -193,10 +194,10 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadkey := db.TableKey{Schema: "", Table: tableName}if _, ok := indexMap[key]; !ok {- indexMap[key] = make(map[string]*storepb.IndexMetadata)+ indexMap[key] = make(map[string]*metadatapb.IndexMetadata)}if _, ok := indexMap[key][keyName]; !ok {- indexMap[key][keyName] = &storepb.IndexMetadata{+ indexMap[key][keyName] = &metadatapb.IndexMetadata{Name: keyName,Type: "BTREE", // Default to BTREE as TiDB generally uses BTREE indexesUnique: !nonUnique,@@ -223,7 +224,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query column info.- columnMap := make(map[db.TableKey][]*storepb.ColumnMetadata)+ columnMap := make(map[db.TableKey][]*metadatapb.ColumnMetadata)columnQuery := `SELECTTABLE_NAME,@@ -246,7 +247,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer columnRows.Close()for columnRows.Next() {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}var tableName, nullable, extra stringvar defaultStr, generationExpr sql.NullStringif err := columnRows.Scan(@@ -277,13 +278,13 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad// Handle generated columnsif generationExpr.Valid && generationExpr.String != "" {if strings.Contains(strings.ToUpper(extra), virtualGenerated) {- column.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_VIRTUAL,+ column.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_VIRTUAL,Expression: generationExpr.String,}} else if strings.Contains(strings.ToUpper(extra), storedGenerated) {- column.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ column.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: generationExpr.String,}}@@ -297,7 +298,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query view info.- viewMap := make(map[db.TableKey]*storepb.ViewMetadata)+ viewMap := make(map[db.TableKey]*metadatapb.ViewMetadata)viewQuery := `SELECTTABLE_NAME,@@ -310,7 +311,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}defer viewRows.Close()for viewRows.Next() {- view := &storepb.ViewMetadata{}+ view := &metadatapb.ViewMetadata{}if err := viewRows.Scan(&view.Name,&view.Definition,@@ -333,7 +334,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Query check constraint info.- checkMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)+ checkMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)if supportsCheckConstraintTable(version) {checkMap, err = d.getCheckConstraintList(ctx, d.databaseName)if err != nil {@@ -434,7 +435,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}}- tableMetadata := &storepb.TableMetadata{+ tableMetadata := &metadatapb.TableMetadata{Name: tableName,Columns: columns,ForeignKeys: foreignKeysMap[key],@@ -483,9 +484,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad// Add sequences to schema metadataschemaMetadata.Sequences = sequences- databaseMetadata := &storepb.DatabaseSchemaMetadata{+ databaseMetadata := &metadatapb.DatabaseSchemaMetadata{Name: d.databaseName,- Schemas: []*storepb.SchemaMetadata{schemaMetadata},+ Schemas: []*metadatapb.SchemaMetadata{schemaMetadata},}// Query db info.databaseQuery := `@@ -522,7 +523,7 @@ func isTimeConstant(s string) bool {return err == nil}-func setColumnMetadataDefault(column *storepb.ColumnMetadata, defaultStr sql.NullString, nullableBool bool, extra string) {+func setColumnMetadataDefault(column *metadatapb.ColumnMetadata, defaultStr sql.NullString, nullableBool bool, extra string) {if defaultStr.Valid {// TiDB is MySQL-compatible, so use MySQL's default handling approachunquotedDefault := mysql.UnquoteMySQLString(defaultStr.String)@@ -569,7 +570,7 @@ func setColumnMetadataDefault(column *storepb.ColumnMetadata, defaultStr sql.Nul}}-func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.TablePartitionMetadata, error) {+func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.TablePartitionMetadata, error) {const query string = `SELECTTABLE_NAME,@@ -602,7 +603,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (}partitionMap := make(map[partitionKey]int)- result := make(map[db.TableKey][]*storepb.TablePartitionMetadata)+ result := make(map[db.TableKey][]*metadatapb.TablePartitionMetadata)for rows.Next() {var tableName, partitionName, partitionMethod string@@ -625,7 +626,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (if _, ok := partitionMap[partitionKey]; !ok {// Partitiontp := convertToStorepbTablePartitionType(partitionMethod)- if tp == storepb.TablePartitionMetadata_TYPE_UNSPECIFIED {+ if tp == metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED {slog.Warn("unknown partition type", slog.String("partitionMethod", partitionMethod))continue}@@ -640,12 +641,12 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (value = partitionDescription.String}- partition := &storepb.TablePartitionMetadata{+ partition := &metadatapb.TablePartitionMetadata{Name: partitionName,Type: tp,Expression: expression,Value: value,- Subpartitions: []*storepb.TablePartitionMetadata{},+ Subpartitions: []*metadatapb.TablePartitionMetadata{},}partitionMap[partitionKey] = len(result[tableKey])result[tableKey] = append(result[tableKey], partition)@@ -653,7 +654,7 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (if subpartitionName.Valid {tp := convertToStorepbTablePartitionType(subpartitionMethod.String)- if tp == storepb.TablePartitionMetadata_TYPE_UNSPECIFIED {+ if tp == metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED {slog.Warn("unknown subpartition type", slog.String("subpartitionMethod", subpartitionMethod.String))continue}@@ -668,12 +669,12 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (value = partitionDescription.String}- subPartition := &storepb.TablePartitionMetadata{+ subPartition := &metadatapb.TablePartitionMetadata{Name: subpartitionName.String,Type: tp,Expression: expression,Value: value,- Subpartitions: []*storepb.TablePartitionMetadata{},+ Subpartitions: []*metadatapb.TablePartitionMetadata{},}if idx, ok := partitionMap[partitionKey]; !ok {@@ -691,30 +692,30 @@ func (d *Driver) listPartitionTables(ctx context.Context, databaseName string) (return result, nil}-func convertToStorepbTablePartitionType(tp string) storepb.TablePartitionMetadata_Type {+func convertToStorepbTablePartitionType(tp string) metadatapb.TablePartitionMetadata_Type {switch strings.ToUpper(tp) {case "RANGE":- return storepb.TablePartitionMetadata_RANGE+ return metadatapb.TablePartitionMetadata_RANGEcase "RANGE COLUMNS":- return storepb.TablePartitionMetadata_RANGE_COLUMNS+ return metadatapb.TablePartitionMetadata_RANGE_COLUMNScase "LIST":- return storepb.TablePartitionMetadata_LIST+ return metadatapb.TablePartitionMetadata_LISTcase "LIST COLUMNS":- return storepb.TablePartitionMetadata_LIST_COLUMNS+ return metadatapb.TablePartitionMetadata_LIST_COLUMNScase "HASH":- return storepb.TablePartitionMetadata_HASH+ return metadatapb.TablePartitionMetadata_HASHcase "KEY":- return storepb.TablePartitionMetadata_KEY+ return metadatapb.TablePartitionMetadata_KEYcase "LINEAR HASH":- return storepb.TablePartitionMetadata_LINEAR_HASH+ return metadatapb.TablePartitionMetadata_LINEAR_HASHcase "LINEAR KEY":- return storepb.TablePartitionMetadata_LINEAR_KEY+ return metadatapb.TablePartitionMetadata_LINEAR_KEYdefault:- return storepb.TablePartitionMetadata_TYPE_UNSPECIFIED+ return metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED}}-func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.ForeignKeyMetadata, error) {+func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.ForeignKeyMetadata, error) {fkQuery := `SELECTfks.TABLE_NAME,@@ -740,12 +741,12 @@ func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (mareturn nil, util.FormatErrorWithQuery(err, fkQuery)}defer fkRows.Close()- foreignKeysMap := make(map[db.TableKey][]*storepb.ForeignKeyMetadata)- var buildingFk *storepb.ForeignKeyMetadata+ foreignKeysMap := make(map[db.TableKey][]*metadatapb.ForeignKeyMetadata)+ var buildingFk *metadatapb.ForeignKeyMetadatavar buildingTable stringfor fkRows.Next() {var tableName string- var fk storepb.ForeignKeyMetadata+ var fk metadatapb.ForeignKeyMetadatavar column, referencedColumn stringif err := fkRows.Scan(&tableName,@@ -790,7 +791,7 @@ func (d *Driver) getForeignKeyList(ctx context.Context, databaseName string) (mareturn foreignKeysMap, nil}-func (d *Driver) getCheckConstraintList(ctx context.Context, databaseName string) (map[db.TableKey][]*storepb.CheckConstraintMetadata, error) {+func (d *Driver) getCheckConstraintList(ctx context.Context, databaseName string) (map[db.TableKey][]*metadatapb.CheckConstraintMetadata, error) {checkQuery := `SELECTtc.TABLE_NAME,@@ -808,9 +809,9 @@ func (d *Driver) getCheckConstraintList(ctx context.Context, databaseName string}defer checkRows.Close()- checkMap := make(map[db.TableKey][]*storepb.CheckConstraintMetadata)+ checkMap := make(map[db.TableKey][]*metadatapb.CheckConstraintMetadata)for checkRows.Next() {- check := &storepb.CheckConstraintMetadata{}+ check := &metadatapb.CheckConstraintMetadata{}var tableName stringif err := checkRows.Scan(&tableName,@@ -875,7 +876,7 @@ func stripSingleQuote(s string) string {return s}-func (d *Driver) getSequenceList(ctx context.Context, databaseName string) ([]*storepb.SequenceMetadata, error) {+func (d *Driver) getSequenceList(ctx context.Context, databaseName string) ([]*metadatapb.SequenceMetadata, error) {query := `SELECTSEQUENCE_NAME,@@ -896,9 +897,9 @@ func (d *Driver) getSequenceList(ctx context.Context, databaseName string) ([]*s}defer rows.Close()- var sequences []*storepb.SequenceMetadata+ var sequences []*metadatapb.SequenceMetadatafor rows.Next() {- sequence := &storepb.SequenceMetadata{}+ sequence := &metadatapb.SequenceMetadata{}var cycleOption int64if err := rows.Scan(diff --git a/backend/plugin/db/tidb/sync_test.go b/backend/plugin/db/tidb/sync_test.goindex b1c2a30996..7584646116 100644--- a/backend/plugin/db/tidb/sync_test.go+++ b/backend/plugin/db/tidb/sync_test.go@@ -5,9 +5,8 @@ import ("fmt""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")func TestSetColumnMetadataDefault(t *testing.T) {@@ -63,7 +62,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr sql.NullStringnullableBool boolextra string- want *storepb.ColumnMetadata+ want *metadatapb.ColumnMetadata}{// 8.0.11-TiDB-v7.6.0.// 5.7.28-TiDB-v7.1.1-serverless.@@ -73,7 +72,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "auto_increment",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "AUTO_INCREMENT",},},@@ -82,7 +81,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -91,7 +90,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -100,7 +99,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "hello"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "hello",},},@@ -109,14 +108,14 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "age1",defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -125,7 +124,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -134,7 +133,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -143,7 +142,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -153,7 +152,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "0"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "0",},},@@ -162,7 +161,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "NULL",},},@@ -171,14 +170,14 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{},+ want: &metadatapb.ColumnMetadata{},},{name: "time2",defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: false,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -187,7 +186,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: false,extra: "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -197,7 +196,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: true,extra: "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",OnUpdate: "CURRENT_TIMESTAMP",},@@ -207,7 +206,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP(6)"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -216,7 +215,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP(6)"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP(6)",},},@@ -225,7 +224,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {defaultStr: sql.NullString{Valid: true, String: "CURRENT_TIMESTAMP"},nullableBool: true,extra: "",- want: &storepb.ColumnMetadata{+ want: &metadatapb.ColumnMetadata{Default: "CURRENT_TIMESTAMP",},},@@ -233,7 +232,7 @@ func TestSetColumnMetadataDefault(t *testing.T) {a := require.New(t)for _, tc := range tests {- column := &storepb.ColumnMetadata{}+ column := &metadatapb.ColumnMetadata{}setColumnMetadataDefault(column, tc.defaultStr, tc.nullableBool, tc.extra)a.Equal(tc.want, column, tc.name)}diff --git a/backend/plugin/db/trino/dump.go b/backend/plugin/db/trino/dump.goindex a5c91c2167..a40bc44ca8 100644--- a/backend/plugin/db/trino/dump.go+++ b/backend/plugin/db/trino/dump.go@@ -4,6 +4,7 @@ import ("context""io"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,7 +12,7 @@ import ()// Dump dumps the database schema as SQL statements.-func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *storepb.DatabaseSchemaMetadata) error {+func (*Driver) Dump(_ context.Context, out io.Writer, dbMetadata *metadatapb.DatabaseSchemaMetadata) error {text, err := schema.GetDatabaseDefinition(storepb.Engine_TRINO, schema.GetDefinitionContext{}, dbMetadata)if err != nil {return errors.Wrapf(err, "failed to get database definition")diff --git a/backend/plugin/db/trino/sync.go b/backend/plugin/db/trino/sync.goindex 426050ae4e..00d0a5a30e 100644--- a/backend/plugin/db/trino/sync.go+++ b/backend/plugin/db/trino/sync.go@@ -3,6 +3,7 @@ package trinoimport ("context"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -22,9 +23,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)return nil, errors.Wrap(err, "failed to get catalog list")}- var catalogMetadata []*storepb.DatabaseSchemaMetadata+ var catalogMetadata []*metadatapb.DatabaseSchemaMetadatafor _, catalog := range catalogList {- catalogMetadata = append(catalogMetadata, &storepb.DatabaseSchemaMetadata{+ catalogMetadata = append(catalogMetadata, &metadatapb.DatabaseSchemaMetadata{Name: catalog,})}@@ -37,9 +38,9 @@ func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)}// SyncDBSchema syncs a single database schema.-func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {+func (d *Driver) SyncDBSchema(ctx context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {catalog := d.databaseName- dbMeta := &storepb.DatabaseSchemaMetadata{+ dbMeta := &metadatapb.DatabaseSchemaMetadata{Name: catalog,}@@ -61,7 +62,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}// Organize the data into schemas- var schemas []*storepb.SchemaMetadata+ var schemas []*metadatapb.SchemaMetadatafor _, schemaName := range schemaNames {tables := allTables[schemaName]@@ -73,7 +74,7 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad}}- schemas = append(schemas, &storepb.SchemaMetadata{+ schemas = append(schemas, &metadatapb.SchemaMetadata{Name: schemaName,Tables: tables,})@@ -126,7 +127,7 @@ func (d *Driver) getSchemaList(ctx context.Context) ([]string, error) {return d.queryStringValues(ctx, query, d.databaseName)}-func (d *Driver) fetchAllTablesForCatalog(ctx context.Context, schemas []string) (map[string][]*storepb.TableMetadata, error) {+func (d *Driver) fetchAllTablesForCatalog(ctx context.Context, schemas []string) (map[string][]*metadatapb.TableMetadata, error) {query := "SELECT table_schem, table_name FROM system.jdbc.tables WHERE table_cat = ? AND table_type = 'TABLE' ORDER BY table_schem, table_name"rows, err := d.db.QueryContext(ctx, query, d.databaseName)@@ -135,9 +136,9 @@ func (d *Driver) fetchAllTablesForCatalog(ctx context.Context, schemas []string)}defer rows.Close()- allTables := make(map[string][]*storepb.TableMetadata)+ allTables := make(map[string][]*metadatapb.TableMetadata)for _, schema := range schemas {- allTables[schema] = []*storepb.TableMetadata{}+ allTables[schema] = []*metadatapb.TableMetadata{}}for rows.Next() {@@ -145,7 +146,7 @@ func (d *Driver) fetchAllTablesForCatalog(ctx context.Context, schemas []string)if err := rows.Scan(&schemaName, &tableName); err != nil {return nil, errors.Wrap(err, "failed to scan table row")}- table := &storepb.TableMetadata{Name: tableName}+ table := &metadatapb.TableMetadata{Name: tableName}allTables[schemaName] = append(allTables[schemaName], table)}@@ -156,7 +157,7 @@ func (d *Driver) fetchAllTablesForCatalog(ctx context.Context, schemas []string)return allTables, nil}-func (d *Driver) fetchAllColumnsForCatalog(ctx context.Context) (map[db.TableKey][]*storepb.ColumnMetadata, error) {+func (d *Driver) fetchAllColumnsForCatalog(ctx context.Context) (map[db.TableKey][]*metadatapb.ColumnMetadata, error) {query := "SELECT table_schem, table_name, column_name, type_name, is_nullable FROM system.jdbc.columns WHERE table_cat = ? ORDER BY table_schem, table_name, ordinal_position"rows, err := d.db.QueryContext(ctx, query, d.databaseName)@@ -165,7 +166,7 @@ func (d *Driver) fetchAllColumnsForCatalog(ctx context.Context) (map[db.TableKey}defer rows.Close()- allColumns := make(map[db.TableKey][]*storepb.ColumnMetadata)+ allColumns := make(map[db.TableKey][]*metadatapb.ColumnMetadata)for rows.Next() {var schemaName, tableName, columnName, dataType, isNullable string@@ -177,7 +178,7 @@ func (d *Driver) fetchAllColumnsForCatalog(ctx context.Context) (map[db.TableKeyif err != nil {return nil, err}- column := &storepb.ColumnMetadata{+ column := &metadatapb.ColumnMetadata{Name: columnName,Type: dataType,Nullable: isNullBool,diff --git a/backend/plugin/parser/bigquery/query_span_leak_pins_test.go b/backend/plugin/parser/bigquery/query_span_leak_pins_test.goindex 5e9082a3b0..6b21318ea3 100644--- a/backend/plugin/parser/bigquery/query_span_leak_pins_test.go+++ b/backend/plugin/parser/bigquery/query_span_leak_pins_test.go@@ -3,6 +3,7 @@ package bigqueryimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -18,7 +19,7 @@ import (// failure, never silently empty/misaligned attribution (bytebase's masker is// positional and fail-open).-func leakPinSpan(t *testing.T, statement string, tables []*storepb.TableMetadata) []base.QuerySpanResult {+func leakPinSpan(t *testing.T, statement string, tables []*metadatapb.TableMetadata) []base.QuerySpanResult {t.Helper()span, err := googlesqltest.GetSpan(t, storepb.Engine_BIGQUERY, GetQuerySpan, statement, "ds1",googlesqltest.DefaultSchemaTables(tables...))@@ -34,9 +35,9 @@ func leakPinSpan(t *testing.T, statement string, tables []*storepb.TableMetadata// coalesces case-insensitively: one key column whose lineage reads BOTH sides,// then the non-key columns, positionally aligned with the real output.func TestLeakPin_LowercaseUsingCoalesce(t *testing.T) {- results := leakPinSpan(t, "SELECT * FROM a JOIN b USING (k);", []*storepb.TableMetadata{- {Name: "a", Columns: []*storepb.ColumnMetadata{{Name: "k"}, {Name: "x"}}},- {Name: "b", Columns: []*storepb.ColumnMetadata{{Name: "k"}, {Name: "y"}}},+ results := leakPinSpan(t, "SELECT * FROM a JOIN b USING (k);", []*metadatapb.TableMetadata{+ {Name: "a", Columns: []*metadatapb.ColumnMetadata{{Name: "k"}, {Name: "x"}}},+ {Name: "b", Columns: []*metadatapb.ColumnMetadata{{Name: "k"}, {Name: "y"}}},})require.Len(t, results, 3, "USING key must be coalesced: real output is [k, x, y]")require.Equal(t, []string{"a.k", "b.k"}, googlesqltest.SourcesOf(results[0]), "coalesced key reads both sides")@@ -50,8 +51,8 @@ func TestLeakPin_LowercaseUsingCoalesce(t *testing.T) {// must attribute correctly — silently-empty lineage would return the sensitive// array elements unmasked.func TestLeakPin_UnnestLineage(t *testing.T) {- results := leakPinSpan(t, "SELECT elem FROM victim, UNNEST(victim.secret_tokens) AS elem", []*storepb.TableMetadata{- {Name: "victim", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},+ results := leakPinSpan(t, "SELECT elem FROM victim, UNNEST(victim.secret_tokens) AS elem", []*metadatapb.TableMetadata{+ {Name: "victim", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},})require.Len(t, results, 1)require.Equal(t, []string{"victim.secret_tokens"}, googlesqltest.SourcesOf(results[0]),@@ -62,8 +63,8 @@ func TestLeakPin_UnnestLineage(t *testing.T) {// positional metadata, not data — empty lineage is correct for it, while the// element column keeps the array lineage.func TestLeakPin_UnnestWithOffsetNoLineage(t *testing.T) {- results := leakPinSpan(t, "SELECT elem, pos FROM victim, UNNEST(victim.secret_tokens) AS elem WITH OFFSET AS pos", []*storepb.TableMetadata{- {Name: "victim", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},+ results := leakPinSpan(t, "SELECT elem, pos FROM victim, UNNEST(victim.secret_tokens) AS elem WITH OFFSET AS pos", []*metadatapb.TableMetadata{+ {Name: "victim", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},})require.Len(t, results, 2)require.Equal(t, []string{"victim.secret_tokens"}, googlesqltest.SourcesOf(results[0]))@@ -76,9 +77,9 @@ func TestLeakPin_UnnestWithOffsetNoLineage(t *testing.T) {// the right arm's sensitive column to the wrong output position (verified leak// pre-fix: ID <- rt.b_secret).func TestLeakPin_ByNameMerge(t *testing.T) {- results := leakPinSpan(t, "SELECT id, label FROM lt UNION ALL BY NAME SELECT b_secret AS label, id FROM rt", []*storepb.TableMetadata{- {Name: "lt", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},- {Name: "rt", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "b_secret"}}},+ results := leakPinSpan(t, "SELECT id, label FROM lt UNION ALL BY NAME SELECT b_secret AS label, id FROM rt", []*metadatapb.TableMetadata{+ {Name: "lt", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},+ {Name: "rt", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "b_secret"}}},})require.Len(t, results, 2)require.Equal(t, []string{"lt.id", "rt.id"}, googlesqltest.SourcesOf(results[0]),@@ -92,9 +93,9 @@ func TestLeakPin_ByNameMerge(t *testing.T) {// The consumer must name-merge there too — pre-fix it ordinal-merged, which// mis-attributes whenever the arms' column orders differ (round-3 gate finding).func TestLeakPin_ByNameStarArmReversedOrder(t *testing.T) {- results := leakPinSpan(t, "SELECT * FROM pub UNION ALL BY NAME SELECT secret AS label, id FROM priv", []*storepb.TableMetadata{- {Name: "pub", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},- {Name: "priv", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},+ results := leakPinSpan(t, "SELECT * FROM pub UNION ALL BY NAME SELECT secret AS label, id FROM priv", []*metadatapb.TableMetadata{+ {Name: "pub", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},+ {Name: "priv", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},})require.Len(t, results, 2)require.Equal(t, []string{"priv.id", "pub.id"}, googlesqltest.SourcesOf(results[0]),@@ -108,9 +109,9 @@ func TestLeakPin_ByNameStarArmReversedOrder(t *testing.T) {// (wrong arity), shifting the positional masker off every real output column —// the real single `label` column would have received `id`'s masker.func TestLeakPin_ByNameOnMatchColumns(t *testing.T) {- results := leakPinSpan(t, "SELECT * FROM pub UNION ALL BY NAME ON (label) SELECT id, secret AS label FROM priv", []*storepb.TableMetadata{- {Name: "pub", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},- {Name: "priv", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},+ results := leakPinSpan(t, "SELECT * FROM pub UNION ALL BY NAME ON (label) SELECT id, secret AS label FROM priv", []*metadatapb.TableMetadata{+ {Name: "pub", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},+ {Name: "priv", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},})require.Len(t, results, 1, "ON (label) restricts the output to exactly the listed column")require.Equal(t, "label", results[0].Name)diff --git a/backend/plugin/parser/doris/query_span_extractor_system_table_test.go b/backend/plugin/parser/doris/query_span_extractor_system_table_test.goindex b34c96ee63..06d0a75920 100644--- a/backend/plugin/parser/doris/query_span_extractor_system_table_test.go+++ b/backend/plugin/parser/doris/query_span_extractor_system_table_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -22,7 +23,7 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {Description string `yaml:"description,omitempty"`Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -48,9 +49,9 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata))- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -70,7 +71,7 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {diff --git a/backend/plugin/parser/googlesql/googlesqltest/googlesqltest.go b/backend/plugin/parser/googlesql/googlesqltest/googlesqltest.goindex 2646e3a6f4..1fac74af4a 100644--- a/backend/plugin/parser/googlesql/googlesqltest/googlesqltest.go+++ b/backend/plugin/parser/googlesql/googlesqltest/googlesqltest.go@@ -12,6 +12,7 @@ import ("slices""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -33,7 +34,7 @@ func RunQuerySpanCorpus(t *testing.T, engine storepb.Engine, getQuerySpan base.GStatement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`IgnoreCaseSensitve bool `yaml:"ignoreCaseSensitive,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata.+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`}@@ -49,9 +50,9 @@ func RunQuerySpanCorpus(t *testing.T, engine storepb.Engine, getQuerySpan base.Ga.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoErrorf(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata), "cases %d", i+1)- getter, lister := BuildMockDatabaseMetadataGetter(engine, []*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := BuildMockDatabaseMetadataGetter(engine, []*metadatapb.DatabaseSchemaMetadata{metadata})result, err := getQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -72,7 +73,7 @@ func RunQuerySpanCorpus(t *testing.T, engine storepb.Engine, getQuerySpan base.G// BuildMockDatabaseMetadataGetter builds the metadata getter/lister pair the// query-span tests use, keyed by database name.-func BuildMockDatabaseMetadataGetter(engine storepb.Engine, databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func BuildMockDatabaseMetadataGetter(engine storepb.Engine, databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {@@ -95,10 +96,10 @@ func BuildMockDatabaseMetadataGetter(engine storepb.Engine, databaseMetadata []*// GetSpan evaluates one statement's query span against the given metadata —// the leak-pin tests' entry point.-func GetSpan(t *testing.T, engine storepb.Engine, getQuerySpan base.GetQuerySpanFunc, statement, defaultDatabase string, schemas []*storepb.SchemaMetadata) (*base.QuerySpan, error) {+func GetSpan(t *testing.T, engine storepb.Engine, getQuerySpan base.GetQuerySpanFunc, statement, defaultDatabase string, schemas []*metadatapb.SchemaMetadata) (*base.QuerySpan, error) {t.Helper()- meta := &storepb.DatabaseSchemaMetadata{Name: defaultDatabase, Schemas: schemas}- getter, lister := BuildMockDatabaseMetadataGetter(engine, []*storepb.DatabaseSchemaMetadata{meta})+ meta := &metadatapb.DatabaseSchemaMetadata{Name: defaultDatabase, Schemas: schemas}+ getter, lister := BuildMockDatabaseMetadataGetter(engine, []*metadatapb.DatabaseSchemaMetadata{meta})return getQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -106,8 +107,8 @@ func GetSpan(t *testing.T, engine storepb.Engine, getQuerySpan base.GetQuerySpan}// DefaultSchemaTables wraps tables into a single default ("") schema.-func DefaultSchemaTables(tables ...*storepb.TableMetadata) []*storepb.SchemaMetadata {- return []*storepb.SchemaMetadata{{Name: "", Tables: tables}}+func DefaultSchemaTables(tables ...*metadatapb.TableMetadata) []*metadatapb.SchemaMetadata {+ return []*metadatapb.SchemaMetadata{{Name: "", Tables: tables}}}// SourcesOf renders a result's source columns as sorted "[schema.]table.column"diff --git a/backend/plugin/parser/mongodb/completion_test.go b/backend/plugin/parser/mongodb/completion_test.goindex a1e9ecf374..d203f94ec4 100644--- a/backend/plugin/parser/mongodb/completion_test.go+++ b/backend/plugin/parser/mongodb/completion_test.go@@ -7,6 +7,7 @@ import ("slices""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -83,12 +84,12 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *modreturn "", nil, nil}- return "test", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "test", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users"},{Name: "orders"},{Name: "my-collection"}, // special char - needs bracket notationdiff --git a/backend/plugin/parser/mysql/backup_test.go b/backend/plugin/parser/mysql/backup_test.goindex 5d46832dac..a49c88befe 100644--- a/backend/plugin/parser/mysql/backup_test.go+++ b/backend/plugin/parser/mysql/backup_test.go@@ -7,6 +7,7 @@ import ("slices""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -93,13 +94,13 @@ func TestMariaDBTransformDMLToSelectRegistration(t *testing.T) {}func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {- schemaMetadata := []*store.SchemaMetadata{+ schemaMetadata := []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t_generated",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -108,12 +109,12 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "c_generated",- Generation: &store.GenerationMetadata{+ Generation: &metadatapb.GenerationMetadata{Expression: "a + b",},},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Primary: true,@@ -133,7 +134,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -147,7 +148,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -161,7 +162,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "test",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -172,7 +173,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFuName: "c",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Primary: true,@@ -191,7 +192,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "test2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -205,7 +206,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t3",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -221,7 +222,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},}return func(_ context.Context, _ string, database string) (string, *model.DatabaseMetadata, error) {- return database, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return database, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: database,Schemas: schemaMetadata,}, nil, nil, store.Engine_MYSQL, true /* isObjectCaseSensitive */), nildiff --git a/backend/plugin/parser/mysql/completion_test.go b/backend/plugin/parser/mysql/completion_test.goindex 782246e413..bfdd55d52f 100644--- a/backend/plugin/parser/mysql/completion_test.go+++ b/backend/plugin/parser/mysql/completion_test.go@@ -10,6 +10,7 @@ import ("testing""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -141,15 +142,15 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *modreturn "", nil, nil}- return "db", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "db", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1",},@@ -157,7 +158,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "t2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1",},@@ -167,7 +168,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1",Definition: `CREATE VIEW v1 ASdiff --git a/backend/plugin/parser/mysql/query_span_extractor.go b/backend/plugin/parser/mysql/query_span_extractor.goindex 2300671117..12ed9c4bfe 100644--- a/backend/plugin/parser/mysql/query_span_extractor.go+++ b/backend/plugin/parser/mysql/query_span_extractor.go@@ -5,6 +5,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"@@ -284,7 +285,7 @@ func (q *querySpanExtractor) findTableSchema(databaseName, tableName string) (ba}, nil}- var viewSchema *storepb.ViewMetadata+ var viewSchema *metadatapb.ViewMetadataif q.ignoreCaseSensitive {for _, view := range schema.ListViewNames() {if strings.EqualFold(view, tableName) {diff --git a/backend/plugin/parser/mysql/query_span_extractor_test.go b/backend/plugin/parser/mysql/query_span_extractor_test.goindex 58673d52d3..3f8c35dc16 100644--- a/backend/plugin/parser/mysql/query_span_extractor_test.go+++ b/backend/plugin/parser/mysql/query_span_extractor_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -420,8 +421,8 @@ JSON_TABLE(product_info, '$' COLUMNS (}func TestOmniQuerySpanPhase9_ResourceNotFoundFailOpen(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{Name: "db"}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db"}+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})span, err := newOmniQuerySpanExtractor("db", base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -1449,21 +1450,21 @@ func sourceColumnSetFromResources(resources []base.ColumnResource) base.SourceCo}func newOmniViewTestQuerySpanContext() base.GetQuerySpanContext {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},{Name: "b"},},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT a AS va, b FROM t",@@ -1480,7 +1481,7 @@ func newOmniViewTestQuerySpanContext() base.GetQuerySpanContext {},},}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})return base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -1489,15 +1490,15 @@ func newOmniViewTestQuerySpanContext() base.GetQuerySpanContext {}func newOmniTestQuerySpanContext() base.GetQuerySpanContext {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},{Name: "b"},{Name: "c"},@@ -1505,7 +1506,7 @@ func newOmniTestQuerySpanContext() base.GetQuerySpanContext {},{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},{Name: "b"},{Name: "c"},@@ -1513,7 +1514,7 @@ func newOmniTestQuerySpanContext() base.GetQuerySpanContext {},{Name: "t2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},{Name: "b"},{Name: "c"},@@ -1521,27 +1522,27 @@ func newOmniTestQuerySpanContext() base.GetQuerySpanContext {},{Name: "galleries",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"},{Name: "city"},},},{Name: "paintings",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"},{Name: "gallery_id"},},},{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "product_info"},},},{Name: "keyword_table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "select"},{Name: "Camel"},},@@ -1550,7 +1551,7 @@ func newOmniTestQuerySpanContext() base.GetQuerySpanContext {},},}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})return base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -1565,15 +1566,15 @@ func newOmniStarRocksTestQuerySpanContext() base.GetQuerySpanContext {}func newOmniCaseCollisionTestQuerySpanContext() base.GetQuerySpanContext {- dbMetadata := &storepb.DatabaseSchemaMetadata{+ dbMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},},},@@ -1581,15 +1582,15 @@ func newOmniCaseCollisionTestQuerySpanContext() base.GetQuerySpanContext {},},}- upperMetadata := &storepb.DatabaseSchemaMetadata{+ upperMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "DB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},},},@@ -1597,7 +1598,7 @@ func newOmniCaseCollisionTestQuerySpanContext() base.GetQuerySpanContext {},},}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{dbMetadata, upperMetadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{dbMetadata, upperMetadata})return base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,diff --git a/backend/plugin/parser/mysql/query_span_parity_test.go b/backend/plugin/parser/mysql/query_span_parity_test.goindex 4add01e968..150ed77575 100644--- a/backend/plugin/parser/mysql/query_span_parity_test.go+++ b/backend/plugin/parser/mysql/query_span_parity_test.go@@ -9,6 +9,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -111,11 +112,11 @@ func runMySQLOmniGoldenCase(engine storepb.Engine,ignoreCaseSensitive bool,) (*base.YamlQuerySpan, error) {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(metadataText), metadata); err != nil {return nil, err}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,diff --git a/backend/plugin/parser/mysql/query_span_test.go b/backend/plugin/parser/mysql/query_span_test.goindex 19a2381ad6..74b9d68d65 100644--- a/backend/plugin/parser/mysql/query_span_test.go+++ b/backend/plugin/parser/mysql/query_span_test.go@@ -7,6 +7,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -24,7 +25,7 @@ func TestGetQuerySpan(t *testing.T) {Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`IgnoreCaseSensitve bool `yaml:"ignoreCaseSensitive,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -59,9 +60,9 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoErrorf(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata), "cases %d", i+1)- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -82,7 +83,7 @@ func TestGetQuerySpan(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {@@ -104,19 +105,19 @@ func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaM}func TestGetQuerySpanCyclicViewReference(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1", Definition: "SELECT * FROM v2"},{Name: "v2", Definition: "SELECT * FROM v1"},},},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})_, err := GetQuerySpan(context.Background(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,diff --git a/backend/plugin/parser/partiql/completion_test.go b/backend/plugin/parser/partiql/completion_test.goindex 34ea156d10..65b0d8349e 100644--- a/backend/plugin/parser/partiql/completion_test.go+++ b/backend/plugin/parser/partiql/completion_test.go@@ -7,6 +7,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -96,16 +97,16 @@ func getCaretPosition(statement string) (string, int, int) {panic("caret position not found")}-var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{+var databaseMetadatas = []*metadatapb.DatabaseSchemaMetadata{{Name: "xx-ap-east-1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "Music",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Artist",},diff --git a/backend/plugin/parser/pg/completion_test.go b/backend/plugin/parser/pg/completion_test.goindex 92868bee6c..d4f1e663b5 100644--- a/backend/plugin/parser/pg/completion_test.go+++ b/backend/plugin/parser/pg/completion_test.go@@ -10,6 +10,7 @@ import ("testing""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -141,15 +142,15 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *modreturn "", nil, nil}- return "db", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "db", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1",Type: "int",@@ -158,7 +159,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "t2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1",Type: "int",@@ -170,16 +171,16 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1",Definition: `SELECT * FROM t1`,},},- ExternalTables: []*storepb.ExternalTableMetadata{+ ExternalTables: []*metadatapb.ExternalTableMetadata{{Name: "ft1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "f1",Type: "int",@@ -191,13 +192,13 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- MaterializedViews: []*storepb.MaterializedViewMetadata{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "mv1",Definition: "SELECT c1, c2 FROM t2",},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "seq1",DataType: "bigint",@@ -218,10 +219,10 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "test",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "auto",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",@@ -234,7 +235,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "user_id",Type: "int",@@ -246,7 +247,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "order_id_seq",DataType: "bigint",@@ -336,15 +337,15 @@ func getQuotedIdentifierMetadataForTest(_ context.Context, _, databaseName strinreturn "", nil, nil}- return "db", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "db", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c1",Type: "int",@@ -353,7 +354,7 @@ func getQuotedIdentifierMetadataForTest(_ context.Context, _, databaseName strin},{Name: "order",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",@@ -366,7 +367,7 @@ func getQuotedIdentifierMetadataForTest(_ context.Context, _, databaseName strin},{Name: "MyTable",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id",Type: "int",@@ -379,7 +380,7 @@ func getQuotedIdentifierMetadataForTest(_ context.Context, _, databaseName strin},{Name: "my-table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "col1",Type: "int",diff --git a/backend/plugin/parser/pg/query_span_composite_test.go b/backend/plugin/parser/pg/query_span_composite_test.goindex 521bb3b1dd..4a1c885047 100644--- a/backend/plugin/parser/pg/query_span_composite_test.go+++ b/backend/plugin/parser/pg/query_span_composite_test.go@@ -4,10 +4,9 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast""github.com/bytebase/omni/pg/catalog"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// TestLoaderInstallsCompositeTypes proves the query-span catalog loader@@ -15,40 +14,40 @@ import (// order (aa_nested sorts before its dependency zz_base alphabetically), and// that tables typed with them install cleanly.func TestLoaderInstallsCompositeTypes(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a", "b"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{// References zz_base only through an array suffix.Name: "aa_array_only",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "items", Type: "public.zz_base[]"},},},{Name: "aa_nested",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "home", Type: "public.zz_base"},{Name: "s", Type: "public.status"},},},{Name: "zz_base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},{Name: "city", Type: "character varying(50)"},},},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "home", Type: "public.zz_base", Nullable: true},},@@ -98,14 +97,14 @@ func TestLoaderInstallsCompositeTypes(t *testing.T) {// fallback via a domain-typed attribute (domains are not loader objects) and// asserts the fallback keeps the metadata attribute names.func TestLoaderCompositeFallbackPreservesAttributeNames(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "with_domain",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "p", Type: "public.pos_int"},{Name: "note", Type: "text"},},@@ -138,22 +137,22 @@ func TestLoaderCompositeFallbackPreservesAttributeNames(t *testing.T) {// not expand a standalone composite type as a FROM source — PostgreSQL// rejects composite types as table sources.func TestRangeVarFallbackSkipsCompositeTypes(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},diff --git a/backend/plugin/parser/pg/query_span_loader.go b/backend/plugin/parser/pg/query_span_loader.goindex 0704d7ba48..4fd76a1dc3 100644--- a/backend/plugin/parser/pg/query_span_loader.go+++ b/backend/plugin/parser/pg/query_span_loader.go@@ -7,13 +7,12 @@ import ("github.com/pkg/errors"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast""github.com/bytebase/omni/pg/catalog"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")-// catalogLoader installs every schema object from a storepb.DatabaseSchemaMetadata+// catalogLoader installs every schema object from a metadatapb.DatabaseSchemaMetadata// into an omni catalog, in dependency-topological order, with an inline// pseudo fallback at each failed slot.//@@ -30,7 +29,7 @@ import (// catalog object belongs to the caller.type catalogLoader struct {cat *catalog.Catalog- meta *storepb.DatabaseSchemaMetadata+ meta *metadatapb.DatabaseSchemaMetadata// loaderObjects maps canonical object keys (schema.name) to true for// every object the loader collected from metadata. Used by the classifier@@ -72,12 +71,12 @@ type objectEntry struct {name string// Exactly one of the following is populated based on kind.- enumMeta *storepb.EnumTypeMetadata- compositeMeta *storepb.CompositeTypeMetadata- tableMeta *storepb.TableMetadata- viewMeta *storepb.ViewMetadata- matViewMeta *storepb.MaterializedViewMetadata- funcMeta *storepb.FunctionMetadata+ enumMeta *metadatapb.EnumTypeMetadata+ compositeMeta *metadatapb.CompositeTypeMetadata+ tableMeta *metadatapb.TableMetadata+ viewMeta *metadatapb.ViewMetadata+ matViewMeta *metadatapb.MaterializedViewMetadata+ funcMeta *metadatapb.FunctionMetadata}// key returns a canonical kind-prefixed identifier used for dependency@@ -116,7 +115,7 @@ func (e *objectEntry) sortKey() string {// signature. Uses the metadata Signature string when present; falls back to// the definition hash to keep distinct overloads distinguishable even when// sync emitted an empty Signature field.-func funcSignatureKey(fn *storepb.FunctionMetadata) string {+func funcSignatureKey(fn *metadatapb.FunctionMetadata) string {if fn == nil {return ""}@@ -148,7 +147,7 @@ func kindLabel(k objectKind) string {// newCatalogLoader returns a loader primed for Load(). It does not touch the// catalog until Load() is called.-func newCatalogLoader(cat *catalog.Catalog, meta *storepb.DatabaseSchemaMetadata) *catalogLoader {+func newCatalogLoader(cat *catalog.Catalog, meta *metadatapb.DatabaseSchemaMetadata) *catalogLoader {return &catalogLoader{cat: cat,meta: meta,@@ -679,7 +678,7 @@ func (l *catalogLoader) installPseudo(obj *objectEntry) error {// columnNamesFromTableMetadata returns the deduplicated column names of a// table's metadata, in order, for use as pseudo column names.-func columnNamesFromTableMetadata(tbl *storepb.TableMetadata) []string {+func columnNamesFromTableMetadata(tbl *metadatapb.TableMetadata) []string {if tbl == nil {return nil}@@ -698,7 +697,7 @@ func columnNamesFromTableMetadata(tbl *storepb.TableMetadata) []string {// viewColumnNames returns the pseudo column-name list for a view. Prefers// explicit Columns (when sync populated them); falls back to the set of// dependency_columns.column values.-func viewColumnNames(v *storepb.ViewMetadata) []string {+func viewColumnNames(v *metadatapb.ViewMetadata) []string {if v == nil {return nil}@@ -729,7 +728,7 @@ func viewColumnNames(v *storepb.ViewMetadata) []string {// matviewColumnNames returns pseudo column names for a materialized view.// MaterializedViewMetadata does not carry a Columns field, so we fall back// to dependency_columns.-func matviewColumnNames(m *storepb.MaterializedViewMetadata) []string {+func matviewColumnNames(m *metadatapb.MaterializedViewMetadata) []string {if m == nil {return nil}diff --git a/backend/plugin/parser/pg/query_span_loader_builders.go b/backend/plugin/parser/pg/query_span_loader_builders.goindex 988f75d961..9d4b6c120c 100644--- a/backend/plugin/parser/pg/query_span_loader_builders.go+++ b/backend/plugin/parser/pg/query_span_loader_builders.go@@ -5,9 +5,8 @@ import ("github.com/pkg/errors"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// This file translates storepb metadata into omni AST nodes. Each build*@@ -17,7 +16,7 @@ import (// buildCreateEnumStmt translates EnumTypeMetadata + schema into a// CreateEnumStmt. Enum values are preserved as plain string literals.-func buildCreateEnumStmt(schema string, enum *storepb.EnumTypeMetadata) *ast.CreateEnumStmt {+func buildCreateEnumStmt(schema string, enum *metadatapb.EnumTypeMetadata) *ast.CreateEnumStmt {vals := make([]ast.Node, 0, len(enum.Values))for _, v := range enum.Values {vals = append(vals, &ast.String{Str: v})@@ -31,7 +30,7 @@ func buildCreateEnumStmt(schema string, enum *storepb.EnumTypeMetadata) *ast.Cre// buildCompositeTypeStmt translates CompositeTypeMetadata + schema into a// CompositeTypeStmt. Attribute types are parsed via typeNameFromString; an// error on any attribute propagates so the loader can pseudo the whole type.-func buildCompositeTypeStmt(schema string, composite *storepb.CompositeTypeMetadata) (*ast.CompositeTypeStmt, error) {+func buildCompositeTypeStmt(schema string, composite *metadatapb.CompositeTypeMetadata) (*ast.CompositeTypeStmt, error) {cols := make([]ast.Node, 0, len(composite.Attributes))for _, attribute := range composite.Attributes {if attribute.Name == "" {@@ -62,7 +61,7 @@ func buildCompositeTypeStmt(schema string, composite *storepb.CompositeTypeMetad// relation rather than install a partially-typed catalog entry.//// Columns with empty names are skipped.-func buildCreateStmt(schema string, table *storepb.TableMetadata) (*ast.CreateStmt, error) {+func buildCreateStmt(schema string, table *metadatapb.TableMetadata) (*ast.CreateStmt, error) {items := make([]ast.Node, 0, len(table.Columns))for _, col := range table.Columns {if col.Name == "" {@@ -97,7 +96,7 @@ func buildCreateStmt(schema string, table *storepb.TableMetadata) (*ast.CreateSt//// If the body is empty or unparseable, returns an error; the loader will// pseudo the view using dependency_columns metadata.-func buildViewStmt(schema string, view *storepb.ViewMetadata) (*ast.ViewStmt, error) {+func buildViewStmt(schema string, view *metadatapb.ViewMetadata) (*ast.ViewStmt, error) {if view.Definition == "" {return nil, errors.New("empty view definition")}@@ -118,7 +117,7 @@ func buildViewStmt(schema string, view *storepb.ViewMetadata) (*ast.ViewStmt, er// buildCreateTableAsStmt translates MaterializedViewMetadata into a// CreateTableAsStmt with Objtype OBJECT_MATVIEW. Same SelectStmt contract// as buildViewStmt: body must parse to *ast.SelectStmt.-func buildCreateTableAsStmt(schema string, mv *storepb.MaterializedViewMetadata) (*ast.CreateTableAsStmt, error) {+func buildCreateTableAsStmt(schema string, mv *metadatapb.MaterializedViewMetadata) (*ast.CreateTableAsStmt, error) {if mv.Definition == "" {return nil, errors.New("empty matview definition")}@@ -150,7 +149,7 @@ func buildCreateTableAsStmt(schema string, mv *storepb.MaterializedViewMetadata)// reconstructed from the signature string. The fallback loses return-type// fidelity but keeps analyzer name resolution working for queries that// reference the function by name.-func buildCreateFunctionStmt(schema string, fn *storepb.FunctionMetadata) (*ast.CreateFunctionStmt, error) {+func buildCreateFunctionStmt(schema string, fn *metadatapb.FunctionMetadata) (*ast.CreateFunctionStmt, error) {if fn.Definition != "" {stmts, err := ParsePg(fn.Definition)if err == nil && len(stmts) == 1 {@@ -169,7 +168,7 @@ func buildCreateFunctionStmt(schema string, fn *storepb.FunctionMetadata) (*ast.// buildCreateFunctionStmtFromSignature is the minimal-shape fallback used// when the full definition is missing or unparseable. Parameters and return// type collapse to text; the body is a trivial `SELECT NULL::text`.-func buildCreateFunctionStmtFromSignature(schema string, fn *storepb.FunctionMetadata) (*ast.CreateFunctionStmt, error) {+func buildCreateFunctionStmtFromSignature(schema string, fn *metadatapb.FunctionMetadata) (*ast.CreateFunctionStmt, error) {argTypes, err := parseFunctionSignatureArgTypes(fn.Signature)if err != nil {return nil, errors.Wrapf(err, "function %q signature %q", fn.Name, fn.Signature)diff --git a/backend/plugin/parser/pg/query_span_loader_integration_test.go b/backend/plugin/parser/pg/query_span_loader_integration_test.goindex 25457e7eac..e1e53c3343 100644--- a/backend/plugin/parser/pg/query_span_loader_integration_test.go+++ b/backend/plugin/parser/pg/query_span_loader_integration_test.go@@ -7,10 +7,10 @@ import ("runtime/debug""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast""github.com/bytebase/omni/pg/catalog"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base")@@ -35,25 +35,25 @@ func TestLoaderIntegration_BYT9215_BadQuotedIdentifier(t *testing.T) {// deparse-and-reparse loop chokes on. Under the old path this would kill// query span for the entire database. Under the loader, the bad table is// pseudo-installed and unrelated queries succeed.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{// A table with a quoted identifier containing an apostrophe —// the kind of input BYT-9215 reported failing under Exec(ddl).// Real install should succeed (no DDL roundtrip), but even if// it didn't, pseudo would catch it.{Name: "'weird'table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},},},// An unrelated healthy table.{Name: "accounts",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "email", Type: "text"},},@@ -74,24 +74,24 @@ func TestLoaderIntegration_BYT9215_BadQuotedIdentifier(t *testing.T) {}func TestGetQuerySpanWithSelectedSchemaFallsBackToPublic(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "app",},{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ssn", Type: "text"},},}},},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{meta})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{meta})span, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -113,30 +113,30 @@ func TestGetQuerySpanWithSelectedSchemaFallsBackToPublic(t *testing.T) {}func TestGetQuerySpanSelectedSchemaTakesPrecedenceOverPublic(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "app",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "email", Type: "text"},},}},},{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ssn", Type: "text"},},}},},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{meta})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{meta})span, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -158,13 +158,13 @@ func TestLoaderIntegration_BrokenEnumCascade(t *testing.T) {// not exist in metadata. Real install of the table fails (omni cannot// resolve the type). Pseudo install of the table succeeds with text// columns. Query against the table returns its metadata column names.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "tasks",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},// References an enum that is NOT declared in metadata —// buildCreateStmt will succeed (typeNameFromString works)@@ -198,21 +198,21 @@ func TestLoaderIntegration_BrokenRootTableAndHealthyNeighbor(t *testing.T) {// A query against a healthy table must succeed even when an unrelated// table in the same schema references a broken type. This is the core// blast-radius claim: one bad object does not poison all queries.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "broken",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "bad", Type: "public.nonexistent_type"},},},{Name: "healthy",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "label", Type: "text"},},@@ -235,22 +235,22 @@ func TestLoaderIntegration_BrokenRootTableAndHealthyNeighbor(t *testing.T) {func TestLoaderIntegration_ViewOverBrokenTableStillResolves(t *testing.T) {// Chain: enum missing → table T references it (degrades to pseudo) →// view V on T installs real (against pseudo T) → query on V resolves.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "records",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "status", Type: "public.nonexistent_enum"},{Name: "title", Type: "text"},},}},- Views: []*storepb.ViewMetadata{{+ Views: []*metadatapb.ViewMetadata{{Name: "records_view",Definition: "SELECT id, title, status FROM records",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "records", Column: "id"},{Schema: "public", Table: "records", Column: "title"},{Schema: "public", Table: "records", Column: "status"},@@ -273,13 +273,13 @@ func TestLoaderIntegration_ViewOverBrokenTableStillResolves(t *testing.T) {func TestLoaderIntegration_SimpleHealthyPath(t *testing.T) {// Baseline sanity: a clean schema must produce exact lineage down to// (schema, table, column) — no degraded flags.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "email", Type: "text"},{Name: "created_at", Type: "timestamp with time zone"},@@ -300,17 +300,17 @@ func TestLoaderIntegration_EnumWorksWhenDeclared(t *testing.T) {// When an enum IS declared in metadata, the table installs as real and// enum-typed columns resolve through their real type. This is the// positive control for TestLoaderIntegration_BrokenEnumCascade.- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "task_status",Values: []string{"pending", "running", "done"},}},- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "tasks",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "status", Type: "public.task_status"},},@@ -327,14 +327,14 @@ func TestLoaderIntegration_EnumWorksWhenDeclared(t *testing.T) {}func TestLoaderIntegration_CorrelatedRangeFunctionSubquery(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "compliance_case_record_audits",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "case_id", Type: "text"},{Name: "entity_id", Type: "text"},{Name: "reason", Type: "text"},@@ -346,7 +346,7 @@ func TestLoaderIntegration_CorrelatedRangeFunctionSubquery(t *testing.T) {},{Name: "compliance_cases",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "case_id", Type: "text"},{Name: "case_info", Type: "jsonb"},{Name: "deleted_at", Type: "timestamptz"},@@ -394,13 +394,13 @@ where a.reviewer_by in ('****** ', '******')}func TestLoaderIntegration_MultipleCTEsWithLateralJoinKeepsJSONBLineage(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "ai_conversation",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "text"},{Name: "parts", Type: "jsonb"},},@@ -638,9 +638,9 @@ const (loaderTestSchema = "public")-func mustGetQuerySpan(t *testing.T, meta *storepb.DatabaseSchemaMetadata, sql string) *base.QuerySpan {+func mustGetQuerySpan(t *testing.T, meta *metadatapb.DatabaseSchemaMetadata, sql string) *base.QuerySpan {t.Helper()- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{meta})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{meta})span, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,diff --git a/backend/plugin/parser/pg/query_span_loader_test.go b/backend/plugin/parser/pg/query_span_loader_test.goindex 82152f4456..ce0d2a8773 100644--- a/backend/plugin/parser/pg/query_span_loader_test.go+++ b/backend/plugin/parser/pg/query_span_loader_test.go@@ -7,10 +7,9 @@ import ("github.com/pkg/errors"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast""github.com/bytebase/omni/pg/catalog"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// ---------------- typeNameFromString ----------------@@ -415,7 +414,7 @@ func TestLoaderQualifiedNameList(t *testing.T) {// ---------------- real builders ----------------func TestLoaderBuildCreateEnumStmt(t *testing.T) {- stmt := buildCreateEnumStmt("public", &storepb.EnumTypeMetadata{+ stmt := buildCreateEnumStmt("public", &metadatapb.EnumTypeMetadata{Name: "task_status",Values: []string{"pending", "running", "done"},})@@ -429,9 +428,9 @@ func TestLoaderBuildCreateEnumStmt(t *testing.T) {}func TestLoaderBuildCreateStmt(t *testing.T) {- stmt, err := buildCreateStmt("public", &storepb.TableMetadata{+ stmt, err := buildCreateStmt("public", &metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4", Nullable: false},{Name: "name", Type: "text", Nullable: true},{Name: "amount", Type: "numeric(10,2)", Nullable: true},@@ -455,9 +454,9 @@ func TestLoaderBuildCreateStmt(t *testing.T) {}func TestLoaderBuildCreateStmt_BadTypeErrors(t *testing.T) {- _, err := buildCreateStmt("public", &storepb.TableMetadata{+ _, err := buildCreateStmt("public", &metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "bad", Type: "this is not a type at all;;"},},})@@ -467,9 +466,9 @@ func TestLoaderBuildCreateStmt_BadTypeErrors(t *testing.T) {}func TestLoaderBuildCreateStmt_EmptyTypeErrors(t *testing.T) {- _, err := buildCreateStmt("public", &storepb.TableMetadata{+ _, err := buildCreateStmt("public", &metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{{Name: "x", Type: ""}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "x", Type: ""}},})if err == nil {t.Fatal("expected error for empty column type")@@ -479,9 +478,9 @@ func TestLoaderBuildCreateStmt_EmptyTypeErrors(t *testing.T) {func TestLoaderBuildViewStmt(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- base, err := buildCreateStmt("public", &storepb.TableMetadata{+ base, err := buildCreateStmt("public", &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "total", Type: "int4"},},@@ -492,7 +491,7 @@ func TestLoaderBuildViewStmt(t *testing.T) {if err := cat.DefineRelation(base, 'r'); err != nil {t.Fatalf("install base: %v", err)}- stmt, err := buildViewStmt("public", &storepb.ViewMetadata{+ stmt, err := buildViewStmt("public", &metadatapb.ViewMetadata{Name: "v",Definition: "SELECT id, total FROM orders",})@@ -505,7 +504,7 @@ func TestLoaderBuildViewStmt(t *testing.T) {}func TestLoaderBuildViewStmt_EmptyDefinition(t *testing.T) {- _, err := buildViewStmt("public", &storepb.ViewMetadata{Name: "v"})+ _, err := buildViewStmt("public", &metadatapb.ViewMetadata{Name: "v"})if err == nil {t.Fatal("expected error for empty definition")}@@ -514,9 +513,9 @@ func TestLoaderBuildViewStmt_EmptyDefinition(t *testing.T) {func TestLoaderBuildCreateTableAsStmt(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- base, err := buildCreateStmt("public", &storepb.TableMetadata{+ base, err := buildCreateStmt("public", &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},},})@@ -526,7 +525,7 @@ func TestLoaderBuildCreateTableAsStmt(t *testing.T) {if err := cat.DefineRelation(base, 'r'); err != nil {t.Fatalf("install base: %v", err)}- stmt, err := buildCreateTableAsStmt("public", &storepb.MaterializedViewMetadata{+ stmt, err := buildCreateTableAsStmt("public", &metadatapb.MaterializedViewMetadata{Name: "m",Definition: "SELECT id FROM orders",})@@ -541,7 +540,7 @@ func TestLoaderBuildCreateTableAsStmt(t *testing.T) {func TestLoaderBuildCreateFunctionStmt(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- stmt, err := buildCreateFunctionStmt("public", &storepb.FunctionMetadata{+ stmt, err := buildCreateFunctionStmt("public", &metadatapb.FunctionMetadata{Name: "fn",Signature: "fn(integer, text)",})@@ -559,7 +558,7 @@ func TestLoaderBuildCreateFunctionStmt(t *testing.T) {func TestLoaderBuildCreateFunctionStmt_ZeroArgs(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- stmt, err := buildCreateFunctionStmt("public", &storepb.FunctionMetadata{+ stmt, err := buildCreateFunctionStmt("public", &metadatapb.FunctionMetadata{Name: "fn",Signature: "fn()",})@@ -625,24 +624,24 @@ func TestLoaderParseSelectBody(t *testing.T) {func TestLoader_HappyPath(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "task_status", Values: []string{"pending", "running"}},},- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "tasks",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},{Name: "status", Type: "public.task_status"},{Name: "title", Type: "text"},},}},- Views: []*storepb.ViewMetadata{{+ Views: []*metadatapb.ViewMetadata{{Name: "open_tasks",Definition: "SELECT id, title, status FROM tasks",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "tasks", Column: "id"},{Schema: "public", Table: "tasks", Column: "title"},{Schema: "public", Table: "tasks", Column: "status"},@@ -671,12 +670,12 @@ func TestLoader_HappyPath(t *testing.T) {func TestLoader_BrokenEnumCascadesToPseudo(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},// Reference a user type that is not in metadata. The// real install will fail; pseudo should take over.@@ -708,22 +707,22 @@ func TestLoader_BrokenEnumCascadesToPseudo(t *testing.T) {func TestLoader_TopoOrder_DependencyBeforeUse(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",// View is listed BEFORE its base table in metadata. The loader// must reorder so the table is installed first; otherwise the// view body analyzes against an empty catalog.- Views: []*storepb.ViewMetadata{{+ Views: []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM base",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "base", Column: "id"},},}},- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "base",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"},},}},@@ -745,21 +744,21 @@ func TestLoader_CycleBreaking(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})// Two views referencing each other — a metadata-level cycle.- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v_alpha",Definition: "SELECT id FROM v_beta",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "v_beta", Column: "id"},},},{Name: "v_beta",Definition: "SELECT id FROM v_alpha",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "v_alpha", Column: "id"},},},@@ -789,15 +788,15 @@ func TestLoader_CycleBreaking(t *testing.T) {func TestLoader_LoaderObjectsTracksEverything(t *testing.T) {cat := catalog.New()- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "e", Values: []string{"a"}},},- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "int4"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int4"}},}},}},}@@ -823,7 +822,7 @@ func TestLoader_NilMetaIsNoop(t *testing.T) {}func TestLoader_NilCatalogErrors(t *testing.T) {- loader := newCatalogLoader(nil, &storepb.DatabaseSchemaMetadata{})+ loader := newCatalogLoader(nil, &metadatapb.DatabaseSchemaMetadata{})if err := loader.Load(context.Background()); err == nil {t.Error("expected error for nil catalog")}@@ -836,10 +835,10 @@ func TestLoader_NilCatalogErrors(t *testing.T) {func TestLoader_FunctionOverloadsAllInstalled(t *testing.T) {cat := catalog.New()cat.SetSearchPath([]string{"public"})- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "fn",Signature: "fn(integer)",@@ -881,9 +880,9 @@ func TestLoaderTopoSort_Determinism(t *testing.T) {// for the same input.objects := []*objectEntry{{kind: kindSchema, schema: "public", name: "public"},- {kind: kindTable, schema: "public", name: "b", tableMeta: &storepb.TableMetadata{Name: "b"}},- {kind: kindTable, schema: "public", name: "a", tableMeta: &storepb.TableMetadata{Name: "a"}},- {kind: kindEnum, schema: "public", name: "e", enumMeta: &storepb.EnumTypeMetadata{Name: "e"}},+ {kind: kindTable, schema: "public", name: "b", tableMeta: &metadatapb.TableMetadata{Name: "b"}},+ {kind: kindTable, schema: "public", name: "a", tableMeta: &metadatapb.TableMetadata{Name: "a"}},+ {kind: kindEnum, schema: "public", name: "e", enumMeta: &metadatapb.EnumTypeMetadata{Name: "e"}},}first := topoSortObjects(objects)second := topoSortObjects(objects)diff --git a/backend/plugin/parser/pg/query_span_test.go b/backend/plugin/parser/pg/query_span_test.goindex 433a4fe922..5285f85042 100644--- a/backend/plugin/parser/pg/query_span_test.go+++ b/backend/plugin/parser/pg/query_span_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -22,7 +23,7 @@ func TestGetQuerySpan(t *testing.T) {Description string `yaml:"description,omitempty"`Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -48,9 +49,9 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata))- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -83,7 +84,7 @@ func TestGetQuerySpanNilMetadata(t *testing.T) {require.Contains(t, err.Error(), "database metadata for database \"unsynced-db\" not found")}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {diff --git a/backend/plugin/parser/pg/query_span_unresolved_columns_test.go b/backend/plugin/parser/pg/query_span_unresolved_columns_test.goindex 87b8ed7f07..2987300059 100644--- a/backend/plugin/parser/pg/query_span_unresolved_columns_test.go+++ b/backend/plugin/parser/pg/query_span_unresolved_columns_test.go@@ -4,34 +4,34 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base")-func column(name, typ string) *storepb.ColumnMetadata {- return &storepb.ColumnMetadata{Name: name, Type: typ}+func column(name, typ string) *metadatapb.ColumnMetadata {+ return &metadatapb.ColumnMetadata{Name: name, Type: typ}}-func healthySchema() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func healthySchema() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{- {Name: "t", Columns: []*storepb.ColumnMetadata{column("id", "int4"), column("email", "text"), column("ssn", "text")}},- {Name: "o", Columns: []*storepb.ColumnMetadata{column("id", "int4"), column("amt", "numeric")}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "t", Columns: []*metadatapb.ColumnMetadata{column("id", "int4"), column("email", "text"), column("ssn", "text")}},+ {Name: "o", Columns: []*metadatapb.ColumnMetadata{column("id", "int4"), column("amt", "numeric")}},},- Views: []*storepb.ViewMetadata{{+ Views: []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id, email FROM public.t",- Columns: []*storepb.ColumnMetadata{column("id", "int4"), column("email", "text")},+ Columns: []*metadatapb.ColumnMetadata{column("id", "int4"), column("email", "text")},}},- MaterializedViews: []*storepb.MaterializedViewMetadata{{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "mv",Definition: "SELECT id, ssn FROM public.t",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "t", Column: "id"},{Schema: "public", Table: "t", Column: "ssn"},},@@ -41,44 +41,44 @@ func healthySchema() *storepb.DatabaseSchemaMetadata {}// A table with no columns models a snapshot from a sync before #20581.-func degradedSchema() *storepb.DatabaseSchemaMetadata {+func degradedSchema() *metadatapb.DatabaseSchemaMetadata {return degradedSchemaNamed("t")}-func degradedSchemaNamed(table string) *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func degradedSchemaNamed(table string) *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{Name: table}},+ Tables: []*metadatapb.TableMetadata{{Name: table}},}},}}-func degradedViewSchema() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func degradedViewSchema() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{Name: "t"}},- Views: []*storepb.ViewMetadata{{Name: "v", Definition: "SELECT id, email FROM public.t"}},+ Tables: []*metadatapb.TableMetadata{{Name: "t"}},+ Views: []*metadatapb.ViewMetadata{{Name: "v", Definition: "SELECT id, email FROM public.t"}},}},}}-func partialSchema() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func partialSchema() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{Name: "t", Columns: []*storepb.ColumnMetadata{column("email", "text"), column("ssn", "text")}}},+ Tables: []*metadatapb.TableMetadata{{Name: "t", Columns: []*metadatapb.ColumnMetadata{column("email", "text"), column("ssn", "text")}}},}},}}-func spanFor(t *testing.T, statement string, metadata *storepb.DatabaseSchemaMetadata) *base.QuerySpan {+func spanFor(t *testing.T, statement string, metadata *metadatapb.DatabaseSchemaMetadata) *base.QuerySpan {t.Helper()- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})span, err := GetQuerySpan(context.Background(), base.GetQuerySpanContext{InstanceID: "inst",GetDatabaseMetadataFunc: getter,@@ -160,11 +160,11 @@ func TestUnresolvedColumnsSignalScope(t *testing.T) {})t.Run("a foreign table with no synced columns is not refused", func(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- ExternalTables: []*storepb.ExternalTableMetadata{{Name: "ft"}},+ ExternalTables: []*metadatapb.ExternalTableMetadata{{Name: "ft"}},}},}span := spanFor(t, "SELECT * FROM public.ft", metadata)@@ -207,7 +207,7 @@ func TestUnresolvedColumnsSignalScope(t *testing.T) {t.Run("error names every unresolved relation", func(t *testing.T) {metadata := degradedSchema()- metadata.Schemas[0].Tables = append(metadata.Schemas[0].Tables, &storepb.TableMetadata{Name: "o"})+ metadata.Schemas[0].Tables = append(metadata.Schemas[0].Tables, &metadatapb.TableMetadata{Name: "o"})span := spanFor(t, "SELECT * FROM public.t, public.o", metadata)require.NotNil(t, span.UnresolvedColumnsError)require.Contains(t, span.UnresolvedColumnsError.Error(), "public.o")@@ -217,12 +217,12 @@ func TestUnresolvedColumnsSignalScope(t *testing.T) {func TestUnresolvedColumnsSignalResolvesRelationsNotRoutines(t *testing.T) {// Routines do not shadow relations in PostgreSQL search_path resolution.- shadowed := &storepb.DatabaseSchemaMetadata{+ shadowed := &metadatapb.DatabaseSchemaMetadata{Name: "db",SearchPath: "a, b",- Schemas: []*storepb.SchemaMetadata{- {Name: "a", Functions: []*storepb.FunctionMetadata{{Name: "t", Signature: "t()"}}},- {Name: "b", Tables: []*storepb.TableMetadata{{Name: "t"}}},+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "a", Functions: []*metadatapb.FunctionMetadata{{Name: "t", Signature: "t()"}}},+ {Name: "b", Tables: []*metadatapb.TableMetadata{{Name: "t"}}},},}span := spanFor(t, "SELECT * FROM t", shadowed)@@ -231,12 +231,12 @@ func TestUnresolvedColumnsSignalResolvesRelationsNotRoutines(t *testing.T) {require.Contains(t, span.UnresolvedColumnsError.Error(), "b.t")// Sequences share the relation namespace and do shadow later tables.- sequenceFirst := &storepb.DatabaseSchemaMetadata{+ sequenceFirst := &metadatapb.DatabaseSchemaMetadata{Name: "db",SearchPath: "a, b",- Schemas: []*storepb.SchemaMetadata{- {Name: "a", Sequences: []*storepb.SequenceMetadata{{Name: "t"}}},- {Name: "b", Tables: []*storepb.TableMetadata{{Name: "t"}}},+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "a", Sequences: []*metadatapb.SequenceMetadata{{Name: "t"}}},+ {Name: "b", Tables: []*metadatapb.TableMetadata{{Name: "t"}}},},}span = spanFor(t, "SELECT * FROM t", sequenceFirst)diff --git a/backend/plugin/parser/pg/resource_change_test.go b/backend/plugin/parser/pg/resource_change_test.goindex df9b1bdeec..172175b4ef 100644--- a/backend/plugin/parser/pg/resource_change_test.go+++ b/backend/plugin/parser/pg/resource_change_test.go@@ -3,6 +3,7 @@ package pgimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -12,7 +13,7 @@ import ()func TestExtractChangedResources(t *testing.T) {- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)statement :=`CREATE TABLE t1 (c1 INT);DROP TABLE t1;@@ -67,8 +68,8 @@ func TestExtractChangedResourcesSelectedSchemaFallsBackToPublicForExistingTargetfor _, tc := range []struct {name string- appTables []*storepb.TableMetadata- appFuncs []*storepb.FunctionMetadata+ appTables []*metadatapb.TableMetadata+ appFuncs []*metadatapb.FunctionMetadatawantSchema string}{{@@ -77,9 +78,9 @@ func TestExtractChangedResourcesSelectedSchemaFallsBackToPublicForExistingTarget},{name: "selected schema still takes precedence",- appTables: []*storepb.TableMetadata{{+ appTables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},}},@@ -87,16 +88,16 @@ func TestExtractChangedResourcesSelectedSchemaFallsBackToPublicForExistingTarget},{name: "relation lookup skips function in selected schema",- appFuncs: []*storepb.FunctionMetadata{{+ appFuncs: []*metadatapb.FunctionMetadata{{Name: "customer",}},wantSchema: "public",},} {t.Run(tc.name, func(t *testing.T) {- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "app",Tables: tc.appTables,@@ -104,9 +105,9 @@ func TestExtractChangedResourcesSelectedSchemaFallsBackToPublicForExistingTarget},{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},}},@@ -128,7 +129,7 @@ func TestExtractChangedResourcesSelectedSchemaFallsBackToPublicForExistingTarget}func TestExtractChangedResourcesTruncate(t *testing.T) {- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)const statement = `TRUNCATE TABLE public.t1, myschema.t2;`want := model.NewChangedResources(dbMetadata)@@ -144,7 +145,7 @@ func TestExtractChangedResourcesTruncate(t *testing.T) {}func TestExtractChangedResourcesMerge(t *testing.T) {- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)const statement = `MERGE INTO myschema.tgt t USING src s ON t.id = s.id WHEN MATCHED THEN UPDATE SET a = s.a;`want := model.NewChangedResources(dbMetadata)@@ -159,7 +160,7 @@ func TestExtractChangedResourcesMerge(t *testing.T) {}func TestExtractChangedResourcesCTAS(t *testing.T) {- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_POSTGRES, true /* caseSensitive */)for _, tc := range []struct {statement, schema, table string}{diff --git a/backend/plugin/parser/pg/restore_test.go b/backend/plugin/parser/pg/restore_test.goindex 6a4ce8cb0e..12520ea5a3 100644--- a/backend/plugin/parser/pg/restore_test.go+++ b/backend/plugin/parser/pg/restore_test.go@@ -7,6 +7,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -83,16 +84,16 @@ func TestRestore(t *testing.T) {}func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database string) (string, *model.DatabaseMetadata, error) {- return database, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return database, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: database,SearchPath: "public",- Schemas: []*store.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t_generated",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -100,7 +101,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "b",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "t_generated_pk",Expressions: []string{"b"},@@ -116,7 +117,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "t1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -130,7 +131,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "t2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -144,7 +145,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "test",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -155,7 +156,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "c",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "test_pk",Expressions: []string{"a"},@@ -166,7 +167,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "test2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -180,7 +181,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "t",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -195,7 +196,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin{Name: "test1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},diff --git a/backend/plugin/parser/plsql/completion_test.go b/backend/plugin/parser/plsql/completion_test.goindex a0d7deb557..764f348f99 100644--- a/backend/plugin/parser/plsql/completion_test.go+++ b/backend/plugin/parser/plsql/completion_test.go@@ -8,6 +8,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -1280,15 +1281,15 @@ func listDatabaseNamesForTest(_ context.Context, _ string) ([]string, error) {func getMetadataForTest(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {switch databaseName {case "SCHEMA1":- return "SCHEMA1", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "SCHEMA1", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1297,7 +1298,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "T2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1309,7 +1310,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "V1",Definition: `CREATE VIEW v1 AS@@ -1318,7 +1319,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod`,},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "SEQ1",},@@ -1330,15 +1331,15 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},}, nil, nil, storepb.Engine_ORACLE, true /* isObjectCaseSensitive */), nilcase "SCHEMA2":- return "SCHEMA2", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "SCHEMA2", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1347,7 +1348,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "T2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1359,7 +1360,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "V1",Definition: `CREATE VIEW v1 AS@@ -1368,7 +1369,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod`,},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "SCHEMA2_SEQ",},@@ -1377,15 +1378,15 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},}, nil, nil, storepb.Engine_ORACLE, true /* isObjectCaseSensitive */), nilcase "SCHEMA3":- return "SCHEMA3", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "SCHEMA3", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1394,7 +1395,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},{Name: "T2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",@@ -1406,7 +1407,7 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "V1",Definition: `CREATE VIEW v1 AS@@ -1419,15 +1420,15 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod},}, nil, nil, storepb.Engine_ORACLE, true /* isObjectCaseSensitive */), nilcase "SCHEMA4":- return "SCHEMA4", model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return "SCHEMA4", model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1",Type: "int",diff --git a/backend/plugin/parser/plsql/query_span_parity_test.go b/backend/plugin/parser/plsql/query_span_parity_test.goindex d13c5bb136..e5d58e89ae 100644--- a/backend/plugin/parser/plsql/query_span_parity_test.go+++ b/backend/plugin/parser/plsql/query_span_parity_test.go@@ -9,11 +9,11 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3""github.com/bytebase/bytebase/backend/common"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base")@@ -91,13 +91,13 @@ func runOracleOmniGoldenCase(crossDatabaseMetadataText string,defaultDatabase string,) (*base.YamlQuerySpan, error) {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(metadataText), metadata); err != nil {return nil, err}- list := []*storepb.DatabaseSchemaMetadata{metadata}+ list := []*metadatapb.DatabaseSchemaMetadata{metadata}if crossDatabaseMetadataText != "" {- crossDatabase := &storepb.DatabaseSchemaMetadata{}+ crossDatabase := &metadatapb.DatabaseSchemaMetadata{}if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(crossDatabaseMetadataText), crossDatabase); err != nil {return nil, err}@@ -733,9 +733,9 @@ func oracleOmniLongTailTestContext(t *testing.T) base.GetQuerySpanContext {}]}`- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}require.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(metadataText), metadata))- databaseMetadataGetter, databaseNamesLister, linkedDatabaseMetadataGetter := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNamesLister, linkedDatabaseMetadataGetter := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})return base.GetQuerySpanContext{InstanceID: instanceIDA,GetDatabaseMetadataFunc: databaseMetadataGetter,diff --git a/backend/plugin/parser/plsql/query_span_test.go b/backend/plugin/parser/plsql/query_span_test.goindex 36fb0810e0..287ceab497 100644--- a/backend/plugin/parser/plsql/query_span_test.go+++ b/backend/plugin/parser/plsql/query_span_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata"oracleast "github.com/bytebase/omni/oracle/ast""github.com/pkg/errors""github.com/stretchr/testify/require"@@ -28,7 +29,7 @@ func TestGetQuerySpan(t *testing.T) {Description string `yaml:"description,omitempty"`Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`CrossDatabaseMetadata string `yaml:"crossDatabaseMetadata,omitempty"`@@ -51,10 +52,10 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata))- list := []*storepb.DatabaseSchemaMetadata{metadata}- crossDatabase := &storepb.DatabaseSchemaMetadata{}+ list := []*metadatapb.DatabaseSchemaMetadata{metadata}+ crossDatabase := &metadatapb.DatabaseSchemaMetadata{}if tc.CrossDatabaseMetadata != "" {a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.CrossDatabaseMetadata), crossDatabase))list = append(list, crossDatabase)@@ -81,7 +82,7 @@ func TestGetQuerySpan(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(defaultMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc, base.GetLinkedDatabaseMetadataFunc) {+func buildMockDatabaseMetadataGetter(defaultMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc, base.GetLinkedDatabaseMetadataFunc) {return func(_ context.Context, instanceID, databaseName string) (string, *model.DatabaseMetadata, error) {databaseMetadata := defaultMetadataif instanceID == instanceIDB {@@ -109,7 +110,7 @@ func buildMockDatabaseMetadataGetter(defaultMetadata []*storepb.DatabaseSchemaMereturn names, nil}, func(_ context.Context, _, linkedDatabaseName, _ string) (string, string, *model.DatabaseMetadata, error) {databaseMetadata := defaultMetadata- var linkedDBInfo *storepb.LinkedDatabaseMetadata+ var linkedDBInfo *metadatapb.LinkedDatabaseMetadatafor _, metadata := range databaseMetadata {for _, linkedDatabase := range metadata.GetLinkedDatabases() {if linkedDatabase.Name == linkedDatabaseName {@@ -139,17 +140,17 @@ func listLinkedDatabaseNames() ([]string, error) {return []string{"SCHEMA1", "SCHEMA2"}, nil}-func getLinkedDatabaseMetadata() []*storepb.DatabaseSchemaMetadata {- return []*storepb.DatabaseSchemaMetadata{+func getLinkedDatabaseMetadata() []*metadatapb.DatabaseSchemaMetadata {+ return []*metadatapb.DatabaseSchemaMetadata{{Name: "SCHEMA1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "LT1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "LC1",Type: "int",@@ -158,7 +159,7 @@ func getLinkedDatabaseMetadata() []*storepb.DatabaseSchemaMetadata {},{Name: "LT2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "LC1",Type: "int",@@ -170,7 +171,7 @@ func getLinkedDatabaseMetadata() []*storepb.DatabaseSchemaMetadata {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "LV1",Definition: `SELECT LC1, LC2diff --git a/backend/plugin/parser/plsql/resource_change_test.go b/backend/plugin/parser/plsql/resource_change_test.goindex 828670633a..f88faf6b0c 100644--- a/backend/plugin/parser/plsql/resource_change_test.go+++ b/backend/plugin/parser/plsql/resource_change_test.go@@ -3,6 +3,7 @@ package plsqlimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -103,15 +104,15 @@ DELETE FROM t2 WHERE c1 = 1;`func TestExtractChangedResourcesDropIndexUsesMetadata(t *testing.T) {statement := `DROP INDEX idx_t1_c1;`- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "DB",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "DB",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T1",- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "IDX_T1_C1",},diff --git a/backend/plugin/parser/plsql/restore_test.go b/backend/plugin/parser/plsql/restore_test.goindex 2112b221a1..705899eb6e 100644--- a/backend/plugin/parser/plsql/restore_test.go+++ b/backend/plugin/parser/plsql/restore_test.go@@ -7,6 +7,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -199,15 +200,15 @@ func restoreBackupItem(startLine, endLine int32) *store.PriorBackupDetail_Item {}func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database string) (string, *model.DatabaseMetadata, error) {- return database, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return database, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: database,- Schemas: []*store.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "T_GENERATED",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "A",},@@ -215,7 +216,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "B",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "T_GENERATED_PK",Expressions: []string{"B"},@@ -231,7 +232,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "T1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "A",},@@ -245,7 +246,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "T2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "A",},@@ -259,7 +260,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "TEST",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "A",},@@ -270,7 +271,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "C",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "TEST_PK",Expressions: []string{"A"},@@ -281,7 +282,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "TEST2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "A",},diff --git a/backend/plugin/parser/redshift/completion.go b/backend/plugin/parser/redshift/completion.goindex 3d3ab3bb6c..1c7051caee 100644--- a/backend/plugin/parser/redshift/completion.go+++ b/backend/plugin/parser/redshift/completion.go@@ -8,6 +8,7 @@ import ("unicode""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata"redshiftcatalog "github.com/bytebase/omni/redshift/catalog"redshiftcompletion "github.com/bytebase/omni/redshift/completion"@@ -157,7 +158,7 @@ func execCompletionDDL(cat *redshiftcatalog.Catalog, sql string) bool {return err == nil}-func createTableDDL(schemaName, tableName string, columns []*storepb.ColumnMetadata) string {+func createTableDDL(schemaName, tableName string, columns []*metadatapb.ColumnMetadata) string {return fmt.Sprintf("CREATE TABLE %s.%s (%s);",quoteIdent(schemaName),@@ -166,7 +167,7 @@ func createTableDDL(schemaName, tableName string, columns []*storepb.ColumnMetad)}-func createViewDDL(kind, schemaName, viewName string, columns []*storepb.ColumnMetadata) string {+func createViewDDL(kind, schemaName, viewName string, columns []*metadatapb.ColumnMetadata) string {selectItems := make([]string, 0, len(columns))for _, column := range columns {if column == nil || column.GetName() == "" {@@ -204,7 +205,7 @@ func createMaterializedViewDDL(schemaName, viewName, definition string) string {)}-func columnListDDL(columns []*storepb.ColumnMetadata) string {+func columnListDDL(columns []*metadatapb.ColumnMetadata) string {columnDefs := make([]string, 0, len(columns))for _, column := range columns {if column == nil || column.GetName() == "" {diff --git a/backend/plugin/parser/redshift/completion_test.go b/backend/plugin/parser/redshift/completion_test.goindex 5c6fcb12dc..126aaac56e 100644--- a/backend/plugin/parser/redshift/completion_test.go+++ b/backend/plugin/parser/redshift/completion_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -577,57 +578,57 @@ func TestCompletionMySQLPGScaleCoverageMatrix(t *testing.T) {}func redshiftCompletionContextForTest() base.CompletionContext {- metadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ metadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "amount", Type: "numeric"},},},{Name: "Order Items",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Item ID", Type: "bigint"},{Name: "Order ID", Type: "integer"},},},},- ExternalTables: []*storepb.ExternalTableMetadata{+ ExternalTables: []*metadatapb.ExternalTableMetadata{{Name: "spectrum_orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "external_id", Type: "varchar"},},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "amount", Type: "numeric"},},},},- MaterializedViews: []*storepb.MaterializedViewMetadata{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "orders_summary", Definition: "SELECT id, amount FROM orders"},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "order_seq"},},},{Name: "analytics",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "events",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "event_id", Type: "bigint"},},},diff --git a/backend/plugin/parser/redshift/query_span_extractor.go b/backend/plugin/parser/redshift/query_span_extractor.goindex 9c989003e5..5b157e6a21 100644--- a/backend/plugin/parser/redshift/query_span_extractor.go+++ b/backend/plugin/parser/redshift/query_span_extractor.go@@ -5,12 +5,12 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"redshiftanalysis "github.com/bytebase/omni/redshift/analysis"redshiftast "github.com/bytebase/omni/redshift/ast"redshiftcatalog "github.com/bytebase/omni/redshift/catalog""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -328,7 +328,7 @@ func redshiftRelationSpecFromMetadata(metadata *model.DatabaseMetadata, schema *return nil}-func redshiftTableRelationSpec(schemaName, tableName string, columns []*storepb.ColumnMetadata) *redshiftcatalog.RelationSpec {+func redshiftTableRelationSpec(schemaName, tableName string, columns []*metadatapb.ColumnMetadata) *redshiftcatalog.RelationSpec {return &redshiftcatalog.RelationSpec{SchemaName: schemaName,Name: tableName,@@ -337,7 +337,7 @@ func redshiftTableRelationSpec(schemaName, tableName string, columns []*storepb.}}-func redshiftRelationColumnSpecs(columns []*storepb.ColumnMetadata) []redshiftcatalog.RelationColumnSpec {+func redshiftRelationColumnSpecs(columns []*metadatapb.ColumnMetadata) []redshiftcatalog.RelationColumnSpec {result := make([]redshiftcatalog.RelationColumnSpec, 0, len(columns))for _, column := range columns {if column == nil || column.GetName() == "" {@@ -941,7 +941,7 @@ func (q *omniQuerySpanExtractor) omniFunctionBodySourcesForCall(ctx context.Contreturn sources, nil}-func (q *omniQuerySpanExtractor) findOmniFunctionMetadata(ctx context.Context, schemaName, functionName string, argCount int) (string, *storepb.FunctionMetadata, error) {+func (q *omniQuerySpanExtractor) findOmniFunctionMetadata(ctx context.Context, schemaName, functionName string, argCount int) (string, *metadatapb.FunctionMetadata, error) {if q.gCtx.GetDatabaseMetadataFunc == nil {return "", nil, nil}diff --git a/backend/plugin/parser/redshift/query_span_test.go b/backend/plugin/parser/redshift/query_span_test.goindex b007663363..37e3e56fe5 100644--- a/backend/plugin/parser/redshift/query_span_test.go+++ b/backend/plugin/parser/redshift/query_span_test.go@@ -5,6 +5,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require"@@ -541,32 +542,32 @@ func TestRedshiftOmniQuerySpanMetadataAndErrorCoverage(t *testing.T) {})t.Run("view definition resolves unqualified dependencies from view schema", func(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",SearchPath: "analytics, public",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "int"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"}},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "unqualified_orders_view",Definition: "CREATE VIEW public.unqualified_orders_view AS SELECT id FROM orders;",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "int"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"}},},},},{Name: "analytics",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "event_id", Type: "int"},},@@ -575,7 +576,7 @@ func TestRedshiftOmniQuerySpanMetadataAndErrorCoverage(t *testing.T) {},},}- getter, lister := redshiftMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := redshiftMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})localQ := newOmniQuerySpanExtractor("db", []string{"analytics", "public"}, base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -706,24 +707,24 @@ func TestRedshiftOmniQuerySpanMetadataAndErrorCoverage(t *testing.T) {func redshiftOmniQuerySpanContext(t *testing.T) base.GetQuerySpanContext {t.Helper()- getter, lister := redshiftMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{redshiftOmniQuerySpanMetadata()})+ getter, lister := redshiftMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{redshiftOmniQuerySpanMetadata()})return base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,}}-func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func redshiftOmniQuerySpanMetadata() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "db",SearchPath: "analytics, public",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "amount", Type: "numeric"},{Name: "tax", Type: "numeric"},@@ -733,7 +734,7 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {},{Name: "customers",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "name", Type: "varchar"},{Name: "region", Type: "varchar"},@@ -741,7 +742,7 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {},{Name: "line_items",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "order_id", Type: "int"},{Name: "sku", Type: "varchar"},@@ -749,17 +750,17 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {},{Name: "keyword_table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "select", Type: "int"},{Name: "Camel", Type: "int"},},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_orders",Definition: "CREATE VIEW public.active_orders AS SELECT id, amount FROM public.orders WHERE status = 'open';",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "amount", Type: "numeric"},},@@ -767,13 +768,13 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {{Name: "a_view",Definition: "CREATE VIEW public.a_view AS SELECT id FROM public.z_view;",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},},{Name: "fallback_view",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "amount", Type: "numeric"},},@@ -781,19 +782,19 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {{Name: "z_view",Definition: "CREATE VIEW public.z_view AS SELECT id FROM public.orders;",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},},{Name: "aliased_orders",Definition: "CREATE VIEW public.aliased_orders(order_id) AS SELECT id FROM public.orders;",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "order_id", Type: "int"},},},},- MaterializedViews: []*storepb.MaterializedViewMetadata{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "order_totals_mv",Definition: "CREATE MATERIALIZED VIEW public.order_totals_mv AS SELECT customer_id, SUM(amount) AS total_amount FROM public.orders GROUP BY customer_id;",@@ -803,7 +804,7 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {Definition: "CREATE MATERIALIZED VIEW public.aliased_orders_mv(order_id) AS SELECT id FROM public.orders;",},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "reporting_fn",Definition: "CREATE FUNCTION public.reporting_fn() RETURNS int STABLE AS $$ SELECT id FROM public.orders $$ LANGUAGE SQL;",@@ -820,7 +821,7 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {Signature: "unsupported_reporting_fn()",},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "order_id_seq",},@@ -828,16 +829,16 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {},{Name: "analytics",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "events",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "event_id", Type: "int"},{Name: "order_id", Type: "int"},},},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "reporting_fn",Definition: "CREATE FUNCTION analytics.reporting_fn() RETURNS int STABLE AS $$ SELECT event_id FROM analytics.events $$ LANGUAGE SQL;",@@ -847,10 +848,10 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {},{Name: "spectrum",- ExternalTables: []*storepb.ExternalTableMetadata{+ ExternalTables: []*metadatapb.ExternalTableMetadata{{Name: "spectrum_orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "external_id", Type: "varchar"},},},@@ -860,7 +861,7 @@ func redshiftOmniQuerySpanMetadata() *storepb.DatabaseSchemaMetadata {}}-func redshiftMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func redshiftMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {for _, metadata := range databaseMetadata {if metadata.GetName() == databaseName {diff --git a/backend/plugin/parser/redshift/resource_change_test.go b/backend/plugin/parser/redshift/resource_change_test.goindex ea68c3396a..037775d939 100644--- a/backend/plugin/parser/redshift/resource_change_test.go+++ b/backend/plugin/parser/redshift/resource_change_test.go@@ -3,6 +3,7 @@ package redshiftimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -16,7 +17,7 @@ ALTER TABLE t1 ADD COLUMN c2 INT;INSERT INTO t1 VALUES (1);UPDATE t1 SET c2 = 2;`- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_REDSHIFT, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_REDSHIFT, true /* caseSensitive */)changedResources := model.NewChangedResources(dbMetadata)changedResources.AddTable("db",@@ -50,7 +51,7 @@ SELECT * INTO copied_rows FROM public.rows;DROP TABLE old_rows;DELETE FROM copied_rows WHERE id = 1;`- dbMetadata := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_REDSHIFT, true /* caseSensitive */)+ dbMetadata := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, []byte{}, &storepb.DatabaseConfig{}, storepb.Engine_REDSHIFT, true /* caseSensitive */)changedResources := model.NewChangedResources(dbMetadata)changedResources.AddTable("db",diff --git a/backend/plugin/parser/snowflake/query_span_test.go b/backend/plugin/parser/snowflake/query_span_test.goindex 55438d79a3..6ab0e7b8ea 100644--- a/backend/plugin/parser/snowflake/query_span_test.go+++ b/backend/plugin/parser/snowflake/query_span_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -23,7 +24,7 @@ func TestGetQuerySpan(t *testing.T) {Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`IgnoreCaseSensitve bool `yaml:"ignoreCaseSensitive,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -63,9 +64,9 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoErrorf(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata), "cases %d", i+1)- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -85,7 +86,7 @@ func TestGetQuerySpan(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {@@ -112,8 +113,8 @@ func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaM// the bare base table (which would yield wrong lineage/positions for masking).func TestGetQuerySpan_PivotFailsClosed(t *testing.T) {a := require.New(t)- metadata := &storepb.DatabaseSchemaMetadata{Name: "DB1"}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "DB1"}+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})for _, sql := range []string{`SELECT * FROM monthly_sales PIVOT (SUM(amount) FOR month IN ('JAN', 'FEB')) AS p;`,`SELECT * FROM monthly_sales UNPIVOT (sales FOR month IN (jan, feb)) AS u;`,@@ -133,8 +134,8 @@ func TestGetQuerySpan_PivotFailsClosed(t *testing.T) {// passing as metadata-only.func TestGetQuerySpan_ShowPipeFailsClosed(t *testing.T) {a := require.New(t)- metadata := &storepb.DatabaseSchemaMetadata{Name: "DB1"}- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "DB1"}+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})_, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,diff --git a/backend/plugin/parser/spanner/query_span_leak_pins_test.go b/backend/plugin/parser/spanner/query_span_leak_pins_test.goindex cb35021714..1eb2b75645 100644--- a/backend/plugin/parser/spanner/query_span_leak_pins_test.go+++ b/backend/plugin/parser/spanner/query_span_leak_pins_test.go@@ -3,6 +3,7 @@ package spannerimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -25,8 +26,8 @@ func TestLeakPin_SpannerLowercaseUsingCoalesce(t *testing.T) {span, err := googlesqltest.GetSpan(t, storepb.Engine_SPANNER, GetQuerySpan,"SELECT * FROM users JOIN logins USING (id);", "db",googlesqltest.DefaultSchemaTables(- &storepb.TableMetadata{Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "email"}}},- &storepb.TableMetadata{Name: "logins", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},+ &metadatapb.TableMetadata{Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "email"}}},+ &metadatapb.TableMetadata{Name: "logins", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret"}}},))require.NoError(t, err)require.Len(t, span.Results, 3, "USING key must be coalesced: real output is [id, email, secret]")@@ -43,7 +44,7 @@ func TestLeakPin_SpannerUnnestLineage(t *testing.T) {span, err := googlesqltest.GetSpan(t, storepb.Engine_SPANNER, GetQuerySpan,"SELECT elem FROM victim, UNNEST(victim.secret_tokens) AS elem", "db",googlesqltest.DefaultSchemaTables(- &storepb.TableMetadata{Name: "victim", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},+ &metadatapb.TableMetadata{Name: "victim", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "secret_tokens"}}},))require.NoError(t, err)require.Len(t, span.Results, 1)@@ -57,8 +58,8 @@ func TestLeakPin_SpannerByNameMerge(t *testing.T) {span, err := googlesqltest.GetSpan(t, storepb.Engine_SPANNER, GetQuerySpan,"SELECT id, label FROM lt UNION ALL BY NAME SELECT b_secret AS label, id FROM rt", "db",googlesqltest.DefaultSchemaTables(- &storepb.TableMetadata{Name: "lt", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},- &storepb.TableMetadata{Name: "rt", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "b_secret"}}},+ &metadatapb.TableMetadata{Name: "lt", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "label"}}},+ &metadatapb.TableMetadata{Name: "rt", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "b_secret"}}},))require.NoError(t, err)require.Len(t, span.Results, 2)@@ -74,10 +75,10 @@ func TestLeakPin_SpannerByNameMerge(t *testing.T) {func TestLeakPin_SchemaQualifiedStar(t *testing.T) {span, err := googlesqltest.GetSpan(t, storepb.Engine_SPANNER, GetQuerySpan,"SELECT analytics.events.* FROM analytics.events", "db",- []*storepb.SchemaMetadata{+ []*metadatapb.SchemaMetadata{{Name: ""},- {Name: "analytics", Tables: []*storepb.TableMetadata{- {Name: "events", Columns: []*storepb.ColumnMetadata{{Name: "id"}, {Name: "payload"}}},+ {Name: "analytics", Tables: []*metadatapb.TableMetadata{+ {Name: "events", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "payload"}}},}},})require.NoError(t, err)@@ -92,7 +93,7 @@ func TestLeakPin_SchemaQualifiedStar(t *testing.T) {// extractor's exact behavior; SPANNER_SYS included).func TestLeakPin_MixedUserSystemRejected(t *testing.T) {userTables := googlesqltest.DefaultSchemaTables(- &storepb.TableMetadata{Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id"}}},+ &metadatapb.TableMetadata{Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}}},)_, err := googlesqltest.GetSpan(t, storepb.Engine_SPANNER, GetQuerySpan,"SELECT * FROM users JOIN INFORMATION_SCHEMA.TABLES ON TRUE", "db", userTables)diff --git a/backend/plugin/parser/spanner/query_span_type_test.go b/backend/plugin/parser/spanner/query_span_type_test.goindex f2198eae95..7cdc621cc3 100644--- a/backend/plugin/parser/spanner/query_span_type_test.go+++ b/backend/plugin/parser/spanner/query_span_type_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -16,7 +17,7 @@ import (// the access check rejects a QueryTypeUnknown span as "disallowed query type",// so a missing Type makes every Spanner SELECT fail in normal (non-admin) mode.func TestQuerySpanTypeForSelect(t *testing.T) {- getter, lister := googlesqltest.BuildMockDatabaseMetadataGetter(storepb.Engine_SPANNER, []*storepb.DatabaseSchemaMetadata{{Name: "db"}})+ getter, lister := googlesqltest.BuildMockDatabaseMetadataGetter(storepb.Engine_SPANNER, []*metadatapb.DatabaseSchemaMetadata{{Name: "db"}})result, err := GetQuerySpan(context.Background(),base.GetQuerySpanContext{diff --git a/backend/plugin/parser/starrocks/query_span_extractor_system_table_test.go b/backend/plugin/parser/starrocks/query_span_extractor_system_table_test.goindex 2a4e0b5b88..438c4620ac 100644--- a/backend/plugin/parser/starrocks/query_span_extractor_system_table_test.go+++ b/backend/plugin/parser/starrocks/query_span_extractor_system_table_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -22,7 +23,7 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {Description string `yaml:"description,omitempty"`Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -48,9 +49,9 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata))- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -70,7 +71,7 @@ func TestGetQuerySpan_SystemTable(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {diff --git a/backend/plugin/parser/tidb/backup_test.go b/backend/plugin/parser/tidb/backup_test.goindex 3bcf1ca217..465e89560d 100644--- a/backend/plugin/parser/tidb/backup_test.go+++ b/backend/plugin/parser/tidb/backup_test.go@@ -7,6 +7,7 @@ import ("slices""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -79,13 +80,13 @@ func TestBackup(t *testing.T) {}func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {- schemaMetadata := []*store.SchemaMetadata{+ schemaMetadata := []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t_generated",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -94,12 +95,12 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "c_generated",- Generation: &store.GenerationMetadata{+ Generation: &metadatapb.GenerationMetadata{Expression: "a + b",},},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Primary: true,@@ -146,7 +147,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -160,7 +161,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -174,7 +175,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "test",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -185,7 +186,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFuName: "c",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY",Primary: true,@@ -204,7 +205,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "test2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -218,7 +219,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu},{Name: "t3",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -235,7 +236,7 @@ func buildFixedMockDatabaseMetadataGetterAndLister() (base.GetDatabaseMetadataFu}return func(_ context.Context, _ string, database string) (string, *model.DatabaseMetadata, error) {- return database, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return database, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: database,Schemas: schemaMetadata,}, nil, nil, store.Engine_TIDB, false /* isObjectCaseSensitive */), nildiff --git a/backend/plugin/parser/tidb/completion.go b/backend/plugin/parser/tidb/completion.goindex 4dc36966a6..533368873f 100644--- a/backend/plugin/parser/tidb/completion.go+++ b/backend/plugin/parser/tidb/completion.go@@ -8,6 +8,7 @@ import ("unicode""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/tidb/catalog"omnicompletion "github.com/bytebase/omni/tidb/completion"tidbparser "github.com/bytebase/omni/tidb/parser"@@ -253,7 +254,7 @@ func isIdentByte(b byte) bool {// defineTable installs a table in the catalog, retrying with generic column// types if the real types fail to parse so that column names still surface.-func defineTable(cat *catalog.Catalog, name string, columns []*storepb.ColumnMetadata) {+func defineTable(cat *catalog.Catalog, name string, columns []*metadatapb.ColumnMetadata) {if len(columns) == 0 {return}@@ -263,7 +264,7 @@ func defineTable(cat *catalog.Catalog, name string, columns []*storepb.ColumnMetexecTableDDL(cat, name, columns, true)}-func execTableDDL(cat *catalog.Catalog, name string, columns []*storepb.ColumnMetadata, generic bool) bool {+func execTableDDL(cat *catalog.Catalog, name string, columns []*metadatapb.ColumnMetadata, generic bool) bool {defs := make([]string, 0, len(columns))for _, col := range columns {colType := col.GetType()diff --git a/backend/plugin/parser/tidb/completion_test.go b/backend/plugin/parser/tidb/completion_test.goindex 119b2d3717..5f4335e041 100644--- a/backend/plugin/parser/tidb/completion_test.go+++ b/backend/plugin/parser/tidb/completion_test.go@@ -5,6 +5,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -34,7 +35,7 @@ func hasKeyword(cands []base.Candidate, text string) bool {return false}-func metadataFunc(meta *storepb.DatabaseSchemaMetadata) base.GetDatabaseMetadataFunc {+func metadataFunc(meta *metadatapb.DatabaseSchemaMetadata) base.GetDatabaseMetadataFunc {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {return databaseName, model.NewDatabaseMetadata(meta, nil, nil, storepb.Engine_TIDB, true /* isObjectCaseSensitive */), nil}@@ -88,15 +89,15 @@ func candidateSet(cands []base.Candidate, types ...base.CandidateType) map[strin// catalog DDL backticks identifiers; the quoted candidate text proves the shim// quotes reserved object names on the way out.func TestCompletion_ReservedWordIdentifiersSurface(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "order",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "select"},{Name: "key"},},@@ -131,13 +132,13 @@ func TestCompletion_ReservedWordIdentifiersSurface(t *testing.T) {// column name still surfaces. Without that retry the failing CREATE TABLE would// drop the entire table from the catalog.func TestCompletion_UnparseableColumnTypeFallsBackToGeneric(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{- {Name: "t", Columns: []*storepb.ColumnMetadata{+ Tables: []*metadatapb.TableMetadata{+ {Name: "t", Columns: []*metadatapb.ColumnMetadata{{Name: "good", Type: "int"},{Name: "weird", Type: ")"}, // unparseable type — forces the generic retry}},@@ -159,9 +160,9 @@ func TestCompletion_UnparseableColumnTypeFallsBackToGeneric(t *testing.T) {// In the read-only query scene, write statements (DML/DDL incl. TiDB BATCH)// must be filtered out, while read keywords (SELECT) stay.func TestCompletion_QuerySceneFiltersWriteKeywords(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{{Name: ""}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: ""}},})ccx := func(scene base.SceneType) base.CompletionContext {return base.CompletionContext{Scene: scene, DefaultDatabase: "testdb", Metadata: meta}@@ -192,9 +193,9 @@ func TestCompletion_QuerySceneFiltersWriteKeywords(t *testing.T) {// position. Context-specific keywords that are valid inside read statements must// survive — e.g. CREATE in SHOW CREATE TABLE, UPDATE in SELECT ... FOR UPDATE.func TestCompletion_QuerySceneKeepsReadSubkeywords(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: ""}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: ""}},})q := base.CompletionContext{Scene: base.SceneTypeQuery, DefaultDatabase: "db", Metadata: meta}@@ -213,9 +214,9 @@ func TestCompletion_QuerySceneKeepsReadSubkeywords(t *testing.T) {// prefix at a statement-start position (the common autocomplete path), while// still preserving read sub-keywords typed mid-statement.func TestCompletion_QuerySceneFiltersWriteKeywordPrefix(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: ""}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: ""}},})q := base.CompletionContext{Scene: base.SceneTypeQuery, DefaultDatabase: "db", Metadata: meta}@@ -242,9 +243,9 @@ func TestCompletion_QuerySceneFiltersWriteKeywordPrefix(t *testing.T) {// cannot produce it. Its presence for Engine_TIDB and absence for Engine_MYSQL// proves Engine_TIDB now routes through the omni shim, not the mysql completer.func TestCompletion_TiDBRoutesThroughOmni(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: ""}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: ""}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll,@@ -274,16 +275,16 @@ func TestCompletion_TiDBRoutesThroughOmni(t *testing.T) {// fully-qualified db.table.col refs) that omni omits, because omni resolves the// in-scope columns directly instead. Tracked as a follow-up candidate gap.func TestCompletion_NoCoreCandidateLossVsMySQL(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "c1"}}},- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "c1"}, {Name: "c2"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "c1"}}},+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "c1"}, {Name: "c2"}}},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1", Definition: "SELECT c1 FROM t1"}, // bare SELECT, as TiDB sync stores it},},@@ -335,9 +336,9 @@ func TestCompletion_NoCoreCandidateLossVsMySQL(t *testing.T) {// candidates must still surface so the user can pick a database.func TestCompletion_InstanceLevelDatabaseCandidates(t *testing.T) {meta := func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {- return databaseName, model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ return databaseName, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{{Name: ""}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: ""}},}, nil, nil, storepb.Engine_TIDB, true), nil}cCtx := base.CompletionContext{@@ -359,11 +360,11 @@ func TestCompletion_InstanceLevelDatabaseCandidates(t *testing.T) {// Completion must be limited to the statement containing the caret: table refs// from earlier statements in the buffer must not leak into the candidate set.func TestCompletion_LimitsToStatementAtCaret(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},}}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -386,12 +387,12 @@ func TestCompletion_LimitsToStatementAtCaret(t *testing.T) {// so the view must still be installed (and surface as a candidate) via the// wrapped CREATE VIEW form rather than being treated as already created.func TestCompletion_ViewWithBareSelectDefinitionSurfaces(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{{Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "id"}}}},- Views: []*storepb.ViewMetadata{{Name: "v1", Definition: "SELECT id FROM t1"}},+ Tables: []*metadatapb.TableMetadata{{Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}}}},+ Views: []*metadatapb.ViewMetadata{{Name: "v1", Definition: "SELECT id FROM t1"}},}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -407,11 +408,11 @@ func TestCompletion_ViewWithBareSelectDefinitionSurfaces(t *testing.T) {// reference must be scoped to the qualifier's table (relies on the omni resolver// honoring the qualifier — pulled in via the go.mod bump).func TestCompletion_QualifiedColumnScopedInJoin(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},}}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -435,11 +436,11 @@ func TestCompletion_QualifiedColumnScopedInJoin(t *testing.T) {// An unknown column qualifier narrows to no columns rather than broadening to// all in-scope columns (relies on the omni resolver fix pulled in via the bump).func TestCompletion_UnknownQualifierOffersNoColumns(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "a1"}, {Name: "a2"}}},+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "b1"}, {Name: "b2"}}},}}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -460,10 +461,10 @@ func TestCompletion_UnknownQualifierOffersNoColumns(t *testing.T) {// Function candidates carry a "()" suffix, matching the mysql completer, so the// completion text inserts a call site.func TestCompletion_FunctionCandidatesGetParens(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "id"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}}},}}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -547,10 +548,10 @@ func TestStatementReferencesDatabase(t *testing.T) {// A backtick inside a preceding string literal must not be treated as an open// identifier quote: the reserved table name must still be quoted on the way out.func TestCompletion_QuotesReservedNameAfterStringLiteralWithBacktick(t *testing.T) {- meta := metadataFunc(&storepb.DatabaseSchemaMetadata{+ meta := metadataFunc(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "order", Columns: []*storepb.ColumnMetadata{{Name: "id"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "order", Columns: []*metadatapb.ColumnMetadata{{Name: "id"}}},}}},})cCtx := base.CompletionContext{Scene: base.SceneTypeAll, DefaultDatabase: "db", Metadata: meta}@@ -569,16 +570,16 @@ func TestCompletion_QuotesReservedNameAfterStringLiteralWithBacktick(t *testing.// omni-side limitation — omni ignores the table qualifier — tracked as a// follow-up, not asserted here.)func TestCompletion_QualifiedColumnAcrossDatabases(t *testing.T) {- appMeta := &storepb.DatabaseSchemaMetadata{+ appMeta := &metadatapb.DatabaseSchemaMetadata{Name: "appdb",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "c1"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "c1"}}},}}},}- otherMeta := &storepb.DatabaseSchemaMetadata{+ otherMeta := &metadatapb.DatabaseSchemaMetadata{Name: "otherdb",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "c2"}, {Name: "c3"}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "c2"}, {Name: "c3"}}},}}},}metaFn := func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {diff --git a/backend/plugin/parser/tidb/query_span_test.go b/backend/plugin/parser/tidb/query_span_test.goindex fa82c4c936..a493cb3bba 100644--- a/backend/plugin/parser/tidb/query_span_test.go+++ b/backend/plugin/parser/tidb/query_span_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -22,7 +23,7 @@ func TestGetQuerySpan(t *testing.T) {Description string `yaml:"description,omitempty"`Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -52,9 +53,9 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata))- databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNamesLister,@@ -81,15 +82,15 @@ func TestGetQuerySpanStaleMetadataReturnsNotFoundError(t *testing.T) {a := require.New(t)// Metadata omits distribute_level to mimic a stale cache after out-of-band ALTER TABLE ADD COLUMN.- staleMetadata := &storepb.DatabaseSchemaMetadata{+ staleMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "cif",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "byt9385_repro",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"},{Name: "existing_col"},{Name: "create_time"},@@ -99,7 +100,7 @@ func TestGetQuerySpanStaleMetadataReturnsNotFoundError(t *testing.T) {},},}- databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{staleMetadata})+ databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{staleMetadata})span, err := GetQuerySpan(context.TODO(),@@ -141,13 +142,13 @@ func TestGetQuerySpanMissingTableFallsBackToNotFoundDatabase(t *testing.T) {a := require.New(t)// Metadata is missing the table entirely.- staleMetadata := &storepb.DatabaseSchemaMetadata{+ staleMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "cif",- Schemas: []*storepb.SchemaMetadata{- {Name: "", Tables: []*storepb.TableMetadata{}},+ Schemas: []*metadatapb.SchemaMetadata{+ {Name: "", Tables: []*metadatapb.TableMetadata{}},},}- databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{staleMetadata})+ databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{staleMetadata})span, err := GetQuerySpan(context.TODO(),@@ -187,21 +188,21 @@ func TestGetQuerySpanMissingTableUnionedWithAccessTables(t *testing.T) {a := require.New(t)// Metadata has the "known" table but not the "unknown" one.- staleMetadata := &storepb.DatabaseSchemaMetadata{+ staleMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "cif",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "byt9385_known",- Columns: []*storepb.ColumnMetadata{{Name: "a"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"}},},},},},}- databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{staleMetadata})+ databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{staleMetadata})span, err := GetQuerySpan(context.TODO(),@@ -235,19 +236,19 @@ func TestGetQuerySpanMissingTableUnionedWithAccessTables(t *testing.T) {// reported as an error rather than recursing until the stack overflows.// Ported from the MySQL guard (#20153).func TestGetQuerySpanCyclicViewReference(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1", Definition: "SELECT * FROM v2"},{Name: "v2", Definition: "SELECT * FROM v1"},},},},}- databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNamesLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})_, err := GetQuerySpan(context.TODO(),@@ -264,7 +265,7 @@ func TestGetQuerySpanCyclicViewReference(t *testing.T) {require.ErrorContains(t, err, "cyclic view reference")}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {diff --git a/backend/plugin/parser/trino/completion.go b/backend/plugin/parser/trino/completion.goindex ee0ae8037e..116afedd49 100644--- a/backend/plugin/parser/trino/completion.go+++ b/backend/plugin/parser/trino/completion.go@@ -5,6 +5,7 @@ import ("strings""unicode/utf8"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/trino/catalog""github.com/bytebase/omni/trino/completion"@@ -165,7 +166,7 @@ func catalogNeeded(normName, defaultDB, lowerStmt string) bool {// columnsOf converts storepb columns into omni catalog columns (names// normalized).-func columnsOf(columns []*storepb.ColumnMetadata) []*catalog.Column {+func columnsOf(columns []*metadatapb.ColumnMetadata) []*catalog.Column {out := make([]*catalog.Column, 0, len(columns))for _, c := range columns {if c == nil {diff --git a/backend/plugin/parser/trino/completion_test.go b/backend/plugin/parser/trino/completion_test.goindex 7069f996de..4454205656 100644--- a/backend/plugin/parser/trino/completion_test.go+++ b/backend/plugin/parser/trino/completion_test.go@@ -5,6 +5,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -160,10 +161,10 @@ func TestCompletionNilMetadata(t *testing.T) {// for every catalog on the instance. On a Trino instance federating many// catalogs, eager loading would fan out a metadata fetch per keystroke.func TestCompletionLoadsOnlyNeededCatalogs(t *testing.T) {- metas := []*storepb.DatabaseSchemaMetadata{- {Name: "Company", Schemas: []*storepb.SchemaMetadata{{Name: "dbo", Tables: []*storepb.TableMetadata{{Name: "Employees", Columns: []*storepb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},- {Name: "School", Schemas: []*storepb.SchemaMetadata{{Name: "sch", Tables: []*storepb.TableMetadata{{Name: "Student", Columns: []*storepb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},- {Name: "Warehouse", Schemas: []*storepb.SchemaMetadata{{Name: "wh", Tables: []*storepb.TableMetadata{{Name: "Item", Columns: []*storepb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},+ metas := []*metadatapb.DatabaseSchemaMetadata{+ {Name: "Company", Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo", Tables: []*metadatapb.TableMetadata{{Name: "Employees", Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},+ {Name: "School", Schemas: []*metadatapb.SchemaMetadata{{Name: "sch", Tables: []*metadatapb.TableMetadata{{Name: "Student", Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},+ {Name: "Warehouse", Schemas: []*metadatapb.SchemaMetadata{{Name: "wh", Tables: []*metadatapb.TableMetadata{{Name: "Item", Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"}}}}}}},}loads := map[string]int{}getter := func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {@@ -237,23 +238,23 @@ func getCaretPosition(statement string) (string, int, int) {panic("caret position not found")}-var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{+var databaseMetadatas = []*metadatapb.DatabaseSchemaMetadata{{Name: "Company",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "Employees",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"},{Name: "Name", Type: "varchar"},},},{Name: "Address",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "EmployeeId", Type: "int"},{Name: "Street", Type: "varchar"},},@@ -262,10 +263,10 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},{Name: "MySchema",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "SalaryLevel",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"},{Name: "SalaryUpBound", Type: "int"},},@@ -276,13 +277,13 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},{Name: "School",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "Student",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id", Type: "int"},{Name: "ParentName", Type: "varchar"},},diff --git a/backend/plugin/parser/trino/query_span_feature_test.go b/backend/plugin/parser/trino/query_span_feature_test.goindex fc04e8e7a8..28df518eef 100644--- a/backend/plugin/parser/trino/query_span_feature_test.go+++ b/backend/plugin/parser/trino/query_span_feature_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -33,15 +34,15 @@ func tablesFromSpan(t *testing.T, sql, defaultDatabase string) base.SourceColumnfunc TestQuerySpan_PredicateExtraction(t *testing.T) {// A WHERE predicate's columns are reported as predicate columns once they// resolve against the (metadata-expanded) source columns.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "name", Type: "varchar"},},@@ -50,7 +51,7 @@ func TestQuerySpan_PredicateExtraction(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -105,15 +106,15 @@ func TestQuerySpan_SelectStarColumnOrder(t *testing.T) {// against the executed result's column order (query_result_masker.go), so a// nondeterministic order here could apply a column's masker to a different// column and leak sensitive data.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "accounts",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "secret", Type: "varchar"},{Name: "name", Type: "varchar"},@@ -124,7 +125,7 @@ func TestQuerySpan_SelectStarColumnOrder(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -151,15 +152,15 @@ func TestQuerySpan_AliasedColumnSourceColumns(t *testing.T) {// resolve back to the physical column users.email. Otherwise the per-result// SourceColumns are empty, the masker treats the column as a constant// expression, and a sensitive aliased column is returned unmasked.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},@@ -168,7 +169,7 @@ func TestQuerySpan_AliasedColumnSourceColumns(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -191,11 +192,11 @@ func TestQuerySpan_SystemSchemaNoNotFoundError(t *testing.T) {// "failed to mask data" rejection of an otherwise-successful result, so// resolving Trino's pseudo-catalogs (which are not Bytebase-tracked// databases) as metadata would fail valid SQL-info queries after execution.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "mydb",- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -219,15 +220,15 @@ func TestQuerySpan_SystemSubstringDoesNotBypassMasking(t *testing.T) {// statement text contains "system." in a string literal (which trips the// coarse containsSystemSchema classifier). System detection is per resolved// table, so the literal must not suppress lineage for users.email.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},@@ -236,7 +237,7 @@ func TestQuerySpan_SystemSubstringDoesNotBypassMasking(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -256,15 +257,15 @@ func TestQuerySpan_SelfJoinStarColumnCount(t *testing.T) {// (2N for a 2-way self-join). The positional masker needs a span result per// output column, so the expansion must NOT collapse the duplicate physical// columns or the trailing instance's columns would get no masker.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},@@ -273,7 +274,7 @@ func TestQuerySpan_SelfJoinStarColumnCount(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -302,22 +303,22 @@ func TestQuerySpan_ShadowedAliasStillMasked(t *testing.T) {// An alias reused across scopes ("u" for users outside, for orders inside an// EXISTS subquery) must not drop lineage for the outer u.email. Additive// alias resolution keeps users.email so the sensitive column stays masked.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},@@ -325,7 +326,7 @@ func TestQuerySpan_ShadowedAliasStillMasked(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -344,22 +345,22 @@ func TestQuerySpan_QualifiedStarSourceColumns(t *testing.T) {// A qualified star (u.*) must expand to the aliased relation's columns, each// carrying its physical source column so they stay maskable. omni names the// result "u.*"; only u's table (users) is expanded, not the joined orders.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "amount", Type: "double"},},@@ -368,7 +369,7 @@ func TestQuerySpan_QualifiedStarSourceColumns(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -407,24 +408,24 @@ func TestQuerySpan_QualifiedStarDistinguishesSameNamedTables(t *testing.T) {// must expand to ONLY s1.users' columns, not s2.users' — matching on the full// (database, schema, table), not just the table name. Otherwise the positional// masker could apply s2's policies to s1's columns and leak.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "s1",- Tables: []*storepb.TableMetadata{- {Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}, {Name: "secret", Type: "varchar"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}, {Name: "secret", Type: "varchar"}}},},},{Name: "s2",- Tables: []*storepb.TableMetadata{- {Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}, {Name: "name", Type: "varchar"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}, {Name: "name", Type: "varchar"}}},},},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -451,15 +452,15 @@ func TestQuerySpan_AliasEndingInStarIsNotExpanded(t *testing.T) {// (email); star-expanding it would emit several results and misalign the// positional masker, leaking the value. Detection keys on the source-ref// shape, so this resolves to a single email result.- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "email", Type: "varchar"},},@@ -468,7 +469,7 @@ func TestQuerySpan_AliasEndingInStarIsNotExpanded(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,diff --git a/backend/plugin/parser/trino/query_span_lineage_test.go b/backend/plugin/parser/trino/query_span_lineage_test.goindex 89bf4bc44b..aaf034e1f4 100644--- a/backend/plugin/parser/trino/query_span_lineage_test.go+++ b/backend/plugin/parser/trino/query_span_lineage_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -19,16 +20,16 @@ import (// exercises the full extractor path metadata -> catalog -> omni -> resource// mapping. The view vectors are covered in query_span_view_test.go.-func lineageAuditMetadata() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func lineageAuditMetadata() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "phone", Type: "varchar"},{Name: "name", Type: "varchar"},@@ -43,7 +44,7 @@ func lineageAuditMetadata() *storepb.DatabaseSchemaMetadata {func lineageAuditSpan(t *testing.T, sql string) *base.QuerySpan {t.Helper()- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{lineageAuditMetadata()})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{lineageAuditMetadata()})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,diff --git a/backend/plugin/parser/trino/query_span_test.go b/backend/plugin/parser/trino/query_span_test.goindex 3e71981928..d7d633b44d 100644--- a/backend/plugin/parser/trino/query_span_test.go+++ b/backend/plugin/parser/trino/query_span_test.go@@ -7,6 +7,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -118,7 +119,7 @@ func TestGetQuerySpanFromYAML(t *testing.T) {Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`IgnoreCaseSensitve bool `yaml:"ignoreCaseSensitive,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata string `yaml:"metadata,omitempty"`QuerySpan *CustomYamlQuerySpan `yaml:"querySpan,omitempty"`@@ -150,9 +151,9 @@ func TestGetQuerySpanFromYAML(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}a.NoErrorf(common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), metadata), "cases %d", i+1)- databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ databaseMetadataGetter, databaseNameLister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})result, err := GetQuerySpan(context.TODO(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: databaseMetadataGetter,ListDatabaseNamesFunc: databaseNameLister,@@ -206,7 +207,7 @@ func TestGetQuerySpanFromYAML(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {diff --git a/backend/plugin/parser/trino/query_span_view_test.go b/backend/plugin/parser/trino/query_span_view_test.goindex 0dff5b5d71..dcf589fceb 100644--- a/backend/plugin/parser/trino/query_span_view_test.go+++ b/backend/plugin/parser/trino/query_span_view_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -13,52 +14,52 @@ import (// viewLineageMetadata builds a catalog with a base table customer(id, phone,// name), a pass-through view customer_v, a renaming view cust_masked// (phone AS ph), and a view-over-view v2.-func viewLineageMetadata() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func viewLineageMetadata() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "phone", Type: "varchar"},{Name: "name", Type: "varchar"},},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "customer_v",Definition: "SELECT id, phone, name FROM customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "phone"}, {Name: "name"},},},{Name: "cust_masked",Definition: "SELECT phone AS ph FROM customer",- Columns: []*storepb.ColumnMetadata{{Name: "ph"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "ph"}},},{Name: "v2",Definition: "SELECT phone FROM customer_v",- Columns: []*storepb.ColumnMetadata{{Name: "phone"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "phone"}},},{// Explicit view column list renames the projection: the// definition outputs "phone" but the view column is "ph".Name: "renamed_v",Definition: "SELECT phone FROM customer",- Columns: []*storepb.ColumnMetadata{{Name: "ph"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "ph"}},},{// A composed view column derives from two base columns.Name: "comp_v",Definition: "SELECT phone || name AS token FROM customer",- Columns: []*storepb.ColumnMetadata{{Name: "token"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "token"}},},},},@@ -67,7 +68,7 @@ func viewLineageMetadata() *storepb.DatabaseSchemaMetadata {}func viewLineageSpan(t *testing.T, sql string) *base.QuerySpan {- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{viewLineageMetadata()})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{viewLineageMetadata()})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,@@ -162,16 +163,16 @@ func TestQuerySpan_ComposedViewColumnNotPlain(t *testing.T) {// catalog's column metadata): the outer statement never names catalog2, so the// span-catalog builder must follow the view definition transitively to load it.func TestQuerySpan_CrossCatalogViewResolvesToBase(t *testing.T) {- cat1 := &storepb.DatabaseSchemaMetadata{+ cat1 := &metadatapb.DatabaseSchemaMetadata{Name: "catalog1",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "xcat_v",Definition: "SELECT * FROM catalog2.public.customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"}, {Name: "phone"}, {Name: "name"},},},@@ -179,15 +180,15 @@ func TestQuerySpan_CrossCatalogViewResolvesToBase(t *testing.T) {},},}- cat2 := &storepb.DatabaseSchemaMetadata{+ cat2 := &metadatapb.DatabaseSchemaMetadata{Name: "catalog2",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "customer",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "phone", Type: "varchar"},{Name: "name", Type: "varchar"},@@ -197,7 +198,7 @@ func TestQuerySpan_CrossCatalogViewResolvesToBase(t *testing.T) {},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{cat1, cat2})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{cat1, cat2})gCtx := base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,ListDatabaseNamesFunc: lister,diff --git a/backend/plugin/parser/tsql/completion_test.go b/backend/plugin/parser/tsql/completion_test.goindex 10d4e8acfd..21b61ea671 100644--- a/backend/plugin/parser/tsql/completion_test.go+++ b/backend/plugin/parser/tsql/completion_test.go@@ -8,6 +8,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -143,16 +144,16 @@ func getCaretPosition(statement string) (string, int, int) {panic("caret position not found")}-var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{+var databaseMetadatas = []*metadatapb.DatabaseSchemaMetadata{{Name: "Company",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "Employees",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id",Type: "int",@@ -165,7 +166,7 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},{Name: "Address",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "EmployeeId",Type: "int",@@ -177,7 +178,7 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "EmployeeIdSeq",},@@ -185,7 +186,7 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{Name: "OrderSeq",},},- Procedures: []*storepb.ProcedureMetadata{+ Procedures: []*metadatapb.ProcedureMetadata{{Name: "SyncEmployees",},@@ -193,10 +194,10 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},{Name: "MySchema",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "SalaryLevel",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id",Type: "int",@@ -208,17 +209,17 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "SalaryView",},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "SalarySeq",},},- Procedures: []*storepb.ProcedureMetadata{+ Procedures: []*metadatapb.ProcedureMetadata{{Name: "SyncSalary",},@@ -228,13 +229,13 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},{Name: "School",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "Student",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "Id",Type: "int",@@ -246,12 +247,12 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{},},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "StudentSeq",},},- Procedures: []*storepb.ProcedureMetadata{+ Procedures: []*metadatapb.ProcedureMetadata{{Name: "SyncStudents",},diff --git a/backend/plugin/parser/tsql/query_span_extractor_test.go b/backend/plugin/parser/tsql/query_span_extractor_test.goindex be55586fd1..218c8e9527 100644--- a/backend/plugin/parser/tsql/query_span_extractor_test.go+++ b/backend/plugin/parser/tsql/query_span_extractor_test.go@@ -7,30 +7,30 @@ import ("slices""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base")// omniTestMetadata is the default mock catalog used by these tests.// db.dbo has tables t(a,b,c), t1(a,b,c), t2(a,b), and a view vw.-var omniTestMetadata = []*storepb.DatabaseSchemaMetadata{+var omniTestMetadata = []*metadatapb.DatabaseSchemaMetadata{{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{- {Name: "t", Columns: []*storepb.ColumnMetadata{{Name: "a"}, {Name: "b"}, {Name: "c"}}},- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "a"}, {Name: "b"}, {Name: "c"}}},- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "a"}, {Name: "b"}}},- {Name: "ident_t", Columns: []*storepb.ColumnMetadata{{Name: "id", IsIdentity: true}, {Name: "payload"}}},- {Name: "ident_t2", Columns: []*storepb.ColumnMetadata{{Name: "seq", IsIdentity: true}, {Name: "v"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "t", Columns: []*metadatapb.ColumnMetadata{{Name: "a"}, {Name: "b"}, {Name: "c"}}},+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "a"}, {Name: "b"}, {Name: "c"}}},+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "a"}, {Name: "b"}}},+ {Name: "ident_t", Columns: []*metadatapb.ColumnMetadata{{Name: "id", IsIdentity: true}, {Name: "payload"}}},+ {Name: "ident_t2", Columns: []*metadatapb.ColumnMetadata{{Name: "seq", IsIdentity: true}, {Name: "v"}}},{Name: "bare_edge"},- {Name: "weird", Columns: []*storepb.ColumnMetadata{{Name: "$node_id"}, {Name: "IDENTITYCOL"}}},+ {Name: "weird", Columns: []*metadatapb.ColumnMetadata{{Name: "$node_id"}, {Name: "IDENTITYCOL"}}},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "vw", Definition: "CREATE VIEW [dbo].[vw] AS SELECT a, b FROM t"},},},@@ -38,11 +38,11 @@ var omniTestMetadata = []*storepb.DatabaseSchemaMetadata{},{Name: "db2",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{- {Name: "t2", Columns: []*storepb.ColumnMetadata{{Name: "x"}, {Name: "y"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "t2", Columns: []*metadatapb.ColumnMetadata{{Name: "x"}, {Name: "y"}}},},},},diff --git a/backend/plugin/parser/tsql/query_span_test.go b/backend/plugin/parser/tsql/query_span_test.goindex d44a53033a..1c692f5aa8 100644--- a/backend/plugin/parser/tsql/query_span_test.go+++ b/backend/plugin/parser/tsql/query_span_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -23,7 +24,7 @@ func TestGetQuerySpan(t *testing.T) {Statement string `yaml:"statement,omitempty"`DefaultDatabase string `yaml:"defaultDatabase,omitempty"`IgnoreCaseSensitve bool `yaml:"ignoreCaseSensitive,omitempty"`- // Metadata is the protojson encoded storepb.DatabaseSchemaMetadata,+ // Metadata is the protojson encoded metadatapb.DatabaseSchemaMetadata,// if it's empty, we will use the defaultDatabaseMetadata.Metadata []string `yaml:"metadata,omitempty"`QuerySpan *base.YamlQuerySpan `yaml:"querySpan,omitempty"`@@ -53,9 +54,9 @@ func TestGetQuerySpan(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &testCases))for i, tc := range testCases {- var ms []*storepb.DatabaseSchemaMetadata+ var ms []*metadatapb.DatabaseSchemaMetadatafor _, metadata := range tc.Metadata {- storepbMetadata := &storepb.DatabaseSchemaMetadata{}+ storepbMetadata := &metadatapb.DatabaseSchemaMetadata{}a.NoErrorf(common.ProtojsonUnmarshaler.Unmarshal([]byte(metadata), storepbMetadata), "cases %d", i+1)ms = append(ms, storepbMetadata)}@@ -80,7 +81,7 @@ func TestGetQuerySpan(t *testing.T) {}}-func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {+func buildMockDatabaseMetadataGetter(databaseMetadata []*metadatapb.DatabaseSchemaMetadata) (base.GetDatabaseMetadataFunc, base.ListDatabaseNamesFunc) {return func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {m := make(map[string]*model.DatabaseMetadata)for _, metadata := range databaseMetadata {@@ -102,19 +103,19 @@ func buildMockDatabaseMetadataGetter(databaseMetadata []*storepb.DatabaseSchemaM}func TestGetQuerySpanCyclicViewReference(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1", Definition: "CREATE VIEW [dbo].[v1] AS SELECT * FROM v2"},{Name: "v2", Definition: "CREATE VIEW [dbo].[v2] AS SELECT * FROM v1"},},},},}- getter, lister := buildMockDatabaseMetadataGetter([]*storepb.DatabaseSchemaMetadata{metadata})+ getter, lister := buildMockDatabaseMetadataGetter([]*metadatapb.DatabaseSchemaMetadata{metadata})_, err := GetQuerySpan(context.Background(), base.GetQuerySpanContext{GetDatabaseMetadataFunc: getter,diff --git a/backend/plugin/parser/tsql/restore_test.go b/backend/plugin/parser/tsql/restore_test.goindex 50aa458ee4..85a2683af9 100644--- a/backend/plugin/parser/tsql/restore_test.go+++ b/backend/plugin/parser/tsql/restore_test.go@@ -8,6 +8,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -43,15 +44,15 @@ func TestRestoreIdentityHandling(t *testing.T) {if dbName == "" {dbName = databaseName}- return databaseName, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return databaseName, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: dbName,- Schemas: []*store.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "positions",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "position_id",Type: "int",@@ -265,15 +266,15 @@ func TestRestore(t *testing.T) {}func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database string) (string, *model.DatabaseMetadata, error) {- return database, model.NewDatabaseMetadata(&store.DatabaseSchemaMetadata{+ return database, model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: database,- Schemas: []*store.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*store.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t_generated",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -281,7 +282,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "b",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "t_generated_pk",Expressions: []string{"b"},@@ -297,7 +298,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "t1",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -311,7 +312,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "t2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -325,7 +326,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "test",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},@@ -336,7 +337,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strinName: "c",},},- Indexes: []*store.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "test_pk",Expressions: []string{"a"},@@ -347,7 +348,7 @@ func fixedMockDatabaseMetadataGetter(_ context.Context, _ string, database strin},{Name: "test2",- Columns: []*store.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",},diff --git a/backend/plugin/schema/clickhouse/get_database_definition.go b/backend/plugin/schema/clickhouse/get_database_definition.goindex 6f5146104a..c4c26fdfaa 100644--- a/backend/plugin/schema/clickhouse/get_database_definition.go+++ b/backend/plugin/schema/clickhouse/get_database_definition.go@@ -5,6 +5,8 @@ import ("io""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -15,7 +17,7 @@ func init() {schema.RegisterGetViewDefinition(storepb.Engine_CLICKHOUSE, GetViewDefinition)}-func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *metadatapb.DatabaseSchemaMetadata) (string, error) {toState := convertToDatabaseState(to)var sb strings.Builder@@ -30,7 +32,7 @@ func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseScreturn strings.TrimLeft(sb.String(), "\n"), nil}-func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(_ string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var buf strings.BuildertableState := convertToTableState(0, table)@@ -43,7 +45,7 @@ func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.Seqreturn buf.String(), nil}-func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(_ string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.BuilderviewState := convertToViewState(0, view)@@ -56,7 +58,7 @@ func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {return buf.String(), nil}-func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {+func writeTables(w io.StringWriter, to *metadatapb.DatabaseSchemaMetadata, state *databaseState) error {// Follow the order of the input schemas.for _, schema := range to.Schemas {schemaState, ok := state.schemas[schema.Name]@@ -86,7 +88,7 @@ func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *dreturn nil}-func writeViews(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {+func writeViews(w io.StringWriter, to *metadatapb.DatabaseSchemaMetadata, state *databaseState) error {// Follow the order of the input schemas.for _, schema := range to.Schemas {schemaState, ok := state.schemas[schema.Name]diff --git a/backend/plugin/schema/clickhouse/state.go b/backend/plugin/schema/clickhouse/state.goindex c80bbb55ff..bed26f62c7 100644--- a/backend/plugin/schema/clickhouse/state.go+++ b/backend/plugin/schema/clickhouse/state.go@@ -6,7 +6,8 @@ import ("slices""strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata"+"github.com/bytebase/bytebase/backend/plugin/db/util")@@ -21,7 +22,7 @@ func newDatabaseState() *databaseState {}}-func convertToDatabaseState(database *storepb.DatabaseSchemaMetadata) *databaseState {+func convertToDatabaseState(database *metadatapb.DatabaseSchemaMetadata) *databaseState {state := newDatabaseState()state.name = database.Namefor _, schema := range database.Schemas {@@ -43,7 +44,7 @@ func newSchemaState() *schemaState {}}-func convertToSchemaState(schema *storepb.SchemaMetadata) *schemaState {+func convertToSchemaState(schema *metadatapb.SchemaMetadata) *schemaState {state := newSchemaState()state.name = schema.Namefor i, table := range schema.Tables {@@ -137,7 +138,7 @@ func newTableState(id int, name string) *tableState {}}-func convertToTableState(id int, table *storepb.TableMetadata) *tableState {+func convertToTableState(id int, table *metadatapb.TableMetadata) *tableState {state := newTableState(id, table.Name)state.comment = table.Commentstate.engine = table.Engine@@ -215,7 +216,7 @@ func (c *columnState) toString(buf *strings.Builder) error {return nil}-func convertToColumnState(id int, column *storepb.ColumnMetadata) *columnState {+func convertToColumnState(id int, column *metadatapb.ColumnMetadata) *columnState {result := &columnState{id: id,name: column.Name,@@ -258,7 +259,7 @@ type viewState struct {comment string}-func convertToViewState(id int, view *storepb.ViewMetadata) *viewState {+func convertToViewState(id int, view *metadatapb.ViewMetadata) *viewState {return &viewState{id: id,name: view.Name,diff --git a/backend/plugin/schema/differ.go b/backend/plugin/schema/differ.goindex f26b73ca76..52c0d717c7 100644--- a/backend/plugin/schema/differ.go+++ b/backend/plugin/schema/differ.go@@ -4,6 +4,8 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"+"github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/store/model"@@ -68,8 +70,8 @@ type MetadataDiff struct {type SchemaDiff struct {Action MetadataDiffActionSchemaName string- OldSchema *storepb.SchemaMetadata- NewSchema *storepb.SchemaMetadata+ OldSchema *metadatapb.SchemaMetadata+ NewSchema *metadatapb.SchemaMetadata}// TableDiff represents changes to a table.@@ -77,8 +79,8 @@ type TableDiff struct {Action MetadataDiffActionSchemaName stringTableName string- OldTable *storepb.TableMetadata- NewTable *storepb.TableMetadata+ OldTable *metadatapb.TableMetadata+ NewTable *metadatapb.TableMetadata// Column changesColumnChanges []*ColumnDiff@@ -111,50 +113,50 @@ type TableDiff struct {// ColumnDiff represents changes to a column.type ColumnDiff struct {Action MetadataDiffAction- OldColumn *storepb.ColumnMetadata- NewColumn *storepb.ColumnMetadata+ OldColumn *metadatapb.ColumnMetadata+ NewColumn *metadatapb.ColumnMetadata}// IndexDiff represents changes to an index.type IndexDiff struct {Action MetadataDiffAction- OldIndex *storepb.IndexMetadata- NewIndex *storepb.IndexMetadata+ OldIndex *metadatapb.IndexMetadata+ NewIndex *metadatapb.IndexMetadata}// ForeignKeyDiff represents changes to a foreign key.type ForeignKeyDiff struct {Action MetadataDiffAction- OldForeignKey *storepb.ForeignKeyMetadata- NewForeignKey *storepb.ForeignKeyMetadata+ OldForeignKey *metadatapb.ForeignKeyMetadata+ NewForeignKey *metadatapb.ForeignKeyMetadata}// CheckConstraintDiff represents changes to a check constraint.type CheckConstraintDiff struct {Action MetadataDiffAction- OldCheckConstraint *storepb.CheckConstraintMetadata- NewCheckConstraint *storepb.CheckConstraintMetadata+ OldCheckConstraint *metadatapb.CheckConstraintMetadata+ NewCheckConstraint *metadatapb.CheckConstraintMetadata}// ExcludeConstraintDiff represents changes to an EXCLUDE constraint (PostgreSQL specific).type ExcludeConstraintDiff struct {Action MetadataDiffAction- OldExcludeConstraint *storepb.ExcludeConstraintMetadata- NewExcludeConstraint *storepb.ExcludeConstraintMetadata+ OldExcludeConstraint *metadatapb.ExcludeConstraintMetadata+ NewExcludeConstraint *metadatapb.ExcludeConstraintMetadata}// PrimaryKeyDiff represents changes to a primary key constraint.type PrimaryKeyDiff struct {Action MetadataDiffAction- OldPrimaryKey *storepb.IndexMetadata- NewPrimaryKey *storepb.IndexMetadata+ OldPrimaryKey *metadatapb.IndexMetadata+ NewPrimaryKey *metadatapb.IndexMetadata}// UniqueConstraintDiff represents changes to a unique constraint.type UniqueConstraintDiff struct {Action MetadataDiffAction- OldUniqueConstraint *storepb.IndexMetadata- NewUniqueConstraint *storepb.IndexMetadata+ OldUniqueConstraint *metadatapb.IndexMetadata+ NewUniqueConstraint *metadatapb.IndexMetadata}// TriggerDiff represents changes to a trigger.@@ -163,15 +165,15 @@ type TriggerDiff struct {SchemaName string // Schema name of the table that owns the triggerTableName string // Table name that owns the triggerTriggerName string // Trigger name- OldTrigger *storepb.TriggerMetadata- NewTrigger *storepb.TriggerMetadata+ OldTrigger *metadatapb.TriggerMetadata+ NewTrigger *metadatapb.TriggerMetadata}// PartitionDiff represents changes to table partitions.type PartitionDiff struct {Action MetadataDiffAction- OldPartition *storepb.TablePartitionMetadata- NewPartition *storepb.TablePartitionMetadata+ OldPartition *metadatapb.TablePartitionMetadata+ NewPartition *metadatapb.TablePartitionMetadata}// ViewDiff represents changes to a view.@@ -179,8 +181,8 @@ type ViewDiff struct {Action MetadataDiffActionSchemaName stringViewName string- OldView *storepb.ViewMetadata- NewView *storepb.ViewMetadata+ OldView *metadatapb.ViewMetadata+ NewView *metadatapb.ViewMetadata}// MaterializedViewDiff represents changes to a materialized view.@@ -188,8 +190,8 @@ type MaterializedViewDiff struct {Action MetadataDiffActionSchemaName stringMaterializedViewName string- OldMaterializedView *storepb.MaterializedViewMetadata- NewMaterializedView *storepb.MaterializedViewMetadata+ OldMaterializedView *metadatapb.MaterializedViewMetadata+ NewMaterializedView *metadatapb.MaterializedViewMetadataIndexChanges []*IndexDiff // Index changes on materialized view}@@ -198,8 +200,8 @@ type FunctionDiff struct {Action MetadataDiffActionSchemaName stringFunctionName string- OldFunction *storepb.FunctionMetadata- NewFunction *storepb.FunctionMetadata+ OldFunction *metadatapb.FunctionMetadata+ NewFunction *metadatapb.FunctionMetadata// Detailed change information for advanced enginesSignatureChanged bool@@ -214,8 +216,8 @@ type ProcedureDiff struct {Action MetadataDiffActionSchemaName stringProcedureName string- OldProcedure *storepb.ProcedureMetadata- NewProcedure *storepb.ProcedureMetadata+ OldProcedure *metadatapb.ProcedureMetadata+ NewProcedure *metadatapb.ProcedureMetadata}// SequenceDiff represents changes to a sequence.@@ -223,8 +225,8 @@ type SequenceDiff struct {Action MetadataDiffActionSchemaName stringSequenceName string- OldSequence *storepb.SequenceMetadata- NewSequence *storepb.SequenceMetadata+ OldSequence *metadatapb.SequenceMetadata+ NewSequence *metadatapb.SequenceMetadata}// EnumTypeDiff represents changes to an enum type.@@ -232,8 +234,8 @@ type EnumTypeDiff struct {Action MetadataDiffActionSchemaName stringEnumTypeName string- OldEnumType *storepb.EnumTypeMetadata- NewEnumType *storepb.EnumTypeMetadata+ OldEnumType *metadatapb.EnumTypeMetadata+ NewEnumType *metadatapb.EnumTypeMetadata}// CompositeTypeDiff represents changes to a composite type.@@ -241,32 +243,32 @@ type CompositeTypeDiff struct {Action MetadataDiffActionSchemaName stringCompositeTypeName string- OldCompositeType *storepb.CompositeTypeMetadata- NewCompositeType *storepb.CompositeTypeMetadata+ OldCompositeType *metadatapb.CompositeTypeMetadata+ NewCompositeType *metadatapb.CompositeTypeMetadata}// ExtensionDiff represents changes to an extension.type ExtensionDiff struct {Action MetadataDiffActionExtensionName string- OldExtension *storepb.ExtensionMetadata- NewExtension *storepb.ExtensionMetadata+ OldExtension *metadatapb.ExtensionMetadata+ NewExtension *metadatapb.ExtensionMetadata}// EventTriggerDiff represents changes to an event trigger.type EventTriggerDiff struct {Action MetadataDiffActionEventTriggerName string- OldEventTrigger *storepb.EventTriggerMetadata- NewEventTrigger *storepb.EventTriggerMetadata+ OldEventTrigger *metadatapb.EventTriggerMetadata+ NewEventTrigger *metadatapb.EventTriggerMetadata}// EventDiff represents changes to an event.type EventDiff struct {Action MetadataDiffActionEventName string- OldEvent *storepb.EventMetadata- NewEvent *storepb.EventMetadata+ OldEvent *metadatapb.EventMetadata+ NewEvent *metadatapb.EventMetadata}// CommentObjectType represents the type of database object that has a comment.@@ -664,7 +666,7 @@ func compareColumns(engine storepb.Engine, oldTable, newTable *model.TableMetada}// columnsEqual checks if two columns are equal.-func columnsEqual(engine storepb.Engine, col1, col2 *storepb.ColumnMetadata) bool {+func columnsEqual(engine storepb.Engine, col1, col2 *metadatapb.ColumnMetadata) bool {if col1.Type != col2.Type {return false}@@ -720,7 +722,7 @@ func columnsEqual(engine storepb.Engine, col1, col2 *storepb.ColumnMetadata) boo}// defaultValuesEqual compares default values.-func defaultValuesEqual(col1, col2 *storepb.ColumnMetadata) bool {+func defaultValuesEqual(col1, col2 *metadatapb.ColumnMetadata) bool {// Quick check for identical stringsif col1.Default == col2.Default {return true@@ -768,7 +770,7 @@ func normalizePostgreSQLTypecastInDefault(defaultValue string) string {}// generationMetadataEqual compares two generation metadata structs.-func generationMetadataEqual(engine storepb.Engine, gen1, gen2 *storepb.GenerationMetadata) bool {+func generationMetadataEqual(engine storepb.Engine, gen1, gen2 *metadatapb.GenerationMetadata) bool {if gen1 == nil && gen2 == nil {return true}@@ -820,7 +822,7 @@ func compareIndexes(engine storepb.Engine, oldTable, newTable *model.TableMetada}// indexesEqual checks if two indexes are equal.-func indexesEqual(engine storepb.Engine, idx1, idx2 *storepb.IndexMetadata) bool {+func indexesEqual(engine storepb.Engine, idx1, idx2 *metadatapb.IndexMetadata) bool {if idx1.Type != idx2.Type {return false}@@ -908,7 +910,7 @@ func descendingArraysEqual(desc1, desc2 []bool) bool {}// spatialConfigsEqual checks if two spatial index configurations are equal.-func spatialConfigsEqual(cfg1, cfg2 *storepb.SpatialIndexConfig) bool {+func spatialConfigsEqual(cfg1, cfg2 *metadatapb.SpatialIndexConfig) bool {if cfg1 == nil && cfg2 == nil {return true}@@ -951,7 +953,7 @@ func spatialConfigsEqual(cfg1, cfg2 *storepb.SpatialIndexConfig) bool {}// tessellationConfigsEqual checks if two tessellation configurations are equal.-func tessellationConfigsEqual(cfg1, cfg2 *storepb.TessellationConfig) bool {+func tessellationConfigsEqual(cfg1, cfg2 *metadatapb.TessellationConfig) bool {if cfg1 == nil && cfg2 == nil {return true}@@ -979,7 +981,7 @@ func tessellationConfigsEqual(cfg1, cfg2 *storepb.TessellationConfig) bool {}// boundingBoxesEqual checks if two bounding boxes are equal.-func boundingBoxesEqual(bb1, bb2 *storepb.BoundingBox) bool {+func boundingBoxesEqual(bb1, bb2 *metadatapb.BoundingBox) bool {if bb1 == nil && bb2 == nil {return true}@@ -994,7 +996,7 @@ func boundingBoxesEqual(bb1, bb2 *storepb.BoundingBox) bool {}// gridLevelsEqual checks if two grid level lists are equal.-func gridLevelsEqual(grids1, grids2 []*storepb.GridLevel) bool {+func gridLevelsEqual(grids1, grids2 []*metadatapb.GridLevel) bool {if len(grids1) != len(grids2) {return false}@@ -1010,7 +1012,7 @@ func gridLevelsEqual(grids1, grids2 []*storepb.GridLevel) bool {}// storageConfigsEqual checks if two storage configurations are equal.-func storageConfigsEqual(cfg1, cfg2 *storepb.StorageConfig) bool {+func storageConfigsEqual(cfg1, cfg2 *metadatapb.StorageConfig) bool {if cfg1 == nil && cfg2 == nil {return true}@@ -1035,7 +1037,7 @@ func storageConfigsEqual(cfg1, cfg2 *storepb.StorageConfig) bool {}// dimensionalConfigsEqual checks if two dimensional configurations are equal.-func dimensionalConfigsEqual(cfg1, cfg2 *storepb.DimensionalConfig) bool {+func dimensionalConfigsEqual(cfg1, cfg2 *metadatapb.DimensionalConfig) bool {if cfg1 == nil && cfg2 == nil {return true}@@ -1051,15 +1053,15 @@ func dimensionalConfigsEqual(cfg1, cfg2 *storepb.DimensionalConfig) bool {}// compareForeignKeys compares two lists of foreign keys.-func compareForeignKeys(oldFKs, newFKs []*storepb.ForeignKeyMetadata) []*ForeignKeyDiff {+func compareForeignKeys(oldFKs, newFKs []*metadatapb.ForeignKeyMetadata) []*ForeignKeyDiff {var changes []*ForeignKeyDiff- oldFKMap := make(map[string]*storepb.ForeignKeyMetadata)+ oldFKMap := make(map[string]*metadatapb.ForeignKeyMetadata)for _, fk := range oldFKs {oldFKMap[fk.Name] = fk}- newFKMap := make(map[string]*storepb.ForeignKeyMetadata)+ newFKMap := make(map[string]*metadatapb.ForeignKeyMetadata)for _, fk := range newFKs {newFKMap[fk.Name] = fk}@@ -1099,7 +1101,7 @@ func compareForeignKeys(oldFKs, newFKs []*storepb.ForeignKeyMetadata) []*Foreign}// foreignKeysEqual checks if two foreign keys are equal.-func foreignKeysEqual(fk1, fk2 *storepb.ForeignKeyMetadata) bool {+func foreignKeysEqual(fk1, fk2 *metadatapb.ForeignKeyMetadata) bool {if fk1.ReferencedSchema != fk2.ReferencedSchema {return false}@@ -1135,15 +1137,15 @@ func foreignKeysEqual(fk1, fk2 *storepb.ForeignKeyMetadata) bool {}// compareCheckConstraints compares two lists of check constraints.-func compareCheckConstraints(engine storepb.Engine, oldChecks, newChecks []*storepb.CheckConstraintMetadata) []*CheckConstraintDiff {+func compareCheckConstraints(engine storepb.Engine, oldChecks, newChecks []*metadatapb.CheckConstraintMetadata) []*CheckConstraintDiff {var changes []*CheckConstraintDiff- oldCheckMap := make(map[string]*storepb.CheckConstraintMetadata)+ oldCheckMap := make(map[string]*metadatapb.CheckConstraintMetadata)for _, check := range oldChecks {oldCheckMap[check.Name] = check}- newCheckMap := make(map[string]*storepb.CheckConstraintMetadata)+ newCheckMap := make(map[string]*metadatapb.CheckConstraintMetadata)for _, check := range newChecks {newCheckMap[check.Name] = check}@@ -1183,7 +1185,7 @@ func compareCheckConstraints(engine storepb.Engine, oldChecks, newChecks []*stor}// checkConstraintsEqual checks if two check constraints are equal.-func checkConstraintsEqual(engine storepb.Engine, check1, check2 *storepb.CheckConstraintMetadata) bool {+func checkConstraintsEqual(engine storepb.Engine, check1, check2 *metadatapb.CheckConstraintMetadata) bool {// First try semantic comparisonif CompareExpressionsSemantically(engine, check1.Expression, check2.Expression) {return true@@ -1355,15 +1357,15 @@ func extractAnyValues(expr string) []string {}// comparePartitions compares two lists of partitions.-func comparePartitions(engine storepb.Engine, oldPartitions, newPartitions []*storepb.TablePartitionMetadata) []*PartitionDiff {+func comparePartitions(engine storepb.Engine, oldPartitions, newPartitions []*metadatapb.TablePartitionMetadata) []*PartitionDiff {var changes []*PartitionDiff- oldPartMap := make(map[string]*storepb.TablePartitionMetadata)+ oldPartMap := make(map[string]*metadatapb.TablePartitionMetadata)for _, part := range oldPartitions {oldPartMap[part.Name] = part}- newPartMap := make(map[string]*storepb.TablePartitionMetadata)+ newPartMap := make(map[string]*metadatapb.TablePartitionMetadata)for _, part := range newPartitions {newPartMap[part.Name] = part}@@ -1403,15 +1405,15 @@ func comparePartitions(engine storepb.Engine, oldPartitions, newPartitions []*st}// compareTriggers compares two lists of triggers.-func compareTriggers(oldTriggers, newTriggers []*storepb.TriggerMetadata) []*TriggerDiff {+func compareTriggers(oldTriggers, newTriggers []*metadatapb.TriggerMetadata) []*TriggerDiff {var changes []*TriggerDiff- oldTriggerMap := make(map[string]*storepb.TriggerMetadata)+ oldTriggerMap := make(map[string]*metadatapb.TriggerMetadata)for _, trigger := range oldTriggers {oldTriggerMap[trigger.Name] = trigger}- newTriggerMap := make(map[string]*storepb.TriggerMetadata)+ newTriggerMap := make(map[string]*metadatapb.TriggerMetadata)for _, trigger := range newTriggers {newTriggerMap[trigger.Name] = trigger}@@ -1455,7 +1457,7 @@ func compareTriggers(oldTriggers, newTriggers []*storepb.TriggerMetadata) []*Tri}// triggersEqual checks if two triggers are equal.-func triggersEqual(t1, t2 *storepb.TriggerMetadata) bool {+func triggersEqual(t1, t2 *metadatapb.TriggerMetadata) bool {if t1 == nil || t2 == nil {return t1 == t2}@@ -1501,7 +1503,7 @@ func normalizeTriggerBody(body string) string {}// partitionsEqual checks if two partitions are equal.-func partitionsEqual(engine storepb.Engine, part1, part2 *storepb.TablePartitionMetadata) bool {+func partitionsEqual(engine storepb.Engine, part1, part2 *metadatapb.TablePartitionMetadata) bool {if part1.Type != part2.Type {return false}@@ -1519,7 +1521,7 @@ func partitionsEqual(engine storepb.Engine, part1, part2 *storepb.TablePartitionreturn false}// Create maps for subpartition comparison- subPart1Map := make(map[string]*storepb.TablePartitionMetadata)+ subPart1Map := make(map[string]*metadatapb.TablePartitionMetadata)for _, sub := range part1.Subpartitions {subPart1Map[sub.Name] = sub}@@ -1686,7 +1688,7 @@ func compareFunctions(engine storepb.Engine, diff *MetadataDiff, schemaName stri// Functions can have overloading, so we need to handle them carefully// Group functions by signature to properly match overloaded functions// Build map of old functions by signature- oldFuncsBySignature := make(map[string]*storepb.FunctionMetadata)+ oldFuncsBySignature := make(map[string]*metadatapb.FunctionMetadata)for _, fn := range oldSchema.GetProto().GetFunctions() {if !fn.GetSkipDump() {sig := fn.Signature@@ -1698,7 +1700,7 @@ func compareFunctions(engine storepb.Engine, diff *MetadataDiff, schemaName stri}// Build map of new functions by signature- newFuncsBySignature := make(map[string]*storepb.FunctionMetadata)+ newFuncsBySignature := make(map[string]*metadatapb.FunctionMetadata)for _, fn := range newSchema.GetProto().GetFunctions() {if !fn.GetSkipDump() {sig := fn.Signature@@ -1809,7 +1811,7 @@ func compareFunctions(engine storepb.Engine, diff *MetadataDiff, schemaName stri}// functionsEqual checks if two functions are equal.-func functionsEqual(fn1, fn2 *storepb.FunctionMetadata) bool {+func functionsEqual(fn1, fn2 *metadatapb.FunctionMetadata) bool {if fn1.Definition != fn2.Definition {// Try normalized comparison for PostgreSQL functionsnorm1 := normalizePostgreSQLFunction(fn1.Definition)@@ -1883,14 +1885,14 @@ func compareProcedures(diff *MetadataDiff, schemaName string, oldSchema, newSche// compareSequences compares sequences between two schemas.func compareSequences(diff *MetadataDiff, schemaName string, oldSchema, newSchema *model.SchemaMetadata) {// Get sequences from proto since there's no ListSequenceNames method- oldSeqMap := make(map[string]*storepb.SequenceMetadata)+ oldSeqMap := make(map[string]*metadatapb.SequenceMetadata)for _, seq := range oldSchema.GetProto().Sequences {if !seq.GetSkipDump() {oldSeqMap[seq.Name] = seq}}- newSeqMap := make(map[string]*storepb.SequenceMetadata)+ newSeqMap := make(map[string]*metadatapb.SequenceMetadata)for _, seq := range newSchema.GetProto().Sequences {if !seq.GetSkipDump() {newSeqMap[seq.Name] = seq@@ -1930,7 +1932,7 @@ func compareSequences(diff *MetadataDiff, schemaName string, oldSchema, newSchem}}-func sequencesEqual(oldSeq, newSeq *storepb.SequenceMetadata) bool {+func sequencesEqual(oldSeq, newSeq *metadatapb.SequenceMetadata) bool {return oldSeq.DataType == newSeq.DataType &&oldSeq.Start == newSeq.Start &&oldSeq.MinValue == newSeq.MinValue &&@@ -1949,14 +1951,14 @@ func compareEnumTypes(diff *MetadataDiff, schemaName string, oldSchema, newSchemnewSchemaProto := newSchema.GetProto()// Build maps of enum types- oldEnumMap := make(map[string]*storepb.EnumTypeMetadata)+ oldEnumMap := make(map[string]*metadatapb.EnumTypeMetadata)for _, enum := range oldSchemaProto.EnumTypes {if !enum.GetSkipDump() {oldEnumMap[enum.Name] = enum}}- newEnumMap := make(map[string]*storepb.EnumTypeMetadata)+ newEnumMap := make(map[string]*metadatapb.EnumTypeMetadata)for _, enum := range newSchemaProto.EnumTypes {if !enum.GetSkipDump() {newEnumMap[enum.Name] = enum@@ -2001,14 +2003,14 @@ func compareCompositeTypes(diff *MetadataDiff, schemaName string, oldSchema, newoldSchemaProto := oldSchema.GetProto()newSchemaProto := newSchema.GetProto()- oldCompositeMap := make(map[string]*storepb.CompositeTypeMetadata)+ oldCompositeMap := make(map[string]*metadatapb.CompositeTypeMetadata)for _, composite := range oldSchemaProto.CompositeTypes {if !composite.GetSkipDump() {oldCompositeMap[composite.Name] = composite}}- newCompositeMap := make(map[string]*storepb.CompositeTypeMetadata)+ newCompositeMap := make(map[string]*metadatapb.CompositeTypeMetadata)for _, composite := range newSchemaProto.CompositeTypes {if !composite.GetSkipDump() {newCompositeMap[composite.Name] = composite@@ -2049,7 +2051,7 @@ func compareCompositeTypes(diff *MetadataDiff, schemaName string, oldSchema, new}// compositeTypesEqual checks attributes (order-sensitive) and comments.-func compositeTypesEqual(oldComposite, newComposite *storepb.CompositeTypeMetadata) bool {+func compositeTypesEqual(oldComposite, newComposite *metadatapb.CompositeTypeMetadata) bool {if oldComposite.Comment != newComposite.Comment {return false}@@ -2082,14 +2084,14 @@ func enumValuesEqual(oldValues, newValues []string) bool {}// compareExtensions compares extensions between old and new database metadata.-func compareExtensions(diff *MetadataDiff, oldMetadata, newMetadata *storepb.DatabaseSchemaMetadata) {+func compareExtensions(diff *MetadataDiff, oldMetadata, newMetadata *metadatapb.DatabaseSchemaMetadata) {// Build maps of extensions- oldExtensionMap := make(map[string]*storepb.ExtensionMetadata)+ oldExtensionMap := make(map[string]*metadatapb.ExtensionMetadata)for _, extension := range oldMetadata.Extensions {oldExtensionMap[extension.Name] = extension}- newExtensionMap := make(map[string]*storepb.ExtensionMetadata)+ newExtensionMap := make(map[string]*metadatapb.ExtensionMetadata)for _, extension := range newMetadata.Extensions {newExtensionMap[extension.Name] = extension}@@ -2140,14 +2142,14 @@ func compareExtensions(diff *MetadataDiff, oldMetadata, newMetadata *storepb.Dat}// compareEventTriggers compares event triggers between old and new database metadata.-func compareEventTriggers(diff *MetadataDiff, oldMetadata, newMetadata *storepb.DatabaseSchemaMetadata) {+func compareEventTriggers(diff *MetadataDiff, oldMetadata, newMetadata *metadatapb.DatabaseSchemaMetadata) {// Build maps of event triggers- oldEventTriggerMap := make(map[string]*storepb.EventTriggerMetadata)+ oldEventTriggerMap := make(map[string]*metadatapb.EventTriggerMetadata)for _, eventTrigger := range oldMetadata.EventTriggers {oldEventTriggerMap[eventTrigger.Name] = eventTrigger}- newEventTriggerMap := make(map[string]*storepb.EventTriggerMetadata)+ newEventTriggerMap := make(map[string]*metadatapb.EventTriggerMetadata)for _, eventTrigger := range newMetadata.EventTriggers {newEventTriggerMap[eventTrigger.Name] = eventTrigger}@@ -2206,12 +2208,12 @@ func compareEvents(diff *MetadataDiff, _ string, oldSchema, newSchema *model.SchnewSchemaProto := newSchema.GetProto()// Build maps of events- oldEventMap := make(map[string]*storepb.EventMetadata)+ oldEventMap := make(map[string]*metadatapb.EventMetadata)for _, event := range oldSchemaProto.Events {oldEventMap[event.Name] = event}- newEventMap := make(map[string]*storepb.EventMetadata)+ newEventMap := make(map[string]*metadatapb.EventMetadata)for _, event := range newSchemaProto.Events {newEventMap[event.Name] = event}diff --git a/backend/plugin/schema/function_comparer.go b/backend/plugin/schema/function_comparer.goindex ea09c816f8..20d025ac98 100644--- a/backend/plugin/schema/function_comparer.go+++ b/backend/plugin/schema/function_comparer.go@@ -3,6 +3,8 @@ package schemaimport ("sync"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store")@@ -36,18 +38,18 @@ type FunctionComparisonResult struct {// FunctionComparer provides an interface for engine-specific function comparison logic.type FunctionComparer interface {// Equal compares two functions and returns whether they are equal.- Equal(oldFunc, newFunc *storepb.FunctionMetadata) bool+ Equal(oldFunc, newFunc *metadatapb.FunctionMetadata) bool// CompareDetailed performs detailed comparison and returns migration strategy information.// Returns nil if functions are equal.- CompareDetailed(oldFunc, newFunc *storepb.FunctionMetadata) (*FunctionComparisonResult, error)+ CompareDetailed(oldFunc, newFunc *metadatapb.FunctionMetadata) (*FunctionComparisonResult, error)}// DefaultFunctionComparer provides default function comparison logic that can be used by most engines.type DefaultFunctionComparer struct{}// Equal compares two functions using simple definition comparison.-func (*DefaultFunctionComparer) Equal(oldFunc, newFunc *storepb.FunctionMetadata) bool {+func (*DefaultFunctionComparer) Equal(oldFunc, newFunc *metadatapb.FunctionMetadata) bool {if oldFunc == nil || newFunc == nil {return oldFunc == newFunc}@@ -57,7 +59,7 @@ func (*DefaultFunctionComparer) Equal(oldFunc, newFunc *storepb.FunctionMetadata}// CompareDetailed provides basic comparison for engines that don't have advanced comparison logic.-func (*DefaultFunctionComparer) CompareDetailed(oldFunc, newFunc *storepb.FunctionMetadata) (*FunctionComparisonResult, error) {+func (*DefaultFunctionComparer) CompareDetailed(oldFunc, newFunc *metadatapb.FunctionMetadata) (*FunctionComparisonResult, error) {// For default implementation, if functions are equal, return nilif functionsEqual(oldFunc, newFunc) {return nil, nildiff --git a/backend/plugin/schema/mssql/generate_migration.go b/backend/plugin/schema/mssql/generate_migration.goindex d405f85643..6c3f89603d 100644--- a/backend/plugin/schema/mssql/generate_migration.go+++ b/backend/plugin/schema/mssql/generate_migration.go@@ -6,6 +6,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mssql/ast""github.com/pkg/errors"@@ -491,7 +492,7 @@ func generateMigration(diff *schema.MetadataDiff) (string, error) {return buf.String(), nil}-func generateCreateTable(schemaName, tableName string, table *storepb.TableMetadata) string {+func generateCreateTable(schemaName, tableName string, table *metadatapb.TableMetadata) string {var buf strings.Builder_, _ = buf.WriteString("CREATE TABLE [")@@ -683,7 +684,7 @@ func generateAlterTable(tableDiff *schema.TableDiff) string {return buf.String()}-func generateColumnDefinition(column *storepb.ColumnMetadata) string {+func generateColumnDefinition(column *metadatapb.ColumnMetadata) string {var buf strings.Builder_, _ = buf.WriteString("[")_, _ = buf.WriteString(column.Name)@@ -804,7 +805,7 @@ func generateAlterColumn(schemaName, tableName string, colDiff *schema.ColumnDif}// getColumnDefaultValue extracts the default value from a column-func getColumnDefaultValue(column *storepb.ColumnMetadata) string {+func getColumnDefaultValue(column *metadatapb.ColumnMetadata) string {if column == nil {return ""}@@ -814,7 +815,7 @@ func getColumnDefaultValue(column *storepb.ColumnMetadata) string {return ""}-func generateCreateIndex(schemaName, tableName string, index *storepb.IndexMetadata) string {+func generateCreateIndex(schemaName, tableName string, index *metadatapb.IndexMetadata) string {var buf strings.Builder_, _ = buf.WriteString("CREATE")@@ -894,7 +895,7 @@ func generateCreateIndex(schemaName, tableName string, index *storepb.IndexMetad}}-func generateAddForeignKey(schemaName, tableName string, fk *storepb.ForeignKeyMetadata) string {+func generateAddForeignKey(schemaName, tableName string, fk *metadatapb.ForeignKeyMetadata) string {var buf strings.Builder_, _ = buf.WriteString("ALTER TABLE [")@@ -953,7 +954,7 @@ func generateAddForeignKey(schemaName, tableName string, fk *storepb.ForeignKeyM}// hasConstraintsInTable checks if the table has any constraints (primary key or unique)-func hasConstraintsInTable(table *storepb.TableMetadata) bool {+func hasConstraintsInTable(table *metadatapb.TableMetadata) bool {for _, idx := range table.Indexes {if idx.IsConstraint {return true@@ -1099,12 +1100,12 @@ func getViewDependencies(viewDef string, schemaName string) ([]string, error) {base.GetQuerySpanContext{GetDatabaseMetadataFunc: func(_ context.Context, _, databaseName string) (string, *model.DatabaseMetadata, error) {// Return minimal metadata - we only need table references, not column info- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: databaseName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: schemaName,- Tables: []*storepb.TableMetadata{},+ Tables: []*metadatapb.TableMetadata{},},},}@@ -1493,7 +1494,7 @@ func hasCreateProcedures(diff *schema.MetadataDiff) bool {return false}-func generateSpatialIndexDDL(index *storepb.IndexMetadata, schemaName, tableName string) string {+func generateSpatialIndexDDL(index *metadatapb.IndexMetadata, schemaName, tableName string) string {var buf strings.Builder// Build the CREATE SPATIAL INDEX statement@@ -1553,7 +1554,7 @@ func generateSpatialIndexDDL(index *storepb.IndexMetadata, schemaName, tableNamereturn buf.String()}-func buildMigrationTessellationParams(tessellation *storepb.TessellationConfig) []string {+func buildMigrationTessellationParams(tessellation *metadatapb.TessellationConfig) []string {params := []string{}// BOUNDING_BOX for GEOMETRY indexes@@ -1582,7 +1583,7 @@ func buildMigrationTessellationParams(tessellation *storepb.TessellationConfig)return params}-func buildMigrationStorageParams(storage *storepb.StorageConfig) []string {+func buildMigrationStorageParams(storage *metadatapb.StorageConfig) []string {params := []string{}// PAD_INDEX (defaults to OFF, so only output when ON)diff --git a/backend/plugin/schema/mssql/generate_migration_test.go b/backend/plugin/schema/mssql/generate_migration_test.goindex 50be7f7e33..48c0f00154 100644--- a/backend/plugin/schema/mssql/generate_migration_test.go+++ b/backend/plugin/schema/mssql/generate_migration_test.go@@ -5,6 +5,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata"_ "github.com/microsoft/go-mssqldb""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -42,7 +43,7 @@ func TestGenerateMigration(t *testing.T) {for i, test := range tests {t.Run(test.Description, func(t *testing.T) {// Parse old schema- var oldMetadata *storepb.DatabaseSchemaMetadata+ var oldMetadata *metadatapb.DatabaseSchemaMetadataif test.OldSchema != "" {oldMetadata, err = GetDatabaseMetadata(test.OldSchema)require.NoErrorf(t, err, "Failed to parse old schema for test case [%02d]: %s", i+1, test.Description)@@ -65,9 +66,9 @@ func TestGenerateMigration(t *testing.T) {// Handle case where old schema is empty (creating from scratch)if test.OldSchema == "" && oldDBSchema == nil {// Create empty database schema for comparison- emptyMetadata := &storepb.DatabaseSchemaMetadata{+ emptyMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "",- Schemas: []*storepb.SchemaMetadata{},+ Schemas: []*metadatapb.SchemaMetadata{},}oldDBSchema = model.NewDatabaseMetadata(emptyMetadata, nil, nil, storepb.Engine_MSSQL, false)}@@ -75,12 +76,12 @@ func TestGenerateMigration(t *testing.T) {// Handle case where new schema is empty (dropping everything)if test.NewSchema == "" {// Create empty metadata with dbo schema to match the structure- emptyMetadata := &storepb.DatabaseSchemaMetadata{+ emptyMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{},+ Tables: []*metadatapb.TableMetadata{},},},}diff --git a/backend/plugin/schema/mssql/get_database_definition.go b/backend/plugin/schema/mssql/get_database_definition.goindex 2b247e1eb9..0bbc68768b 100644--- a/backend/plugin/schema/mssql/get_database_definition.go+++ b/backend/plugin/schema/mssql/get_database_definition.go@@ -5,6 +5,8 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/schema"@@ -22,7 +24,7 @@ func init() {schema.RegisterGetProcedureDefinition(storepb.Engine_MSSQL, GetProcedureDefinition)}-func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *metadatapb.DatabaseSchemaMetadata) (string, error) {if to == nil {return "", nil}@@ -65,13 +67,13 @@ func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseScreturn buf.String(), nil}-func GetTableDefinition(schemaName string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(schemaName string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var buf strings.BuilderwriteTable(&buf, schemaName, table)return buf.String(), nil}-func writeFunctionsAndProcedures(out *strings.Builder, schema *storepb.SchemaMetadata) {+func writeFunctionsAndProcedures(out *strings.Builder, schema *metadatapb.SchemaMetadata) {for _, function := range schema.Functions {writeFunction(out, schema.Name, function)}@@ -81,7 +83,7 @@ func writeFunctionsAndProcedures(out *strings.Builder, schema *storepb.SchemaMet}}-func hasViews(schemas []*storepb.SchemaMetadata) bool {+func hasViews(schemas []*metadatapb.SchemaMetadata) bool {for _, schema := range schemas {if len(schema.Views) > 0 {return true@@ -90,7 +92,7 @@ func hasViews(schemas []*storepb.SchemaMetadata) bool {return false}-func hasTables(schemas []*storepb.SchemaMetadata) bool {+func hasTables(schemas []*metadatapb.SchemaMetadata) bool {for _, schema := range schemas {if len(schema.Tables) > 0 {return true@@ -99,7 +101,7 @@ func hasTables(schemas []*storepb.SchemaMetadata) bool {return false}-func writeAllTablesInOrder(out *strings.Builder, schemas []*storepb.SchemaMetadata) {+func writeAllTablesInOrder(out *strings.Builder, schemas []*metadatapb.SchemaMetadata) {// Collect all tables from all schemasvar allTables []*tableWithSchemafor _, schema := range schemas {@@ -126,7 +128,7 @@ func writeAllTablesInOrder(out *strings.Builder, schemas []*storepb.SchemaMetadatype tableWithSchema struct {schema string- table *storepb.TableMetadata+ table *metadatapb.TableMetadata}// sortTablesByDependenciesAcrossSchemas sorts tables using topological sort considering cross-schema foreign key dependencies@@ -203,7 +205,7 @@ func sortTablesByDependenciesAcrossSchemas(tables []*tableWithSchema) []*tableWireturn result}-func writeAllViewsInOrder(out *strings.Builder, schemas []*storepb.SchemaMetadata) {+func writeAllViewsInOrder(out *strings.Builder, schemas []*metadatapb.SchemaMetadata) {// Collect all views from all schemasvar allViews []*viewWithSchemafor _, schema := range schemas {@@ -230,7 +232,7 @@ func writeAllViewsInOrder(out *strings.Builder, schemas []*storepb.SchemaMetadattype viewWithSchema struct {schema string- view *storepb.ViewMetadata+ view *metadatapb.ViewMetadata}// sortViewsByDependenciesAcrossSchemas sorts views using topological sort considering cross-schema dependencies@@ -310,7 +312,7 @@ func sortViewsByDependenciesAcrossSchemas(views []*viewWithSchema) []*viewWithScreturn result}-func writeTable(out *strings.Builder, schemaName string, table *storepb.TableMetadata) {+func writeTable(out *strings.Builder, schemaName string, table *metadatapb.TableMetadata) {_, _ = fmt.Fprintf(out, "CREATE TABLE [%s].[%s] (\n", schemaName, table.Name)for i, column := range table.Columns {if i != 0 {@@ -347,11 +349,11 @@ func writeTable(out *strings.Builder, schemaName string, table *storepb.TableMet}}-func writeClusteredColumnStoreIndex(out *strings.Builder, schemaName string, tableName string, index *storepb.IndexMetadata) {+func writeClusteredColumnStoreIndex(out *strings.Builder, schemaName string, tableName string, index *metadatapb.IndexMetadata) {_, _ = fmt.Fprintf(out, "CREATE CLUSTERED COLUMNSTORE INDEX [%s] ON [%s].[%s];\n\n", index.Name, schemaName, tableName)}-func writeNonClusteredColumnStoreIndex(out *strings.Builder, schemaName string, tableName string, index *storepb.IndexMetadata) {+func writeNonClusteredColumnStoreIndex(out *strings.Builder, schemaName string, tableName string, index *metadatapb.IndexMetadata) {_, _ = fmt.Fprintf(out, "CREATE NONCLUSTERED COLUMNSTORE INDEX [%s] ON [%s].[%s] (\n", index.Name, schemaName, tableName)for i, column := range index.Expressions {if i != 0 {@@ -362,14 +364,14 @@ func writeNonClusteredColumnStoreIndex(out *strings.Builder, schemaName string,_, _ = out.WriteString("\n);\n\n")}-func writeSpatialIndex(out *strings.Builder, schemaName string, tableName string, index *storepb.IndexMetadata) {+func writeSpatialIndex(out *strings.Builder, schemaName string, tableName string, index *metadatapb.IndexMetadata) {// Use the enhanced spatial index DDL generationspatialDDL := generateSpatialIndexDefinition(index, schemaName, tableName)_, _ = out.WriteString(spatialDDL)_, _ = out.WriteString(";\n\n")}-func writeNormalIndex(out *strings.Builder, schemaName string, tableName string, index *storepb.IndexMetadata) {+func writeNormalIndex(out *strings.Builder, schemaName string, tableName string, index *metadatapb.IndexMetadata) {_, _ = out.WriteString("CREATE")if index.Unique {_, _ = out.WriteString(" UNIQUE")@@ -392,7 +394,7 @@ func writeNormalIndex(out *strings.Builder, schemaName string, tableName string,_, _ = out.WriteString("\n);\n\n")}-func writeIndex(out *strings.Builder, schemaName string, tableName string, index *storepb.IndexMetadata) {+func writeIndex(out *strings.Builder, schemaName string, tableName string, index *metadatapb.IndexMetadata) {switch strings.ToUpper(index.Type) {case "CLUSTERED COLUMNSTORE":writeClusteredColumnStoreIndex(out, schemaName, tableName, index)@@ -405,11 +407,11 @@ func writeIndex(out *strings.Builder, schemaName string, tableName string, index}}-func writeCheck(out *strings.Builder, check *storepb.CheckConstraintMetadata) {+func writeCheck(out *strings.Builder, check *metadatapb.CheckConstraintMetadata) {_, _ = fmt.Fprintf(out, " CONSTRAINT [%s] CHECK %s", check.Name, check.Expression)}-func writeForeignKey(out *strings.Builder, fk *storepb.ForeignKeyMetadata) {+func writeForeignKey(out *strings.Builder, fk *metadatapb.ForeignKeyMetadata) {_, _ = fmt.Fprintf(out, " CONSTRAINT [%s] FOREIGN KEY (", fk.Name)for i, column := range fk.Columns {if i != 0 {@@ -433,7 +435,7 @@ func writeForeignKey(out *strings.Builder, fk *storepb.ForeignKeyMetadata) {}}-func writeKey(out *strings.Builder, key *storepb.IndexMetadata) {+func writeKey(out *strings.Builder, key *metadatapb.IndexMetadata) {_, _ = fmt.Fprintf(out, " CONSTRAINT [%s]", key.Name)if key.Primary {_, _ = out.WriteString(" PRIMARY KEY")@@ -459,7 +461,7 @@ func writeKey(out *strings.Builder, key *storepb.IndexMetadata) {_, _ = out.WriteString(")")}-func writeColumn(out *strings.Builder, column *storepb.ColumnMetadata) {+func writeColumn(out *strings.Builder, column *metadatapb.ColumnMetadata) {_, _ = fmt.Fprintf(out, " [%s] %s", column.Name, column.Type)if column.IsIdentity {_, _ = fmt.Fprintf(out, " IDENTITY(%d,%d)", column.IdentitySeed, column.IdentityIncrement)@@ -475,38 +477,38 @@ func writeColumn(out *strings.Builder, column *storepb.ColumnMetadata) {}}-func writeView(out *strings.Builder, _ string, view *storepb.ViewMetadata) {+func writeView(out *strings.Builder, _ string, view *metadatapb.ViewMetadata) {// The view definition already contains CREATE VIEW statement_, _ = fmt.Fprintf(out, "%s;\n\nGO\n\n", view.Definition)}-func writeFunction(out *strings.Builder, _ string, function *storepb.FunctionMetadata) {+func writeFunction(out *strings.Builder, _ string, function *metadatapb.FunctionMetadata) {_, _ = fmt.Fprintf(out, "%s\n\nGO\n\n", function.Definition)}-func writeProcedure(out *strings.Builder, _ string, procedure *storepb.ProcedureMetadata) {+func writeProcedure(out *strings.Builder, _ string, procedure *metadatapb.ProcedureMetadata) {_, _ = fmt.Fprintf(out, "%s\n\nGO\n\n", procedure.Definition)}-func GetViewDefinition(schemaName string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(schemaName string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.BuilderwriteView(&buf, schemaName, view)return buf.String(), nil}-func GetFunctionDefinition(schemaName string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(schemaName string, function *metadatapb.FunctionMetadata) (string, error) {var buf strings.BuilderwriteFunction(&buf, schemaName, function)return buf.String(), nil}-func GetProcedureDefinition(schemaName string, procedure *storepb.ProcedureMetadata) (string, error) {+func GetProcedureDefinition(schemaName string, procedure *metadatapb.ProcedureMetadata) (string, error) {var buf strings.BuilderwriteProcedure(&buf, schemaName, procedure)return buf.String(), nil}-func generateSpatialIndexDefinition(index *storepb.IndexMetadata, schemaName, tableName string) string {+func generateSpatialIndexDefinition(index *metadatapb.IndexMetadata, schemaName, tableName string) string {var buf strings.Builder// Build the CREATE SPATIAL INDEX statement@@ -563,7 +565,7 @@ func generateSpatialIndexDefinition(index *storepb.IndexMetadata, schemaName, tareturn buf.String()}-func buildTessellationParams(tessellation *storepb.TessellationConfig) []string {+func buildTessellationParams(tessellation *metadatapb.TessellationConfig) []string {params := []string{}// BOUNDING_BOX for GEOMETRY indexes@@ -592,7 +594,7 @@ func buildTessellationParams(tessellation *storepb.TessellationConfig) []stringreturn params}-func buildStorageParams(storage *storepb.StorageConfig) []string {+func buildStorageParams(storage *metadatapb.StorageConfig) []string {params := []string{}// PAD_INDEX (defaults to OFF, so only output when ON)diff --git a/backend/plugin/schema/mssql/get_database_definition_test.go b/backend/plugin/schema/mssql/get_database_definition_test.goindex 71ece9594d..4ba496582c 100644--- a/backend/plugin/schema/mssql/get_database_definition_test.go+++ b/backend/plugin/schema/mssql/get_database_definition_test.go@@ -4,13 +4,13 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata"_ "github.com/microsoft/go-mssqldb""github.com/stretchr/testify/require""gopkg.in/yaml.v3""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/yamltest"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -34,7 +34,7 @@ func TestGetDatabaseDefinition(t *testing.T) {for i, tc := range tests {t.Run(tc.Description, func(t *testing.T) {- var metadata storepb.DatabaseSchemaMetadata+ var metadata metadatapb.DatabaseSchemaMetadatarequire.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), &metadata))definition, err := GetDatabaseDefinition(schema.GetDefinitionContext{}, &metadata)diff --git a/backend/plugin/schema/mssql/get_database_metadata.go b/backend/plugin/schema/mssql/get_database_metadata.goindex 228a7bd690..656fa8f594 100644--- a/backend/plugin/schema/mssql/get_database_metadata.go+++ b/backend/plugin/schema/mssql/get_database_metadata.go@@ -6,29 +6,29 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mssql/ast""github.com/pkg/errors"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/tsql")const noAction = "NO ACTION"// GetDatabaseMetadata parses the SQL schema text and returns the database metadata.-func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error) {+func GetDatabaseMetadata(schemaText string) (*metadatapb.DatabaseSchemaMetadata, error) {stmts, err := tsql.ParseTSQL(schemaText)if err != nil {return nil, errors.Wrapf(err, "failed to parse SQL schema")}if len(stmts) == 0 {- return &storepb.DatabaseSchemaMetadata{+ return &metadatapb.DatabaseSchemaMetadata{Name: "",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "dbo",- Tables: []*storepb.TableMetadata{},+ Tables: []*metadatapb.TableMetadata{},},},}, nil@@ -36,8 +36,8 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, erextractor := &omniMetadataExtractor{currentSchema: "dbo",- schemas: make(map[string]*storepb.SchemaMetadata),- tables: make(map[tableKey]*storepb.TableMetadata),+ schemas: make(map[string]*metadatapb.SchemaMetadata),+ tables: make(map[tableKey]*metadatapb.TableMetadata),schemaText: schemaText,}@@ -51,7 +51,7 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, erreturn nil, extractor.err}- schemaMetadata := &storepb.DatabaseSchemaMetadata{+ schemaMetadata := &metadatapb.DatabaseSchemaMetadata{Name: extractor.currentDatabase,}@@ -71,23 +71,23 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, ertype omniMetadataExtractor struct {currentDatabase stringcurrentSchema string- schemas map[string]*storepb.SchemaMetadata- tables map[tableKey]*storepb.TableMetadata+ schemas map[string]*metadatapb.SchemaMetadata+ tables map[tableKey]*metadatapb.TableMetadataindexCounter intschemaText stringerr error}-func (e *omniMetadataExtractor) getOrCreateSchema(schemaName string) *storepb.SchemaMetadata {+func (e *omniMetadataExtractor) getOrCreateSchema(schemaName string) *metadatapb.SchemaMetadata {if schemaName == "" {schemaName = "dbo"}if schema, exists := e.schemas[schemaName]; exists {return schema}- schema := &storepb.SchemaMetadata{+ schema := &metadatapb.SchemaMetadata{Name: schemaName,- Tables: []*storepb.TableMetadata{},+ Tables: []*metadatapb.TableMetadata{},Views: nil,Procedures: nil,Functions: nil,@@ -97,15 +97,15 @@ func (e *omniMetadataExtractor) getOrCreateSchema(schemaName string) *storepb.Screturn schema}-func (e *omniMetadataExtractor) getOrCreateTable(schemaName, tableName string) *storepb.TableMetadata {+func (e *omniMetadataExtractor) getOrCreateTable(schemaName, tableName string) *metadatapb.TableMetadata {key := tableKey{schema: schemaName, table: tableName}if table, exists := e.tables[key]; exists {return table}- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: tableName,- Columns: []*storepb.ColumnMetadata{},- Indexes: []*storepb.IndexMetadata{},+ Columns: []*metadatapb.ColumnMetadata{},+ Indexes: []*metadatapb.IndexMetadata{},ForeignKeys: nil,CheckConstraints: nil,}@@ -138,9 +138,9 @@ func (e *omniMetadataExtractor) extractStatement(node ast.Node) {schemaName, viewName := tableRefSchemaObject(n.Name, e.currentSchema)schemaMetadata := e.getOrCreateSchema(schemaName)if schemaMetadata.Views == nil {- schemaMetadata.Views = []*storepb.ViewMetadata{}+ schemaMetadata.Views = []*metadatapb.ViewMetadata{}}- schemaMetadata.Views = append(schemaMetadata.Views, &storepb.ViewMetadata{+ schemaMetadata.Views = append(schemaMetadata.Views, &metadatapb.ViewMetadata{Name: viewName,Definition: e.definitionText(n),})@@ -148,9 +148,9 @@ func (e *omniMetadataExtractor) extractStatement(node ast.Node) {schemaName, procedureName := tableRefSchemaObject(n.Name, e.currentSchema)schemaMetadata := e.getOrCreateSchema(schemaName)if schemaMetadata.Procedures == nil {- schemaMetadata.Procedures = []*storepb.ProcedureMetadata{}+ schemaMetadata.Procedures = []*metadatapb.ProcedureMetadata{}}- schemaMetadata.Procedures = append(schemaMetadata.Procedures, &storepb.ProcedureMetadata{+ schemaMetadata.Procedures = append(schemaMetadata.Procedures, &metadatapb.ProcedureMetadata{Name: procedureName,Definition: e.definitionText(n),})@@ -158,9 +158,9 @@ func (e *omniMetadataExtractor) extractStatement(node ast.Node) {schemaName, functionName := tableRefSchemaObject(n.Name, e.currentSchema)schemaMetadata := e.getOrCreateSchema(schemaName)if schemaMetadata.Functions == nil {- schemaMetadata.Functions = []*storepb.FunctionMetadata{}+ schemaMetadata.Functions = []*metadatapb.FunctionMetadata{}}- schemaMetadata.Functions = append(schemaMetadata.Functions, &storepb.FunctionMetadata{+ schemaMetadata.Functions = append(schemaMetadata.Functions, &metadatapb.FunctionMetadata{Name: functionName,Definition: e.definitionText(n),})@@ -205,8 +205,8 @@ func (e *omniMetadataExtractor) extractCreateTable(n *ast.CreateTableStmt) {}}-func (e *omniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *storepb.TableMetadata, schemaName string) {- column := &storepb.ColumnMetadata{+func (e *omniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *metadatapb.TableMetadata, schemaName string) {+ column := &metadatapb.ColumnMetadata{Name: n.Name,Position: int32(len(table.Columns) + 1),Nullable: true,@@ -267,7 +267,7 @@ func (e *omniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *storepb.Ttable.Columns = append(table.Columns, column)}-func (e *omniMetadataExtractor) extractTableConstraint(n *ast.ConstraintDef, table *storepb.TableMetadata, schemaName string) {+func (e *omniMetadataExtractor) extractTableConstraint(n *ast.ConstraintDef, table *metadatapb.TableMetadata, schemaName string) {switch n.Type {case ast.ConstraintPrimaryKey:table.Indexes = append(table.Indexes, e.constraintIndexMetadata(n, "", indexColumnNames(n.Columns), true))@@ -285,7 +285,7 @@ func (e *omniMetadataExtractor) extractCreateIndex(n *ast.CreateIndexStmt) {schemaName, tableName := tableRefSchemaObject(n.Table, e.currentSchema)table := e.getOrCreateTable(schemaName, tableName)- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: n.Name,Unique: n.Unique,Type: indexType(n.Columnstore, n.Clustered),@@ -301,18 +301,18 @@ func (e *omniMetadataExtractor) extractCreateSpatialIndex(n *ast.CreateSpatialInschemaName, tableName := tableRefSchemaObject(n.Table, e.currentSchema)table := e.getOrCreateTable(schemaName, tableName)- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: n.Name,Type: "SPATIAL",Expressions: []string{},Descending: []bool{},IsConstraint: false,- SpatialConfig: &storepb.SpatialIndexConfig{+ SpatialConfig: &metadatapb.SpatialIndexConfig{Method: "SPATIAL",- Tessellation: &storepb.TessellationConfig{+ Tessellation: &metadatapb.TessellationConfig{Scheme: strings.ToUpper(n.Using),},- Dimensional: &storepb.DimensionalConfig{+ Dimensional: &metadatapb.DimensionalConfig{Dimensions: 2,},},@@ -333,23 +333,23 @@ func (e *omniMetadataExtractor) extractCreateSpatialIndex(n *ast.CreateSpatialInfunc (e *omniMetadataExtractor) extractCreateSequence(n *ast.CreateSequenceStmt) {schemaName, sequenceName := tableRefSchemaObject(n.Name, e.currentSchema)schemaMetadata := e.getOrCreateSchema(schemaName)- sequence := &storepb.SequenceMetadata{Name: sequenceName}+ sequence := &metadatapb.SequenceMetadata{Name: sequenceName}if n.DataType != nil {sequence.DataType = e.nodeText(n.DataType)}if schemaMetadata.Sequences == nil {- schemaMetadata.Sequences = []*storepb.SequenceMetadata{}+ schemaMetadata.Sequences = []*metadatapb.SequenceMetadata{}}schemaMetadata.Sequences = append(schemaMetadata.Sequences, sequence)}-func (e *omniMetadataExtractor) constraintIndexMetadata(n *ast.ConstraintDef, prefix string, columns []string, primary bool) *storepb.IndexMetadata {+func (e *omniMetadataExtractor) constraintIndexMetadata(n *ast.ConstraintDef, prefix string, columns []string, primary bool) *metadatapb.IndexMetadata {name := n.Nameif name == "" && prefix != "" {e.indexCounter++name = fmt.Sprintf("%s_%d", prefix, e.indexCounter)}- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: name,Primary: primary,Unique: true,@@ -368,8 +368,8 @@ func (e *omniMetadataExtractor) constraintIndexMetadata(n *ast.ConstraintDef, prreturn index}-func (*omniMetadataExtractor) inlineIndexMetadata(n *ast.InlineIndexDef) *storepb.IndexMetadata {- index := &storepb.IndexMetadata{+func (*omniMetadataExtractor) inlineIndexMetadata(n *ast.InlineIndexDef) *metadatapb.IndexMetadata {+ index := &metadatapb.IndexMetadata{Name: n.Name,Unique: n.Unique,Type: indexType(n.Columnstore, n.Clustered),@@ -381,19 +381,19 @@ func (*omniMetadataExtractor) inlineIndexMetadata(n *ast.InlineIndexDef) *storepreturn index}-func (e *omniMetadataExtractor) appendCheckConstraint(table *storepb.TableMetadata, n *ast.ConstraintDef) {- check := &storepb.CheckConstraintMetadata{+func (e *omniMetadataExtractor) appendCheckConstraint(table *metadatapb.TableMetadata, n *ast.ConstraintDef) {+ check := &metadatapb.CheckConstraintMetadata{Name: n.Name,Expression: e.nodeText(n.Expr),}if table.CheckConstraints == nil {- table.CheckConstraints = []*storepb.CheckConstraintMetadata{}+ table.CheckConstraints = []*metadatapb.CheckConstraintMetadata{}}table.CheckConstraints = append(table.CheckConstraints, check)}-func appendForeignKey(table *storepb.TableMetadata, n *ast.ConstraintDef, columns []string, fallbackSchema string) {- fk := &storepb.ForeignKeyMetadata{+func appendForeignKey(table *metadatapb.TableMetadata, n *ast.ConstraintDef, columns []string, fallbackSchema string) {+ fk := &metadatapb.ForeignKeyMetadata{Name: n.Name,Columns: columns,ReferencedColumns: stringNodeList(n.RefColumns),@@ -412,7 +412,7 @@ func appendForeignKey(table *storepb.TableMetadata, n *ast.ConstraintDef, columnfk.ReferencedTable = refTable}if table.ForeignKeys == nil {- table.ForeignKeys = []*storepb.ForeignKeyMetadata{}+ table.ForeignKeys = []*metadatapb.ForeignKeyMetadata{}}table.ForeignKeys = append(table.ForeignKeys, fk)}@@ -478,11 +478,11 @@ func (e *omniMetadataExtractor) applyComment(schemaName, tableName, columnName,table.Comment = comment}-func parseSpatialOptions(options *ast.List, index *storepb.IndexMetadata) {+func parseSpatialOptions(options *ast.List, index *metadatapb.IndexMetadata) {if options == nil {return}- index.SpatialConfig.Storage = &storepb.StorageConfig{+ index.SpatialConfig.Storage = &metadatapb.StorageConfig{AllowRowLocks: true,AllowPageLocks: true,}@@ -513,7 +513,7 @@ func parseSpatialOptions(options *ast.List, index *storepb.IndexMetadata) {}}-func parseBoundingBox(value string, index *storepb.IndexMetadata) {+func parseBoundingBox(value string, index *metadatapb.IndexMetadata) {value = strings.TrimSpace(strings.Trim(value, "()"))parts := strings.Split(value, ",")if len(parts) != 4 {@@ -527,7 +527,7 @@ func parseBoundingBox(value string, index *storepb.IndexMetadata) {}nums[i] = num}- index.SpatialConfig.Tessellation.BoundingBox = &storepb.BoundingBox{+ index.SpatialConfig.Tessellation.BoundingBox = &metadatapb.BoundingBox{Xmin: nums[0],Ymin: nums[1],Xmax: nums[2],@@ -535,9 +535,9 @@ func parseBoundingBox(value string, index *storepb.IndexMetadata) {}}-func parseGridLevels(value string, index *storepb.IndexMetadata) {+func parseGridLevels(value string, index *metadatapb.IndexMetadata) {value = strings.TrimSpace(strings.Trim(value, "()"))- var gridLevels []*storepb.GridLevel+ var gridLevels []*metadatapb.GridLevelfor _, part := range strings.Split(value, ",") {levelPart, densityPart, ok := strings.Cut(part, "=")if !ok {@@ -551,7 +551,7 @@ func parseGridLevels(value string, index *storepb.IndexMetadata) {levelNum = int32(num)}}- gridLevels = append(gridLevels, &storepb.GridLevel{+ gridLevels = append(gridLevels, &metadatapb.GridLevel{Level: levelNum,Density: strings.ToUpper(densityPart),})@@ -559,9 +559,9 @@ func parseGridLevels(value string, index *storepb.IndexMetadata) {index.SpatialConfig.Tessellation.GridLevels = gridLevels}-func parseSpatialStorageOption(name, value string, index *storepb.IndexMetadata) {+func parseSpatialStorageOption(name, value string, index *metadatapb.IndexMetadata) {if index.SpatialConfig.Storage == nil {- index.SpatialConfig.Storage = &storepb.StorageConfig{}+ index.SpatialConfig.Storage = &metadatapb.StorageConfig{}}storage := index.SpatialConfig.Storageswitch name {@@ -644,7 +644,7 @@ func indexType(columnstore bool, clustered *bool) string {return "NONCLUSTERED"}-func appendIndexColumns(index *storepb.IndexMetadata, columns *ast.List) {+func appendIndexColumns(index *metadatapb.IndexMetadata, columns *ast.List) {if columns == nil {return}diff --git a/backend/plugin/schema/mssql/get_database_metadata_test.go b/backend/plugin/schema/mssql/get_database_metadata_test.goindex 5efe94da33..e8fa3df7fb 100644--- a/backend/plugin/schema/mssql/get_database_metadata_test.go+++ b/backend/plugin/schema/mssql/get_database_metadata_test.go@@ -5,11 +5,11 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3""github.com/bytebase/bytebase/backend/common/yamltest"- storepb "github.com/bytebase/bytebase/backend/generated-go/store")func TestGetDatabaseMetadataSequenceUsesExplicitSchema(t *testing.T) {@@ -19,11 +19,11 @@ CREATE SEQUENCE audit.EventSeq AS BIGINT;`)require.NoError(t, err)- require.Equal(t, []*storepb.SchemaMetadata{+ require.Equal(t, []*metadatapb.SchemaMetadata{{Name: "audit",- Tables: []*storepb.TableMetadata{},- Sequences: []*storepb.SequenceMetadata{+ Tables: []*metadatapb.TableMetadata{},+ Sequences: []*metadatapb.SequenceMetadata{{Name: "EventSeq",DataType: "BIGINT",@@ -46,7 +46,7 @@ CREATE TABLE sales.orders (`)require.NoError(t, err)- var orders *storepb.TableMetadata+ var orders *metadatapb.TableMetadatafor _, table := range metadata.Schemas[0].Tables {if table.Name == "orders" {orders = tablediff --git a/backend/plugin/schema/mysql/format_view_body_test.go b/backend/plugin/schema/mysql/format_view_body_test.goindex cfff796050..dd7ba8fd7f 100644--- a/backend/plugin/schema/mysql/format_view_body_test.go+++ b/backend/plugin/schema/mysql/format_view_body_test.go@@ -24,9 +24,9 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -242,7 +242,7 @@ func TestWriteViewSDLPretty(t *testing.T) {require.NoError(t, err)var buf strings.Builder- require.NoError(t, writeViewSDL(&buf, db, &storepb.ViewMetadata{Name: "film_list", Definition: def}))+ require.NoError(t, writeViewSDL(&buf, db, &metadatapb.ViewMetadata{Name: "film_list", Definition: def}))want := "CREATE OR REPLACE VIEW `film_list` AS\n" + strings.TrimRight(string(golden), "\n") + ";\n\n"require.Equal(t, want, buf.String())}@@ -251,10 +251,10 @@ func TestWriteViewSDLPretty(t *testing.T) {// view content as the single-file dump (both share writeViewSDL — the multi-file ≡// single-file concat invariant the live suite checks at scale).func TestMultiFileViewSDLPretty(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{{- Views: []*storepb.ViewMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{+ Views: []*metadatapb.ViewMetadata{{Name: "v_pretty",Definition: "select `testdb`.`t1`.`a` AS `a` from `testdb`.`t1`",}},@@ -278,7 +278,7 @@ func TestMultiFileViewSDLPretty(t *testing.T) {func TestGetDatabaseMetadataParsesPrettyView(t *testing.T) {var buf strings.Builderbuf.WriteString("CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` varchar(10) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB;\n\n")- require.NoError(t, writeViewSDL(&buf, "testdb", &storepb.ViewMetadata{+ require.NoError(t, writeViewSDL(&buf, "testdb", &metadatapb.ViewMetadata{Name: "v_pretty",Definition: "select `testdb`.`t1`.`a` AS `a`,`testdb`.`t1`.`b` AS `b` from `testdb`.`t1` where (`testdb`.`t1`.`a` > 0)",}))diff --git a/backend/plugin/schema/mysql/generate_migration.go b/backend/plugin/schema/mysql/generate_migration.goindex 33003ef9c1..1a2acfb895 100644--- a/backend/plugin/schema/mysql/generate_migration.go+++ b/backend/plugin/schema/mysql/generate_migration.go@@ -6,6 +6,8 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/schema"@@ -14,7 +16,7 @@ import (// tableDrop holds drop operations for deduplicationtype tableDrop struct {checkConstraints map[string]string- indexes map[string]*storepb.IndexMetadata+ indexes map[string]*metadatapb.IndexMetadatacolumns map[string]string}@@ -145,7 +147,7 @@ func dropObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) error {if _, exists := dropsPerTable[tableName]; !exists {dropsPerTable[tableName] = &tableDrop{checkConstraints: make(map[string]string),- indexes: make(map[string]*storepb.IndexMetadata),+ indexes: make(map[string]*metadatapb.IndexMetadata),columns: make(map[string]string),}}@@ -526,7 +528,7 @@ func writeDropColumn(buf *strings.Builder, table, column string) error {return nil}-func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string, table *storepb.TableMetadata) error {+func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string, table *metadatapb.TableMetadata) error {_, _ = buf.WriteString("CREATE TABLE IF NOT EXISTS `")_, _ = buf.WriteString(tableName)_, _ = buf.WriteString("` (\n")@@ -645,7 +647,7 @@ func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string,// column.Generation. Both branches emit INVISIBLE before COMMENT, matching MySQL's// canonical SHOW CREATE order. Shared by writeAddColumn (ADD COLUMN) and writeModifyColumn// (MODIFY COLUMN), which differ only in the leading clause.-func writeColumnDefinitionBody(buf *strings.Builder, column *storepb.ColumnMetadata) {+func writeColumnDefinitionBody(buf *strings.Builder, column *metadatapb.ColumnMetadata) {_, _ = buf.WriteString(column.Type)if column.CharacterSet != "" {@@ -705,14 +707,14 @@ func writeColumnDefinitionBody(buf *strings.Builder, column *storepb.ColumnMetad// 8.0.32). INVISIBLE precedes COMMENT, matching MySQL's canonical order for both regular// and generated columns. Generated columns never carry DEFAULT / AUTO_INCREMENT / ON// UPDATE, so those clauses are intentionally omitted.-func writeGeneratedColumnAttributes(buf *strings.Builder, column *storepb.ColumnMetadata) {+func writeGeneratedColumnAttributes(buf *strings.Builder, column *metadatapb.ColumnMetadata) {_, _ = buf.WriteString(" GENERATED ALWAYS AS (")_, _ = buf.WriteString(column.Generation.Expression)_, _ = buf.WriteString(") ")switch column.Generation.Type {- case storepb.GenerationMetadata_TYPE_STORED:+ case metadatapb.GenerationMetadata_TYPE_STORED:_, _ = buf.WriteString("STORED")- case storepb.GenerationMetadata_TYPE_VIRTUAL:+ case metadatapb.GenerationMetadata_TYPE_VIRTUAL:_, _ = buf.WriteString("VIRTUAL")default:// Default to VIRTUAL for unknown types@@ -738,7 +740,7 @@ func writeGeneratedColumnAttributes(buf *strings.Builder, column *storepb.Column}}-func writeAddColumn(buf *strings.Builder, table string, column *storepb.ColumnMetadata) error {+func writeAddColumn(buf *strings.Builder, table string, column *metadatapb.ColumnMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD COLUMN `")@@ -752,7 +754,7 @@ func writeAddColumn(buf *strings.Builder, table string, column *storepb.ColumnMereturn nil}-func writeModifyColumn(buf *strings.Builder, table string, column *storepb.ColumnMetadata) error {+func writeModifyColumn(buf *strings.Builder, table string, column *metadatapb.ColumnMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` MODIFY COLUMN `")@@ -764,7 +766,7 @@ func writeModifyColumn(buf *strings.Builder, table string, column *storepb.Columreturn nil}-func writeCreateIndex(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeCreateIndex(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("CREATE ")// Handle special index typesif strings.ToUpper(index.Type) == "FULLTEXT" {@@ -825,7 +827,7 @@ func writeCreateIndex(buf *strings.Builder, table string, index *storepb.IndexMereturn nil}-func writeAddPrimaryKey(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeAddPrimaryKey(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD PRIMARY KEY (")@@ -843,7 +845,7 @@ func writeAddPrimaryKey(buf *strings.Builder, table string, index *storepb.Indexreturn nil}-func writeAddUniqueKey(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeAddUniqueKey(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD UNIQUE KEY `")@@ -863,7 +865,7 @@ func writeAddUniqueKey(buf *strings.Builder, table string, index *storepb.IndexMreturn nil}-func writeAddCheckConstraint(buf *strings.Builder, table string, check *storepb.CheckConstraintMetadata) error {+func writeAddCheckConstraint(buf *strings.Builder, table string, check *metadatapb.CheckConstraintMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD CONSTRAINT `")@@ -875,7 +877,7 @@ func writeAddCheckConstraint(buf *strings.Builder, table string, check *storepb.return nil}-func writeAddForeignKey(buf *strings.Builder, table string, fk *storepb.ForeignKeyMetadata) error {+func writeAddForeignKey(buf *strings.Builder, table string, fk *metadatapb.ForeignKeyMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD CONSTRAINT `")@@ -919,7 +921,7 @@ func writeAddForeignKey(buf *strings.Builder, table string, fk *storepb.ForeignKreturn nil}-func writeCreateOrReplaceView(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeCreateOrReplaceView(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {_, _ = buf.WriteString("CREATE OR REPLACE VIEW `")_, _ = buf.WriteString(viewName)_, _ = buf.WriteString("` AS ")@@ -1024,7 +1026,7 @@ func hasCreateOrAlterObjects(diff *schema.MetadataDiff) bool {return false}-func getDefaultExpression(column *storepb.ColumnMetadata) string {+func getDefaultExpression(column *metadatapb.ColumnMetadata) string {if column == nil {return ""}@@ -1037,7 +1039,7 @@ func getDefaultExpression(column *storepb.ColumnMetadata) string {return ""}-func hasDefaultValue(column *storepb.ColumnMetadata) bool {+func hasDefaultValue(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}@@ -1048,7 +1050,7 @@ func hasDefaultValue(column *storepb.ColumnMetadata) bool {return column.Default != ""}-func hasAutoIncrement(column *storepb.ColumnMetadata) bool {+func hasAutoIncrement(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}@@ -1056,7 +1058,7 @@ func hasAutoIncrement(column *storepb.ColumnMetadata) bool {return strings.EqualFold(column.GetDefault(), "AUTO_INCREMENT")}-func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {// Create a temporary view with SELECT 1 AS column_name structure// to satisfy other views that depend on this view_, _ = buf.WriteString("CREATE OR REPLACE VIEW `")@@ -1081,7 +1083,7 @@ func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *storreturn nil}-func writeCreateTemporaryView(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeCreateTemporaryView(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {// Create a temporary view with SELECT 1 AS column_name structure// to satisfy views that depend on this view before we create the real one_, _ = buf.WriteString("CREATE VIEW `")@@ -1106,7 +1108,7 @@ func writeCreateTemporaryView(buf *strings.Builder, viewName string, view *storereturn nil}-func writeCreateTrigger(buf *strings.Builder, tableName string, trigger *storepb.TriggerMetadata) error {+func writeCreateTrigger(buf *strings.Builder, tableName string, trigger *metadatapb.TriggerMetadata) error {// Don't add DELIMITER statements - construct the complete trigger statement_, _ = buf.WriteString("CREATE TRIGGER `")_, _ = buf.WriteString(trigger.Name)diff --git a/backend/plugin/schema/mysql/generate_migration_test.go b/backend/plugin/schema/mysql/generate_migration_test.goindex fd8add65b9..88d80f1453 100644--- a/backend/plugin/schema/mysql/generate_migration_test.go+++ b/backend/plugin/schema/mysql/generate_migration_test.go@@ -5,6 +5,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata"_ "github.com/go-sql-driver/mysql""github.com/stretchr/testify/require"@@ -67,7 +68,7 @@ func TestGenerateMigration(t *testing.T) {func parseSchema(t *testing.T, text string) *model.DatabaseMetadata {t.Helper()- metadata := &storepb.DatabaseSchemaMetadata{Schemas: []*storepb.SchemaMetadata{{}}}+ metadata := &metadatapb.DatabaseSchemaMetadata{Schemas: []*metadatapb.SchemaMetadata{{}}}if text != "" {parsed, err := GetDatabaseMetadata(text)require.NoError(t, err)@@ -76,36 +77,36 @@ func parseSchema(t *testing.T, text string) *model.DatabaseMetadata {return model.NewDatabaseMetadata(metadata, nil, nil, storepb.Engine_MYSQL, false)}-func partitionedTable(partitionCount int) *storepb.TableMetadata {- table := &storepb.TableMetadata{+func partitionedTable(partitionCount int) *metadatapb.TableMetadata {+ table := &metadatapb.TableMetadata{Name: "ads_member_asset_by_account_channel_d",Engine: "InnoDB",Charset: "utf8mb4",Collation: "utf8mb4_general_ci",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "dt", Type: "date", Nullable: false},{Name: "member_id", Type: "bigint", Nullable: false},{Name: "account_type", Type: "varchar(50)", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Expressions: []string{"dt", "member_id", "account_type"}, Primary: true, Unique: true, Visible: true, Type: "BTREE"},{Name: "sindex", Expressions: []string{"dt", "member_id", "account_type"}, Visible: true, Type: "BTREE"},},}for i := range partitionCount {- table.Partitions = append(table.Partitions, &storepb.TablePartitionMetadata{+ table.Partitions = append(table.Partitions, &metadatapb.TablePartitionMetadata{Name: fmt.Sprintf("p%d", i),- Type: storepb.TablePartitionMetadata_RANGE,+ Type: metadatapb.TablePartitionMetadata_RANGE,Expression: "to_days(`dt`)",Value: fmt.Sprintf("%d", 739000+i),})}return table}-func databaseOf(tables ...*storepb.TableMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+func databaseOf(tables ...*metadatapb.TableMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: tables}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: tables}},}, nil, &storepb.DatabaseConfig{}, storepb.Engine_MYSQL, true)}@@ -122,7 +123,7 @@ func TestDiffMigrationPartitionedTableEmittedOnce(t *testing.T) {a.Equal(1, strings.Count(migration, "CREATE INDEX `sindex`"), "sindex must be emitted once:\n%s", migration)// Target has the table but neither the primary key nor the index: the 1068 shape.- bare := &storepb.TableMetadata{+ bare := &metadatapb.TableMetadata{Name: source.Name,Engine: source.Engine,Charset: source.Charset,@@ -181,9 +182,9 @@ func TestDiffMigrationPartitionEngineMatchesTable(t *testing.T) {func TestDiffMigrationQuotesPartitionNames(t *testing.T) {a := require.New(t)source := partitionedTable(0)- source.Partitions = []*storepb.TablePartitionMetadata{- {Name: "select", Type: storepb.TablePartitionMetadata_RANGE, Expression: "to_days(`dt`)", Value: "739000"},- {Name: "order", Type: storepb.TablePartitionMetadata_RANGE, Expression: "to_days(`dt`)", Value: "MAXVALUE"},+ source.Partitions = []*metadatapb.TablePartitionMetadata{+ {Name: "select", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "to_days(`dt`)", Value: "739000"},+ {Name: "order", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "to_days(`dt`)", Value: "MAXVALUE"},}migration, err := schema.DiffMigration(storepb.Engine_MYSQL, databaseOf(), databaseOf(source))@@ -206,18 +207,18 @@ func tableAction(diff *schema.MetadataDiff, name string) schema.MetadataDiffActi// some other table may carry that name, and resolving it as if it were the table makes the// differ miss a drop and mistake a create for a modification of the partition's owner.func TestDiffMigrationPartitionAliasDoesNotMaskTableExistence(t *testing.T) {- archive := &storepb.TableMetadata{+ archive := &metadatapb.TableMetadata{Name: "archive", Engine: "InnoDB",- Columns: []*storepb.ColumnMetadata{{Name: "archive_col", Type: "int"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "archive_col", Type: "int"}},}- events := func(partitions ...*storepb.TablePartitionMetadata) *storepb.TableMetadata {- return &storepb.TableMetadata{+ events := func(partitions ...*metadatapb.TablePartitionMetadata) *metadatapb.TableMetadata {+ return &metadatapb.TableMetadata{Name: "events", Engine: "InnoDB",- Columns: []*storepb.ColumnMetadata{{Name: "events_col", Type: "int"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "events_col", Type: "int"}},Partitions: partitions,}}- alias := &storepb.TablePartitionMetadata{Name: "archive", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"}+ alias := &metadatapb.TablePartitionMetadata{Name: "archive", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"}t.Run("drop", func(t *testing.T) {a := require.New(t)diff --git a/backend/plugin/schema/mysql/get_database_definition.go b/backend/plugin/schema/mysql/get_database_definition.goindex 88651c8ff2..5338aef90b 100644--- a/backend/plugin/schema/mysql/get_database_definition.go+++ b/backend/plugin/schema/mysql/get_database_definition.go@@ -8,6 +8,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -66,7 +67,7 @@ func init() {schema.RegisterGetProcedureDefinition(storepb.Engine_OCEANBASE, GetProcedureDefinition)}-func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {if len(metadata.Schemas) == 0 {return "", nil}@@ -160,7 +161,7 @@ func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.Dareturn buf.String(), nil}-func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(_ string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var buf strings.Builderif err := writeTable(&buf, table); err != nil {return "", err@@ -168,7 +169,7 @@ func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.Seqreturn buf.String(), nil}-func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(_ string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.Builderif err := writeView(&buf, view); err != nil {return "", err@@ -176,7 +177,7 @@ func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {return buf.String(), nil}-func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(_ string, function *metadatapb.FunctionMetadata) (string, error) {var buf strings.Builderif err := writeFunction(&buf, function); err != nil {return "", err@@ -184,7 +185,7 @@ func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (stringreturn buf.String(), nil}-func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (string, error) {+func GetProcedureDefinition(_ string, procedure *metadatapb.ProcedureMetadata) (string, error) {var buf strings.Builderif err := writeProcedure(&buf, procedure); err != nil {return "", err@@ -192,7 +193,7 @@ func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (strreturn buf.String(), nil}-func writeEvent(out io.Writer, event *storepb.EventMetadata) error {+func writeEvent(out io.Writer, event *metadatapb.EventMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -285,7 +286,7 @@ func writeEvent(out io.Writer, event *storepb.EventMetadata) error {return err}-func writeTrigger(out io.Writer, tableName string, trigger *storepb.TriggerMetadata) error {+func writeTrigger(out io.Writer, tableName string, trigger *metadatapb.TriggerMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -393,7 +394,7 @@ func writeTrigger(out io.Writer, tableName string, trigger *storepb.TriggerMetadreturn err}-func writeProcedure(out io.Writer, procedure *storepb.ProcedureMetadata) error {+func writeProcedure(out io.Writer, procedure *metadatapb.ProcedureMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -439,7 +440,7 @@ func writeProcedure(out io.Writer, procedure *storepb.ProcedureMetadata) error {return err}-func writeFunction(out io.Writer, function *storepb.FunctionMetadata) error {+func writeFunction(out io.Writer, function *metadatapb.FunctionMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -481,7 +482,7 @@ func writeFunction(out io.Writer, function *storepb.FunctionMetadata) error {return err}-func writeView(out io.Writer, view *storepb.ViewMetadata) error {+func writeView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -519,7 +520,7 @@ func writeView(out io.Writer, view *storepb.ViewMetadata) error {return err}-func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {+func writeTable(out *strings.Builder, table *metadatapb.TableMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -619,7 +620,7 @@ func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {}// Copy the logic from backend/plugin/schema/mysql/state.go.-func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartitionMetadata, engine string) error {+func printPartitionClause(buf *strings.Builder, partitions []*metadatapb.TablePartitionMetadata, engine string) error {if len(partitions) == 0 {return nil}@@ -629,35 +630,35 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn err}switch partitions[0].Type {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:if _, err := fmt.Fprintf(buf, "RANGE (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:if _, err := fmt.Fprintf(buf, "RANGE COLUMNS (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:if _, err := fmt.Fprintf(buf, "LIST (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:if _, err := fmt.Fprintf(buf, "LIST COLUMNS (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:if _, err := fmt.Fprintf(buf, "HASH (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:if _, err := fmt.Fprintf(buf, "KEY (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_HASH:+ case metadatapb.TablePartitionMetadata_LINEAR_HASH:if _, err := fmt.Fprintf(buf, "LINEAR HASH (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_LINEAR_KEY:if _, err := fmt.Fprintf(buf, "LINEAR KEY (%s)", partitions[0].Expression); err != nil {return err}@@ -684,19 +685,19 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn err}switch partitions[0].Subpartitions[0].Type {- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:if _, err := fmt.Fprintf(buf, "HASH (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_HASH:+ case metadatapb.TablePartitionMetadata_LINEAR_HASH:if _, err := fmt.Fprintf(buf, "LINEAR HASH (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:if _, err := fmt.Fprintf(buf, "KEY (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_LINEAR_KEY:if _, err := fmt.Fprintf(buf, "LINEAR KEY (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}@@ -791,17 +792,17 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn nil}-func getPrepositionByType(tp storepb.TablePartitionMetadata_Type) (string, error) {+func getPrepositionByType(tp metadatapb.TablePartitionMetadata_Type) (string, error) {switch tp {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:return "LESS THAN", nil- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:return "LESS THAN", nil- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:return "IN", nil- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:return "IN", nil- case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_HASH, storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_HASH, metadatapb.TablePartitionMetadata_KEY, metadatapb.TablePartitionMetadata_LINEAR_HASH, metadatapb.TablePartitionMetadata_LINEAR_KEY:return "", nildefault:return "", errors.Errorf("unsupported partition type: %v", tp)@@ -848,26 +849,26 @@ func writePartitionOptions(buf io.StringWriter, engine string) error {return nil}-func getVersionSpecificComment(partitions []*storepb.TablePartitionMetadata) string {+func getVersionSpecificComment(partitions []*metadatapb.TablePartitionMetadata) string {if len(partitions) == 0 {return ""}partition := partitions[0]- if partition.Type == storepb.TablePartitionMetadata_RANGE_COLUMNS || partition.Type == storepb.TablePartitionMetadata_LIST_COLUMNS {+ if partition.Type == metadatapb.TablePartitionMetadata_RANGE_COLUMNS || partition.Type == metadatapb.TablePartitionMetadata_LIST_COLUMNS {// MySQL introduce columns partitioning in 5.5+return "\n/*!50500"}return "\n/*!50100"}-func printCheckClause(buf *strings.Builder, check *storepb.CheckConstraintMetadata) error {+func printCheckClause(buf *strings.Builder, check *metadatapb.CheckConstraintMetadata) error {if _, err := fmt.Fprintf(buf, ",\n CONSTRAINT `%s` CHECK %s", check.Name, check.Expression); err != nil {return err}return nil}-func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata) error {+func printForeignKeyClause(buf *strings.Builder, fk *metadatapb.ForeignKeyMetadata) error {if _, err := fmt.Fprintf(buf, ",\n CONSTRAINT `%s` FOREIGN KEY (", fk.Name); err != nil {return err}@@ -917,7 +918,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)return nil}-func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error {+func printIndexClause(buf *strings.Builder, index *metadatapb.IndexMetadata) error {if index.Primary {return nil}@@ -1157,7 +1158,7 @@ func isCharsetNameByte(c byte) bool {return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'}-func printPrimaryKeyClause(buf *strings.Builder, indexes []*storepb.IndexMetadata) error {+func printPrimaryKeyClause(buf *strings.Builder, indexes []*metadatapb.IndexMetadata) error {for _, index := range indexes {if index.Primary {if _, err := fmt.Fprint(buf, ",\n PRIMARY KEY ("); err != nil {@@ -1192,11 +1193,11 @@ func printPrimaryKeyClause(buf *strings.Builder, indexes []*storepb.IndexMetadatreturn nil}-func isAutoIncrement(column *storepb.ColumnMetadata) bool {+func isAutoIncrement(column *metadatapb.ColumnMetadata) bool {return strings.EqualFold(column.GetDefault(), autoIncrementSymbol)}-func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, table *storepb.TableMetadata) error {+func printColumnClause(buf *strings.Builder, column *metadatapb.ColumnMetadata, table *metadatapb.TableMetadata) error {if _, err := fmt.Fprintf(buf, " `%s` %s", column.Name, normalizeColumnType(column.Type)); err != nil {return err}@@ -1218,11 +1219,11 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tabreturn err}switch column.Generation.Type {- case storepb.GenerationMetadata_TYPE_STORED:+ case metadatapb.GenerationMetadata_TYPE_STORED:if _, err := fmt.Fprint(buf, "STORED"); err != nil {return err}- case storepb.GenerationMetadata_TYPE_VIRTUAL:+ case metadatapb.GenerationMetadata_TYPE_VIRTUAL:if _, err := fmt.Fprint(buf, "VIRTUAL"); err != nil {return err}@@ -1279,7 +1280,7 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tab// zero sentinel) distinguishes from "no SRID". Shared by the SDL dumper// (printColumnClause) and the legacy migration generator (writeAddColumn /// writeModifyColumn) so both render the same canonical form.-func writeColumnSRIDAttribute(buf *strings.Builder, column *storepb.ColumnMetadata) {+func writeColumnSRIDAttribute(buf *strings.Builder, column *metadatapb.ColumnMetadata) {if column.Srid != nil {_, _ = fmt.Fprintf(buf, " /*!80003 SRID %d */", column.GetSrid())}@@ -1289,7 +1290,7 @@ func writeColumnSRIDAttribute(buf *strings.Builder, column *storepb.ColumnMetada// invisible columns (MySQL 8.0.23+). MySQL's canonical SHOW CREATE order places INVISIBLE// before COMMENT for both regular and generated columns (verified against 8.0.32), so callers// emit it before COMMENT. Shared by the SDL dumper and the legacy migration generator.-func writeColumnInvisibleAttribute(buf *strings.Builder, column *storepb.ColumnMetadata) {+func writeColumnInvisibleAttribute(buf *strings.Builder, column *metadatapb.ColumnMetadata) {if column.IsInvisible {_, _ = buf.WriteString(" /*!80023 INVISIBLE */")}@@ -1308,7 +1309,7 @@ func normalizeColumnType(columnType string) string {return columnType}-func printDefaultClause(buf *strings.Builder, column *storepb.ColumnMetadata) error {+func printDefaultClause(buf *strings.Builder, column *metadatapb.ColumnMetadata) error {// Check if column has any default valuehasDefault := column.Default != ""if !hasDefault {@@ -1355,7 +1356,7 @@ func printDefaultClause(buf *strings.Builder, column *storepb.ColumnMetadata) er// (DEFAULT b'0'); match it by recovering the inner literal and emitting it without the// surrounding quotes when the column is BIT and the recovered text is a bit/hex literal// (b'…'/0x…/x'…'). Any other default (including a genuine string) is emitted verbatim.-func renderColumnDefault(column *storepb.ColumnMetadata) string {+func renderColumnDefault(column *metadatapb.ColumnMetadata) string {if isBitColumnType(column.Type) {if lit, ok := bitLiteralFromQuotedDefault(column.Default); ok {return lit@@ -1449,7 +1450,7 @@ func typeSupportsDefaultValue(tp string) bool {}}-func writeInvalidTemporaryView(out io.Writer, view *storepb.ViewMetadata) error {+func writeInvalidTemporaryView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -1479,7 +1480,7 @@ func writeInvalidTemporaryView(out io.Writer, view *storepb.ViewMetadata) errorreturn err}-func writeTemporaryView(out io.Writer, view *storepb.ViewMetadata) error {+func writeTemporaryView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -1597,19 +1598,19 @@ func writeAdditionalEventsIfSet(out io.Writer, characterSetClient, characterSetR// here: the omni Diff path resolves both the dumped source and the user target// through the same Normalizer (CanonicalColumn), so faithful emission is sufficient// for the no-op idempotence property — the canonical comparison happens in omni.-func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func getSDLFormat(metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {var buf strings.Builderschema := metadata.Schemas[0]- tables := make([]*storepb.TableMetadata, 0, len(schema.Tables))+ tables := make([]*metadatapb.TableMetadata, 0, len(schema.Tables))for _, table := range schema.Tables {if table.SkipDump {continue}tables = append(tables, table)}- slices.SortFunc(tables, func(a, b *storepb.TableMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(tables, func(a, b *metadatapb.TableMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, table := range tables {if err := writeTableSDL(&buf, table); err != nil {@@ -1617,42 +1618,42 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {}}- functions := make([]*storepb.FunctionMetadata, 0, len(schema.Functions))+ functions := make([]*metadatapb.FunctionMetadata, 0, len(schema.Functions))for _, function := range schema.Functions {if function.SkipDump {continue}functions = append(functions, function)}- slices.SortFunc(functions, func(a, b *storepb.FunctionMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(functions, func(a, b *metadatapb.FunctionMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, function := range functions {if err := writeRoutineSDL(&buf, function.Definition); err != nil {return "", err}}- procedures := make([]*storepb.ProcedureMetadata, 0, len(schema.Procedures))+ procedures := make([]*metadatapb.ProcedureMetadata, 0, len(schema.Procedures))for _, procedure := range schema.Procedures {if procedure.SkipDump {continue}procedures = append(procedures, procedure)}- slices.SortFunc(procedures, func(a, b *storepb.ProcedureMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(procedures, func(a, b *metadatapb.ProcedureMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, procedure := range procedures {if err := writeRoutineSDL(&buf, procedure.Definition); err != nil {return "", err}}- views := make([]*storepb.ViewMetadata, 0, len(schema.Views))+ views := make([]*metadatapb.ViewMetadata, 0, len(schema.Views))for _, view := range schema.Views {if view.SkipDump {continue}views = append(views, view)}- slices.SortFunc(views, func(a, b *storepb.ViewMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(views, func(a, b *metadatapb.ViewMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, view := range views {if err := writeViewSDL(&buf, metadata.Name, view); err != nil {@@ -1663,14 +1664,14 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {// Triggers hang off tables (TableMetadata.Triggers); emit them after every table// in deterministic (table, trigger) order.for _, table := range tables {- triggers := make([]*storepb.TriggerMetadata, 0, len(table.Triggers))+ triggers := make([]*metadatapb.TriggerMetadata, 0, len(table.Triggers))for _, trigger := range table.Triggers {if trigger.SkipDump {continue}triggers = append(triggers, trigger)}- slices.SortFunc(triggers, func(a, b *storepb.TriggerMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(triggers, func(a, b *metadatapb.TriggerMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, trigger := range triggers {if err := writeTriggerSDL(&buf, table.Name, trigger); err != nil {return "", err@@ -1678,9 +1679,9 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {}}- events := make([]*storepb.EventMetadata, 0, len(schema.Events))+ events := make([]*metadatapb.EventMetadata, 0, len(schema.Events))events = append(events, schema.Events...)- slices.SortFunc(events, func(a, b *storepb.EventMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(events, func(a, b *metadatapb.EventMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, event := range events {if err := writeEventSDL(&buf, event); err != nil {return "", err@@ -1694,7 +1695,7 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {// deterministic clause ordering. It reuses the same column/index/foreign-key/check// clause writers as the mysqldump path; only the statement framing and the sorting// of sub-objects differ.-func writeTableSDL(buf *strings.Builder, table *storepb.TableMetadata) error {+func writeTableSDL(buf *strings.Builder, table *metadatapb.TableMetadata) error {if _, err := fmt.Fprintf(buf, "CREATE TABLE `%s` (\n", table.Name); err != nil {return err}@@ -1714,32 +1715,32 @@ func writeTableSDL(buf *strings.Builder, table *storepb.TableMetadata) error {return err}- secondaryIndexes := make([]*storepb.IndexMetadata, 0, len(table.Indexes))+ secondaryIndexes := make([]*metadatapb.IndexMetadata, 0, len(table.Indexes))for _, index := range table.Indexes {if index.Primary {continue}secondaryIndexes = append(secondaryIndexes, index)}- slices.SortFunc(secondaryIndexes, func(a, b *storepb.IndexMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(secondaryIndexes, func(a, b *metadatapb.IndexMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, index := range secondaryIndexes {if err := printIndexClause(buf, index); err != nil {return err}}- foreignKeys := make([]*storepb.ForeignKeyMetadata, len(table.ForeignKeys))+ foreignKeys := make([]*metadatapb.ForeignKeyMetadata, len(table.ForeignKeys))copy(foreignKeys, table.ForeignKeys)- slices.SortFunc(foreignKeys, func(a, b *storepb.ForeignKeyMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(foreignKeys, func(a, b *metadatapb.ForeignKeyMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, fk := range foreignKeys {if err := printForeignKeyClause(buf, fk); err != nil {return err}}- checks := make([]*storepb.CheckConstraintMetadata, len(table.CheckConstraints))+ checks := make([]*metadatapb.CheckConstraintMetadata, len(table.CheckConstraints))copy(checks, table.CheckConstraints)- slices.SortFunc(checks, func(a, b *storepb.CheckConstraintMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(checks, func(a, b *metadatapb.CheckConstraintMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, check := range checks {if err := printCheckClause(buf, check); err != nil {return err@@ -1828,7 +1829,7 @@ func filterCreateOptions(createOptions string) string {// entry TestSDLStressViewDerivedTable57). The stored one-line body is then// pretty-printed by formatViewBodySDL — a whitespace-only, deterministic rewrite, so// the omni no-op invariant and the dump-cycle byte stability both hold.-func writeViewSDL(buf *strings.Builder, dbName string, view *storepb.ViewMetadata) error {+func writeViewSDL(buf *strings.Builder, dbName string, view *metadatapb.ViewMetadata) error {body := formatViewBodySDL(stripViewBodyDatabaseQualifier(view.Definition, dbName))if body == "" {// Defensive: an empty definition keeps the historical inline framing.@@ -1933,7 +1934,7 @@ func writeRoutineSDL(buf *strings.Builder, definition string) error {// loader expects: `CREATE TRIGGER <name> <timing> <event> ON <table> FOR EACH ROW// <body>`. DEFINER is omitted (omni's trigger differ ignores it) and the body is// emitted verbatim (compared byte for byte after trimming).-func writeTriggerSDL(buf *strings.Builder, tableName string, trigger *storepb.TriggerMetadata) error {+func writeTriggerSDL(buf *strings.Builder, tableName string, trigger *metadatapb.TriggerMetadata) error {if _, err := fmt.Fprintf(buf, "CREATE TRIGGER `%s` %s %s ON `%s` FOR EACH ROW\n%s;\n\n",trigger.Name, trigger.Timing, trigger.Event, tableName, strings.TrimSpace(trigger.Body)); err != nil {return err@@ -1947,7 +1948,7 @@ func writeTriggerSDL(buf *strings.Builder, tableName string, trigger *storepb.Tr// identity. The schedule's auto-injected STARTS '<create-time>' is left intact: omni's// event differ normalizes STARTS out of the canonical schedule key, so it does not// perturb the no-op.-func writeEventSDL(buf *strings.Builder, event *storepb.EventMetadata) error {+func writeEventSDL(buf *strings.Builder, event *metadatapb.EventMetadata) error {def := strings.TrimSpace(stripLeadingDefiner(event.Definition))if def == "" {return nildiff --git a/backend/plugin/schema/mysql/get_database_definition_test.go b/backend/plugin/schema/mysql/get_database_definition_test.goindex e43dfe8021..4f16e7f115 100644--- a/backend/plugin/schema/mysql/get_database_definition_test.go+++ b/backend/plugin/schema/mysql/get_database_definition_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata"_ "github.com/go-sql-driver/mysql""github.com/stretchr/testify/require"@@ -13,18 +14,17 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/yamltest"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")func TestGetTableDefinitionWithCheckConstraint(t *testing.T) {- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "type", Type: "varchar(10)", Nullable: true, Default: "NULL"},{Name: "amount", Type: "decimal(10,2)", Nullable: true, Default: "NULL"},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "c1",// The expression as synced from MySQL after unescaping the@@ -53,7 +53,7 @@ func TestGetTableDefinitionWithCheckConstraint(t *testing.T) {}func TestGetFunctionDefinitionWithMultilineParameters(t *testing.T) {- function := &storepb.FunctionMetadata{+ function := &metadatapb.FunctionMetadata{Name: "f1",// The definition as synced from SHOW CREATE FUNCTION: the parameter// list keeps its original multi-line formatting, and the CHARSET and@@ -119,23 +119,23 @@ func TestRenderColumnDefaultBitLiteral(t *testing.T) {}for _, tc := range testCases {t.Run(tc.name, func(t *testing.T) {- got := renderColumnDefault(&storepb.ColumnMetadata{Type: tc.columnType, Default: tc.def})+ got := renderColumnDefault(&metadatapb.ColumnMetadata{Type: tc.columnType, Default: tc.def})require.Equal(t, tc.want, got)})}}func TestPrintColumnClauseBitDefaultUnquoted(t *testing.T) {- table := &storepb.TableMetadata{Name: "t", Charset: "utf8mb4"}+ table := &metadatapb.TableMetadata{Name: "t", Charset: "utf8mb4"}var buf strings.Builder- col := &storepb.ColumnMetadata{Name: "b1", Type: "bit(1)", Nullable: false, Default: `'b\'0\''`}+ col := &metadatapb.ColumnMetadata{Name: "b1", Type: "bit(1)", Nullable: false, Default: `'b\'0\''`}require.NoError(t, printColumnClause(&buf, col, table))require.Equal(t, " `b1` bit(1) NOT NULL DEFAULT b'0'", buf.String())// A BIT column with no default (b64 BIT(64)) must stay fine: NULL default emitted as// DEFAULT NULL, never as a bit literal.var buf2 strings.Builder- col2 := &storepb.ColumnMetadata{Name: "b64", Type: "bit(64)", Nullable: true, Default: "NULL"}+ col2 := &metadatapb.ColumnMetadata{Name: "b64", Type: "bit(64)", Nullable: true, Default: "NULL"}require.NoError(t, printColumnClause(&buf2, col2, table))require.Equal(t, " `b64` bit(64) DEFAULT NULL", buf2.String())}@@ -189,7 +189,7 @@ func TestNormalizeFunctionalIndexExpr(t *testing.T) {func TestPrintIndexClauseFunctionalExprNormalized(t *testing.T) {var buf strings.Builder- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: "idx_tags",Visible: true,Expressions: []string{"(cast(json_extract(`tags`,_utf8mb4\\'$.ids\\') as unsigned array))"},@@ -371,23 +371,23 @@ func TestStripLeadingDefiner(t *testing.T) {// distinct from "no SRID"), and an unset SRID emits nothing.func TestPrintColumnClauseSRIDPresence(t *testing.T) {srid := func(v uint32) *uint32 { return &v }- table := &storepb.TableMetadata{Name: "t"}+ table := &metadatapb.TableMetadata{Name: "t"}- render := func(col *storepb.ColumnMetadata) string {+ render := func(col *metadatapb.ColumnMetadata) string {var buf strings.Builderrequire.NoError(t, printColumnClause(&buf, col, table))return buf.String()}require.Equal(t, " `pt` point NOT NULL /*!80003 SRID 0 */",- render(&storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(0)}))+ render(&metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(0)}))require.Equal(t, " `pt` point NOT NULL /*!80003 SRID 4326 */",- render(&storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)}))+ render(&metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)}))// Custom SRSs above int32 range must render unmangled.require.Equal(t, " `pt` point NOT NULL /*!80003 SRID 3000000000 */",- render(&storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(3000000000)}))+ render(&metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(3000000000)}))require.Equal(t, " `pt` point NOT NULL",- render(&storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false}))+ render(&metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false}))}// TestPrintColumnClauseInvisibleCommentOrder pins the SDL dumper's INVISIBLE/COMMENT order@@ -396,9 +396,9 @@ func TestPrintColumnClauseSRIDPresence(t *testing.T) {// the dump diverges from SHOW CREATE and from the migration generator's generated-column path.func TestPrintColumnClauseInvisibleCommentOrder(t *testing.T) {srid := func(v uint32) *uint32 { return &v }- table := &storepb.TableMetadata{Name: "t"}+ table := &metadatapb.TableMetadata{Name: "t"}- render := func(col *storepb.ColumnMetadata) string {+ render := func(col *metadatapb.ColumnMetadata) string {var buf strings.Builderrequire.NoError(t, printColumnClause(&buf, col, table))return buf.String()@@ -406,13 +406,13 @@ func TestPrintColumnClauseInvisibleCommentOrder(t *testing.T) {// Regular INVISIBLE + COMMENT column: INVISIBLE precedes COMMENT.require.Equal(t, " `a` int DEFAULT NULL /*!80023 INVISIBLE */ COMMENT 'c'",- render(&storepb.ColumnMetadata{Name: "a", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true, Comment: "c"}))+ render(&metadatapb.ColumnMetadata{Name: "a", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true, Comment: "c"}))// Generated spatial INVISIBLE + COMMENT column: same canonical INVISIBLE-before-COMMENT order.require.Equal(t," `loc` point GENERATED ALWAYS AS (st_srid(point(`lng`,`lat`),4326)) STORED NOT NULL /*!80003 SRID 4326 */ /*!80023 INVISIBLE */ COMMENT 'geo'",- render(&storepb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), IsInvisible: true, Comment: "geo", Generation: &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ render(&metadatapb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), IsInvisible: true, Comment: "geo", Generation: &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: "st_srid(point(`lng`,`lat`),4326)",}}))}@@ -427,12 +427,12 @@ func TestPrintColumnClauseInvisibleCommentOrder(t *testing.T) {// type GENERATED ALWAYS AS (expr) STORED|VIRTUAL [NOT NULL] [SRID] [INVISIBLE] [COMMENT]func TestWriteColumnDefinitionBodyGeneratedOrder(t *testing.T) {srid := func(v uint32) *uint32 { return &v }- stored := &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ stored := &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: "st_srid(point(`lng`,`lat`),4326)",}- render := func(col *storepb.ColumnMetadata) string {+ render := func(col *metadatapb.ColumnMetadata) string {var buf strings.BuilderwriteColumnDefinitionBody(&buf, col)return buf.String()@@ -442,31 +442,31 @@ func TestWriteColumnDefinitionBodyGeneratedOrder(t *testing.T) {// must come first, then NOT NULL, then SRID.require.Equal(t,"point GENERATED ALWAYS AS (st_srid(point(`lng`,`lat`),4326)) STORED NOT NULL /*!80003 SRID 4326 */",- render(&storepb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), Generation: stored}))+ render(&metadatapb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), Generation: stored}))// Nullable generated spatial column: no NOT NULL, SRID still after the generation clause.require.Equal(t,"point GENERATED ALWAYS AS (st_srid(point(`lng`,`lat`),4326)) STORED /*!80003 SRID 0 */",- render(&storepb.ColumnMetadata{Name: "loc", Type: "point", Nullable: true, Srid: srid(0), Generation: stored}))+ render(&metadatapb.ColumnMetadata{Name: "loc", Type: "point", Nullable: true, Srid: srid(0), Generation: stored}))// Generated spatial column that is also INVISIBLE and has a COMMENT: INVISIBLE precedes// COMMENT, matching SHOW CREATE's canonical order for both regular and generated columns.require.Equal(t,"point GENERATED ALWAYS AS (st_srid(point(`lng`,`lat`),4326)) STORED NOT NULL /*!80003 SRID 4326 */ /*!80023 INVISIBLE */ COMMENT 'geo'",- render(&storepb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), IsInvisible: true, Comment: "geo", Generation: stored}))+ render(&metadatapb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326), IsInvisible: true, Comment: "geo", Generation: stored}))// Regular (non-generated) INVISIBLE column with a COMMENT: INVISIBLE precedes COMMENT,// the same canonical order as the generated column above (verified against 8.0.32).require.Equal(t,"int DEFAULT NULL /*!80023 INVISIBLE */ COMMENT 'c'",- render(&storepb.ColumnMetadata{Name: "a", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true, Comment: "c"}))+ render(&metadatapb.ColumnMetadata{Name: "a", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true, Comment: "c"}))// Plain (non-spatial) VIRTUAL generated column still emits the generation clause and// nothing spurious.require.Equal(t,"int GENERATED ALWAYS AS (`a` + 1) VIRTUAL",- render(&storepb.ColumnMetadata{Name: "b", Type: "int", Nullable: true, Generation: &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_VIRTUAL,+ render(&metadatapb.ColumnMetadata{Name: "b", Type: "int", Nullable: true, Generation: &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_VIRTUAL,Expression: "`a` + 1",}}))@@ -474,7 +474,7 @@ func TestWriteColumnDefinitionBodyGeneratedOrder(t *testing.T) {// (NOT NULL then SRID, no generation clause).require.Equal(t,"point NOT NULL /*!80003 SRID 4326 */",- render(&storepb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326)}))+ render(&metadatapb.ColumnMetadata{Name: "loc", Type: "point", Nullable: false, Srid: srid(4326)}))}type getDatabaseDefinitionCase struct {@@ -533,7 +533,7 @@ func TestGetDatabaseDefinition(t *testing.T) {for i, tc := range tests {t.Run(tc.Description, func(t *testing.T) {- var metadata storepb.DatabaseSchemaMetadata+ var metadata metadatapb.DatabaseSchemaMetadatarequire.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), &metadata))definition, err := GetDatabaseDefinition(schema.GetDefinitionContext{PrintHeader: true}, &metadata)diff --git a/backend/plugin/schema/mysql/get_database_metadata.go b/backend/plugin/schema/mysql/get_database_metadata.goindex fde7952897..cf01530ca0 100644--- a/backend/plugin/schema/mysql/get_database_metadata.go+++ b/backend/plugin/schema/mysql/get_database_metadata.go@@ -3,6 +3,7 @@ package mysqlimport ("fmt"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/catalog""github.com/pkg/errors"@@ -17,9 +18,9 @@ func init() {// GetDatabaseMetadata parses MySQL schema DDL text and returns database metadata// using the omni catalog.-func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error) {+func GetDatabaseMetadata(schemaText string) (*metadatapb.DatabaseSchemaMetadata, error) {if schemaText == "" {- return &storepb.DatabaseSchemaMetadata{}, nil+ return &metadatapb.DatabaseSchemaMetadata{}, nil}const dbName = "tmp"diff --git a/backend/plugin/schema/mysql/get_multi_file_definition.go b/backend/plugin/schema/mysql/get_multi_file_definition.goindex 040d11e468..196512c0ce 100644--- a/backend/plugin/schema/mysql/get_multi_file_definition.go+++ b/backend/plugin/schema/mysql/get_multi_file_definition.go@@ -6,6 +6,8 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -32,7 +34,7 @@ func init() {// multi-file always agree. Objects are emitted sorted by name for deterministic output,// and each declarative rollout re-concatenates the files (action/command/file.go) into// the identical statement set the single-file dump carries.-func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error) {+func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error) {if len(metadata.Schemas) == 0 {return &schema.MultiFileSchemaResult{Files: []schema.File{}}, nil}@@ -47,14 +49,14 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto// Tables (sorted by name). Each file is the writeTableSDL output — CREATE TABLE with// inline indexes / foreign keys / checks / generated columns / partitions / options.- tables := make([]*storepb.TableMetadata, 0, len(sm.Tables))+ tables := make([]*metadatapb.TableMetadata, 0, len(sm.Tables))for _, table := range sm.Tables {if table.SkipDump {continue}tables = append(tables, table)}- slices.SortFunc(tables, func(a, b *storepb.TableMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(tables, func(a, b *metadatapb.TableMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, table := range tables {var buf strings.Builderif err := writeTableSDL(&buf, table); err != nil {@@ -67,14 +69,14 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto}// Functions (sorted by name). writeRoutineSDL emits the canonical CREATE FUNCTION.- functions := make([]*storepb.FunctionMetadata, 0, len(sm.Functions))+ functions := make([]*metadatapb.FunctionMetadata, 0, len(sm.Functions))for _, function := range sm.Functions {if function.SkipDump {continue}functions = append(functions, function)}- slices.SortFunc(functions, func(a, b *storepb.FunctionMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(functions, func(a, b *metadatapb.FunctionMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, function := range functions {var buf strings.Builderif err := writeRoutineSDL(&buf, function.Definition); err != nil {@@ -92,14 +94,14 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto}// Procedures (sorted by name). writeRoutineSDL emits the canonical CREATE PROCEDURE.- procedures := make([]*storepb.ProcedureMetadata, 0, len(sm.Procedures))+ procedures := make([]*metadatapb.ProcedureMetadata, 0, len(sm.Procedures))for _, procedure := range sm.Procedures {if procedure.SkipDump {continue}procedures = append(procedures, procedure)}- slices.SortFunc(procedures, func(a, b *storepb.ProcedureMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(procedures, func(a, b *metadatapb.ProcedureMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, procedure := range procedures {var buf strings.Builderif err := writeRoutineSDL(&buf, procedure.Definition); err != nil {@@ -116,14 +118,14 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto// Views (sorted by name). writeViewSDL strips the dumped database's own qualifier from// the body, matching the single-file form.- views := make([]*storepb.ViewMetadata, 0, len(sm.Views))+ views := make([]*metadatapb.ViewMetadata, 0, len(sm.Views))for _, view := range sm.Views {if view.SkipDump {continue}views = append(views, view)}- slices.SortFunc(views, func(a, b *storepb.ViewMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(views, func(a, b *metadatapb.ViewMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, view := range views {var buf strings.Builderif err := writeViewSDL(&buf, metadata.Name, view); err != nil {@@ -139,14 +141,14 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto// (table, trigger) order — the same traversal getSDLFormat uses. Each file carries a// single CREATE TRIGGER.for _, table := range tables {- triggers := make([]*storepb.TriggerMetadata, 0, len(table.Triggers))+ triggers := make([]*metadatapb.TriggerMetadata, 0, len(table.Triggers))for _, trigger := range table.Triggers {if trigger.SkipDump {continue}triggers = append(triggers, trigger)}- slices.SortFunc(triggers, func(a, b *storepb.TriggerMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(triggers, func(a, b *metadatapb.TriggerMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, trigger := range triggers {var buf strings.Builderif err := writeTriggerSDL(&buf, table.Name, trigger); err != nil {@@ -161,9 +163,9 @@ func GetMultiFileDatabaseDefinition(_ schema.GetDefinitionContext, metadata *sto// Events (sorted by name). writeEventSDL strips the DEFINER and emits the canonical// CREATE EVENT.- events := make([]*storepb.EventMetadata, 0, len(sm.Events))+ events := make([]*metadatapb.EventMetadata, 0, len(sm.Events))events = append(events, sm.Events...)- slices.SortFunc(events, func(a, b *storepb.EventMetadata) int { return cmp.Compare(a.Name, b.Name) })+ slices.SortFunc(events, func(a, b *metadatapb.EventMetadata) int { return cmp.Compare(a.Name, b.Name) })for _, event := range events {var buf strings.Builderif err := writeEventSDL(&buf, event); err != nil {diff --git a/backend/plugin/schema/mysql/sdl_migration_test.go b/backend/plugin/schema/mysql/sdl_migration_test.goindex 4e88a2420e..e0d2b79142 100644--- a/backend/plugin/schema/mysql/sdl_migration_test.go+++ b/backend/plugin/schema/mysql/sdl_migration_test.go@@ -14,6 +14,7 @@ import ("testing""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/catalog"mysqldriver "github.com/go-sql-driver/mysql""github.com/google/uuid"@@ -161,7 +162,7 @@ func TestSDLRegistrationsAreMySQLOnly(t *testing.T) {_, err = schema.SDLDropAdvices(storepb.Engine_OCEANBASE, "", nil, "")require.ErrorContains(t, err, "not supported")- _, err = schema.GetMultiFileDatabaseDefinition(storepb.Engine_OCEANBASE, schema.GetDefinitionContext{}, &storepb.DatabaseSchemaMetadata{})+ _, err = schema.GetMultiFileDatabaseDefinition(storepb.Engine_OCEANBASE, schema.GetDefinitionContext{}, &metadatapb.DatabaseSchemaMetadata{})require.ErrorContains(t, err, "not supported")// MySQL stays registered for all three.@@ -169,12 +170,12 @@ func TestSDLRegistrationsAreMySQLOnly(t *testing.T) {require.NoError(t, err)_, err = schema.SDLDropAdvices(storepb.Engine_MYSQL, "", nil, "")require.NoError(t, err)- _, err = schema.GetMultiFileDatabaseDefinition(storepb.Engine_MYSQL, schema.GetDefinitionContext{}, &storepb.DatabaseSchemaMetadata{})+ _, err = schema.GetMultiFileDatabaseDefinition(storepb.Engine_MYSQL, schema.GetDefinitionContext{}, &metadatapb.DatabaseSchemaMetadata{})require.NoError(t, err)}// metadataFromProto wraps a raw proto in the model type the diff entry points take.-func metadataFromProto(proto *storepb.DatabaseSchemaMetadata) *model.DatabaseMetadata {+func metadataFromProto(proto *metadatapb.DatabaseSchemaMetadata) *model.DatabaseMetadata {return model.NewDatabaseMetadata(proto, nil, nil, storepb.Engine_MYSQL, true)}@@ -185,36 +186,36 @@ func metadataFromProto(proto *storepb.DatabaseSchemaMetadata) *model.DatabaseMet// rejects — the SDL path would fail the whole diff, while the legacy path treats view// bodies as opaque text and still diffs the tables.func TestDiffMigrationUsesLegacyMetadataPath(t *testing.T) {- brokenView := &storepb.ViewMetadata{+ brokenView := &metadatapb.ViewMetadata{Name: "v_broken",// Not parseable as a SELECT by the omni loader.Definition: "select ((broken from",}- oldProto := &storepb.DatabaseSchemaMetadata{+ oldProto := &metadatapb.DatabaseSchemaMetadata{Name: "d",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int", Nullable: false},},}},- Views: []*storepb.ViewMetadata{brokenView},+ Views: []*metadatapb.ViewMetadata{brokenView},}},}- newProto := &storepb.DatabaseSchemaMetadata{+ newProto := &metadatapb.DatabaseSchemaMetadata{Name: "d",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int", Nullable: false},{Name: "extra", Type: "varchar(10)", Nullable: true, Default: "NULL"},},}},- Views: []*storepb.ViewMetadata{brokenView},+ Views: []*metadatapb.ViewMetadata{brokenView},}},}@@ -231,14 +232,14 @@ func TestDiffMigrationUsesLegacyMetadataPath(t *testing.T) {// legacyColumnChangeSQL diffs two single-column tables through the registered legacy// metadata path and returns the migration SQL.-func legacyColumnChangeSQL(t *testing.T, oldCol, newCol *storepb.ColumnMetadata) string {+func legacyColumnChangeSQL(t *testing.T, oldCol, newCol *metadatapb.ColumnMetadata) string {t.Helper()- mk := func(col *storepb.ColumnMetadata) *model.DatabaseMetadata {- return metadataFromProto(&storepb.DatabaseSchemaMetadata{+ mk := func(col *metadatapb.ColumnMetadata) *model.DatabaseMetadata {+ return metadataFromProto(&metadatapb.DatabaseSchemaMetadata{Name: "d",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{{Name: "t", Columns: []*storepb.ColumnMetadata{col}}},+ Tables: []*metadatapb.TableMetadata{{Name: "t", Columns: []*metadatapb.ColumnMetadata{col}}},}},})}@@ -256,32 +257,32 @@ func TestLegacyDiffSRIDAndInvisible(t *testing.T) {t.Run("srid_only_change_modifies", func(t *testing.T) {sql := legacyColumnChangeSQL(t,- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false},- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},)require.Contains(t, sql, "MODIFY COLUMN `pt` point NOT NULL /*!80003 SRID 4326 */")})t.Run("explicit_srid_zero_differs_from_unset", func(t *testing.T) {sql := legacyColumnChangeSQL(t,- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false},- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(0)},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(0)},)require.Contains(t, sql, "MODIFY COLUMN `pt` point NOT NULL /*!80003 SRID 0 */")})t.Run("equal_srid_no_change", func(t *testing.T) {sql := legacyColumnChangeSQL(t,- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},- &storepb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},+ &metadatapb.ColumnMetadata{Name: "pt", Type: "point", Nullable: false, Srid: srid(4326)},)require.Empty(t, sql)})t.Run("invisible_only_change_modifies", func(t *testing.T) {sql := legacyColumnChangeSQL(t,- &storepb.ColumnMetadata{Name: "c", Type: "int", Nullable: true, Default: "NULL"},- &storepb.ColumnMetadata{Name: "c", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true},+ &metadatapb.ColumnMetadata{Name: "c", Type: "int", Nullable: true, Default: "NULL"},+ &metadatapb.ColumnMetadata{Name: "c", Type: "int", Nullable: true, Default: "NULL", IsInvisible: true},)require.Contains(t, sql, "MODIFY COLUMN `c` int")require.Contains(t, sql, " /*!80023 INVISIBLE */")diff --git a/backend/plugin/schema/mysql/walk_through.go b/backend/plugin/schema/mysql/walk_through.goindex f794328252..bf459e6599 100644--- a/backend/plugin/schema/mysql/walk_through.go+++ b/backend/plugin/schema/mysql/walk_through.go@@ -7,6 +7,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/ast""github.com/bytebase/omni/mysql/catalog"@@ -600,9 +601,9 @@ func mysqlUnqualifiedName(name string) string {return name}-// catalogToProto converts the omni catalog state to a storepb.DatabaseSchemaMetadata.-func catalogToProto(c *catalog.Catalog, dbName string) *storepb.DatabaseSchemaMetadata {- dbMeta := &storepb.DatabaseSchemaMetadata{+// catalogToProto converts the omni catalog state to a metadatapb.DatabaseSchemaMetadata.+func catalogToProto(c *catalog.Catalog, dbName string) *metadatapb.DatabaseSchemaMetadata {+ dbMeta := &metadatapb.DatabaseSchemaMetadata{Name: dbName,}@@ -615,7 +616,7 @@ func catalogToProto(c *catalog.Catalog, dbName string) *storepb.DatabaseSchemaMedbMeta.Collation = db.Collation// MySQL uses a single empty-name schema.- schemaMeta := &storepb.SchemaMetadata{+ schemaMeta := &metadatapb.SchemaMetadata{Name: "",}@@ -629,7 +630,7 @@ func catalogToProto(c *catalog.Catalog, dbName string) *storepb.DatabaseSchemaMe// tableProtoByLowerName lets the trigger pass below attach each trigger to its// owning table's metadata. The omni catalog keys tables case-insensitively, and a// trigger records its table via Trigger.Table, so the lookup is lower-cased.- tableProtoByLowerName := make(map[string]*storepb.TableMetadata, len(tableNames))+ tableProtoByLowerName := make(map[string]*metadatapb.TableMetadata, len(tableNames))for _, tName := range tableNames {t := db.Tables[tName]tableProto := tableToProto(t)@@ -665,7 +666,7 @@ func catalogToProto(c *catalog.Catalog, dbName string) *storepb.DatabaseSchemaMefor _, vName := range viewNames {v := db.Views[vName]- schemaMeta.Views = append(schemaMeta.Views, &storepb.ViewMetadata{+ schemaMeta.Views = append(schemaMeta.Views, &metadatapb.ViewMetadata{Name: v.Name,Definition: v.Definition,})@@ -711,8 +712,8 @@ func catalogToProto(c *catalog.Catalog, dbName string) *storepb.DatabaseSchemaMereturn dbMeta}-func tableToProto(t *catalog.Table) *storepb.TableMetadata {- table := &storepb.TableMetadata{+func tableToProto(t *catalog.Table) *metadatapb.TableMetadata {+ table := &metadatapb.TableMetadata{Name: t.Name,Engine: t.Engine,Charset: t.Charset,@@ -727,7 +728,7 @@ func tableToProto(t *catalog.Table) *storepb.TableMetadata {// indexes) are not reported by information_schema.continue}- colMeta := &storepb.ColumnMetadata{+ colMeta := &metadatapb.ColumnMetadata{Name: col.Name,Position: int32(col.Position),Type: col.ColumnType,@@ -753,11 +754,11 @@ func tableToProto(t *catalog.Table) *storepb.TableMetadata {colMeta.OnUpdate = col.OnUpdate}if col.Generated != nil {- genType := storepb.GenerationMetadata_TYPE_VIRTUAL+ genType := metadatapb.GenerationMetadata_TYPE_VIRTUALif col.Generated.Stored {- genType = storepb.GenerationMetadata_TYPE_STORED+ genType = metadatapb.GenerationMetadata_TYPE_STORED}- colMeta.Generation = &storepb.GenerationMetadata{+ colMeta.Generation = &metadatapb.GenerationMetadata{Type: genType,Expression: col.Generated.Expr,}@@ -781,7 +782,7 @@ func tableToProto(t *catalog.Table) *storepb.TableMetadata {if indexType == "" {indexType = "BTREE"}- idxMeta := &storepb.IndexMetadata{+ idxMeta := &metadatapb.IndexMetadata{Name: idx.Name,Type: indexType,Unique: idx.Unique,@@ -814,7 +815,7 @@ func tableToProto(t *catalog.Table) *storepb.TableMetadata {for _, con := range t.Constraints {switch con.Type {case catalog.ConForeignKey:- fk := &storepb.ForeignKeyMetadata{+ fk := &metadatapb.ForeignKeyMetadata{Name: con.Name,Columns: con.Columns,ReferencedTable: con.RefTable,@@ -828,7 +829,7 @@ func tableToProto(t *catalog.Table) *storepb.TableMetadata {}table.ForeignKeys = append(table.ForeignKeys, fk)case catalog.ConCheck:- table.CheckConstraints = append(table.CheckConstraints, &storepb.CheckConstraintMetadata{+ table.CheckConstraints = append(table.CheckConstraints, &metadatapb.CheckConstraintMetadata{Name: con.Name,Expression: con.CheckExpr,})@@ -865,16 +866,16 @@ func normalizeOmniDefault(value string, kind catalog.ColumnDefaultKind) string {}}-func partitionsToProto(p *catalog.PartitionInfo) []*storepb.TablePartitionMetadata {+func partitionsToProto(p *catalog.PartitionInfo) []*metadatapb.TablePartitionMetadata {expr := p.Exprif expr == "" && len(p.Columns) > 0 {// RANGE COLUMNS / LIST COLUMNS / KEY partitioning carries a column// list instead of an expression; the driver reports the joined list.expr = strings.Join(p.Columns, ",")}- var result []*storepb.TablePartitionMetadata+ var result []*metadatapb.TablePartitionMetadatafor _, pd := range p.Partitions {- result = append(result, &storepb.TablePartitionMetadata{+ result = append(result, &metadatapb.TablePartitionMetadata{Name: pd.Name,Type: partitionTypeToProto(p.Type),Expression: expr,@@ -884,38 +885,38 @@ func partitionsToProto(p *catalog.PartitionInfo) []*storepb.TablePartitionMetadareturn result}-func partitionTypeToProto(t string) storepb.TablePartitionMetadata_Type {+func partitionTypeToProto(t string) metadatapb.TablePartitionMetadata_Type {switch strings.ToUpper(t) {case "RANGE":- return storepb.TablePartitionMetadata_RANGE+ return metadatapb.TablePartitionMetadata_RANGEcase "RANGE COLUMNS":- return storepb.TablePartitionMetadata_RANGE_COLUMNS+ return metadatapb.TablePartitionMetadata_RANGE_COLUMNScase "LIST":- return storepb.TablePartitionMetadata_LIST+ return metadatapb.TablePartitionMetadata_LISTcase "LIST COLUMNS":- return storepb.TablePartitionMetadata_LIST_COLUMNS+ return metadatapb.TablePartitionMetadata_LIST_COLUMNScase "HASH":- return storepb.TablePartitionMetadata_HASH+ return metadatapb.TablePartitionMetadata_HASHcase "LINEAR HASH":- return storepb.TablePartitionMetadata_LINEAR_HASH+ return metadatapb.TablePartitionMetadata_LINEAR_HASHcase "KEY":- return storepb.TablePartitionMetadata_KEY+ return metadatapb.TablePartitionMetadata_KEYcase "LINEAR KEY":- return storepb.TablePartitionMetadata_LINEAR_KEY+ return metadatapb.TablePartitionMetadata_LINEAR_KEYdefault:- return storepb.TablePartitionMetadata_TYPE_UNSPECIFIED+ return metadatapb.TablePartitionMetadata_TYPE_UNSPECIFIED}}-func routineToFunctionProto(r *catalog.Routine) *storepb.FunctionMetadata {- return &storepb.FunctionMetadata{+func routineToFunctionProto(r *catalog.Routine) *metadatapb.FunctionMetadata {+ return &metadatapb.FunctionMetadata{Name: r.Name,Definition: r.Body,}}-func routineToProcedureProto(r *catalog.Routine) *storepb.ProcedureMetadata {- return &storepb.ProcedureMetadata{+func routineToProcedureProto(r *catalog.Routine) *metadatapb.ProcedureMetadata {+ return &metadatapb.ProcedureMetadata{Name: r.Name,Definition: r.Body,}@@ -926,8 +927,8 @@ func routineToProcedureProto(r *catalog.Routine) *storepb.ProcedureMetadata {// not a full CREATE TRIGGER; this mirrors that shape so a parsed-DDL catalog and a// synced catalog produce the same TriggerMetadata. DEFINER and session charset state// are intentionally dropped: omni's trigger differ ignores them.-func triggerToProto(tr *catalog.Trigger) *storepb.TriggerMetadata {- return &storepb.TriggerMetadata{+func triggerToProto(tr *catalog.Trigger) *metadatapb.TriggerMetadata {+ return &metadatapb.TriggerMetadata{Name: tr.Name,Event: tr.Event,Timing: tr.Timing,@@ -939,8 +940,8 @@ func triggerToProto(tr *catalog.Trigger) *storepb.TriggerMetadata {// the full SHOW CREATE EVENT text in Definition, so the catalog's ShowCreateEvent is// used to reproduce that canonical form (DEFINER included to match the sync; the SDL// dump and omni's event differ both ignore it).-func eventToProto(c *catalog.Catalog, dbName string, e *catalog.Event) *storepb.EventMetadata {- return &storepb.EventMetadata{+func eventToProto(c *catalog.Catalog, dbName string, e *catalog.Event) *metadatapb.EventMetadata {+ return &metadatapb.EventMetadata{Name: e.Name,Definition: c.ShowCreateEvent(dbName, e.Name),}diff --git a/backend/plugin/schema/mysql/walk_through_loader.go b/backend/plugin/schema/mysql/walk_through_loader.goindex 2cb4a1da27..cbbd4116e3 100644--- a/backend/plugin/schema/mysql/walk_through_loader.go+++ b/backend/plugin/schema/mysql/walk_through_loader.go@@ -8,11 +8,10 @@ import ("github.com/pkg/errors"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/ast""github.com/bytebase/omni/mysql/catalog"mysqlparser "github.com/bytebase/omni/mysql/parser"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// autoIncrementSentinel matches the value that MySQL sync writes into@@ -34,7 +33,7 @@ const autoIncrementSentinel = "AUTO_INCREMENT"// Preconditions: the caller must already have created and selected the target// database. This loader mutates foreign_key_checks to allow forward FK// references during bulk load.-func loadWalkThroughCatalog(ctx context.Context, cat *catalog.Catalog, dbName string, meta *storepb.DatabaseSchemaMetadata) error {+func loadWalkThroughCatalog(ctx context.Context, cat *catalog.Catalog, dbName string, meta *metadatapb.DatabaseSchemaMetadata) error {if cat == nil {return errors.New("loadWalkThroughCatalog: nil catalog")}@@ -83,12 +82,12 @@ type wtObjectEntry struct {parentTable string// Exactly one of the following is set based on kind.- tableMeta *storepb.TableMetadata- viewMeta *storepb.ViewMetadata- funcMeta *storepb.FunctionMetadata- procMeta *storepb.ProcedureMetadata- triggerMeta *storepb.TriggerMetadata- eventMeta *storepb.EventMetadata+ tableMeta *metadatapb.TableMetadata+ viewMeta *metadatapb.ViewMetadata+ funcMeta *metadatapb.FunctionMetadata+ procMeta *metadatapb.ProcedureMetadata+ triggerMeta *metadatapb.TriggerMetadata+ eventMeta *metadatapb.EventMetadata}func (e *wtObjectEntry) key() string {@@ -141,7 +140,7 @@ func wtKindLabel(k wtObjectKind) string {// wtCollectObjects flattens DatabaseSchemaMetadata into wtObjectEntry values.// MySQL metadata uses a single empty-named schema, so we look only at the first.-func wtCollectObjects(_ string, meta *storepb.DatabaseSchemaMetadata) []*wtObjectEntry {+func wtCollectObjects(_ string, meta *metadatapb.DatabaseSchemaMetadata) []*wtObjectEntry {var out []*wtObjectEntryfor _, sm := range meta.Schemas {for _, tbl := range sm.Tables {@@ -475,7 +474,7 @@ func wtInstallReal(cat *catalog.Catalog, obj *wtObjectEntry) error {// Expression-bearing fields (DEFAULT, ON UPDATE, GENERATED, CHECK) go through// wtParseExpr, which tolerates parse failures by silently dropping the// affected feature rather than failing the whole table.-func wtBuildCreateTableStmt(tbl *storepb.TableMetadata) (*ast.CreateTableStmt, error) {+func wtBuildCreateTableStmt(tbl *metadatapb.TableMetadata) (*ast.CreateTableStmt, error) {if tbl == nil || tbl.Name == "" {return nil, errors.New("wtBuildCreateTableStmt: empty table")}@@ -539,7 +538,7 @@ func wtBuildCreateTableStmt(tbl *storepb.TableMetadata) (*ast.CreateTableStmt, ereturn stmt, nil}-func wtBuildColumnDef(col *storepb.ColumnMetadata) (*ast.ColumnDef, error) {+func wtBuildColumnDef(col *metadatapb.ColumnMetadata) (*ast.ColumnDef, error) {typeName, err := wtParseTypeName(col.Type)if err != nil {return nil, err@@ -608,14 +607,14 @@ func wtBuildColumnDef(col *storepb.ColumnMetadata) (*ast.ColumnDef, error) {if expr, err := wtParseExpr(col.Generation.Expression); err == nil {def.Generated = &ast.GeneratedColumn{Expr: expr,- Stored: col.Generation.Type == storepb.GenerationMetadata_TYPE_STORED,+ Stored: col.Generation.Type == metadatapb.GenerationMetadata_TYPE_STORED,}}}return def, nil}-func wtBuildIndexConstraint(idx *storepb.IndexMetadata) *ast.Constraint {+func wtBuildIndexConstraint(idx *metadatapb.IndexMetadata) *ast.Constraint {// IndexMetadata.Type mixes two axes: the constraint kind (FULLTEXT /// SPATIAL) and the access method (BTREE / HASH). Pick them apart so// the resulting ast.Constraint sets Type and IndexType correctly.@@ -713,7 +712,7 @@ func wtTypeSupportsDefault(typeStr string) bool {return true}-func wtBuildFKConstraint(fk *storepb.ForeignKeyMetadata) *ast.Constraint {+func wtBuildFKConstraint(fk *metadatapb.ForeignKeyMetadata) *ast.Constraint {return &ast.Constraint{Type: ast.ConstrForeignKey,Name: fk.Name,@@ -743,7 +742,7 @@ func wtFKAction(s string) ast.ReferenceAction {}}-func wtBuildCheckConstraint(chk *storepb.CheckConstraintMetadata) *ast.Constraint {+func wtBuildCheckConstraint(chk *metadatapb.CheckConstraintMetadata) *ast.Constraint {if chk.Expression == "" {return nil}@@ -762,7 +761,7 @@ func wtBuildCheckConstraint(chk *storepb.CheckConstraintMetadata) *ast.Constrain// parsed from VIEW_DEFINITION (a MySQL-produced string, not our deparse).// DefineView tolerates a nil Select, so forward references, cyclic views and// body-parse failures are all survivable.-func wtBuildCreateViewStmt(view *storepb.ViewMetadata) (*ast.CreateViewStmt, error) {+func wtBuildCreateViewStmt(view *metadatapb.ViewMetadata) (*ast.CreateViewStmt, error) {if view == nil || view.Name == "" {return nil, errors.New("wtBuildCreateViewStmt: empty view")}@@ -894,7 +893,7 @@ func wtUnquoteIdent(s string) string {// wtInstallPseudoTable installs a degraded table with all-TEXT columns and no// constraints. Built as an AST and handed to DefineTable directly — no SQL// string and no parser on the critical path.-func wtInstallPseudoTable(cat *catalog.Catalog, _ string, tbl *storepb.TableMetadata) error {+func wtInstallPseudoTable(cat *catalog.Catalog, _ string, tbl *metadatapb.TableMetadata) error {if tbl == nil || tbl.Name == "" {return errors.New("pseudo table: missing name")}@@ -928,7 +927,7 @@ func wtInstallPseudoTable(cat *catalog.Catalog, _ string, tbl *storepb.TableMeta// wtInstallPseudoView installs a degraded view whose SELECT list is a series// of NULL literals aliased to the original view's column names. Built in AST// form and installed via DefineView directly.-func wtInstallPseudoView(cat *catalog.Catalog, _ string, view *storepb.ViewMetadata) error {+func wtInstallPseudoView(cat *catalog.Catalog, _ string, view *metadatapb.ViewMetadata) error {if view == nil || view.Name == "" {return errors.New("pseudo view: missing name")}@@ -978,7 +977,7 @@ func wtPseudoTextType() *ast.DataType {// Name/Timing/Event/Table/BodyText directly. Body is a parsed sp_proc_stmt —// best-effort only; on parse failure we still hand DefineTrigger a usable// stmt with BodyText populated.-func wtBuildCreateTriggerStmt(tm *storepb.TriggerMetadata, tableName string) *ast.CreateTriggerStmt {+func wtBuildCreateTriggerStmt(tm *metadatapb.TriggerMetadata, tableName string) *ast.CreateTriggerStmt {stmt := &ast.CreateTriggerStmt{Name: tm.Name,Timing: tm.Timing,@@ -1027,7 +1026,7 @@ func wtParseTriggerBody(tableName, timing, event, body string) ast.Node {// table name was empty in metadata). The stub preserves Name and routing// (Timing/Event/Table) so references still resolve; Body collapses to the// trivial no-op "BEGIN END".-func wtInstallPseudoTrigger(cat *catalog.Catalog, tm *storepb.TriggerMetadata, tableName string) error {+func wtInstallPseudoTrigger(cat *catalog.Catalog, tm *metadatapb.TriggerMetadata, tableName string) error {if tm == nil || tm.Name == "" {return errors.New("pseudo trigger: missing name")}@@ -1074,7 +1073,7 @@ func wtParseCreateEventStmt(definition string) (*ast.CreateEventStmt, error) {// wtInstallPseudoEvent installs a bare name-only event when the real install// path fails (Definition was empty, malformed, or rejected by DefineEvent).-func wtInstallPseudoEvent(cat *catalog.Catalog, em *storepb.EventMetadata) error {+func wtInstallPseudoEvent(cat *catalog.Catalog, em *metadatapb.EventMetadata) error {if em == nil || em.Name == "" {return errors.New("pseudo event: missing name")}diff --git a/backend/plugin/schema/mysql/walk_through_loader_test.go b/backend/plugin/schema/mysql/walk_through_loader_test.goindex 8126cae1a7..b80305d9e8 100644--- a/backend/plugin/schema/mysql/walk_through_loader_test.go+++ b/backend/plugin/schema/mysql/walk_through_loader_test.go@@ -5,9 +5,8 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/mysql/catalog"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// These tests exercise loadWalkThroughCatalog against synthetic metadata.@@ -30,7 +29,7 @@ func newLoaderTestCatalog(t *testing.T) *catalog.Catalog {return c}-func runLoader(t *testing.T, c *catalog.Catalog, meta *storepb.DatabaseSchemaMetadata) {+func runLoader(t *testing.T, c *catalog.Catalog, meta *metadatapb.DatabaseSchemaMetadata) {t.Helper()if err := loadWalkThroughCatalog(context.Background(), c, testDBName, meta); err != nil {t.Fatalf("loadWalkThroughCatalog: %v", err)@@ -171,13 +170,13 @@ func TestWtParseExpr_Failures(t *testing.T) {// ----------------------------------------------------------------------func TestLoader_TableBasic(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "users",Engine: "InnoDB",Charset: "utf8mb4",Collation: "utf8mb4_0900_ai_ci",Comment: "users table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "bigint unsigned",@@ -205,7 +204,7 @@ func TestLoader_TableBasic(t *testing.T) {Comment: "free form text",},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "uniq_email", Type: "BTREE", Unique: true, Expressions: []string{"email"}},},@@ -290,14 +289,14 @@ func TestLoader_TableBasic(t *testing.T) {// ----------------------------------------------------------------------func TestLoader_FulltextAndSpatialIndex(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},{Name: "body", Type: "text", Nullable: true},{Name: "location", Type: "geometry", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "ft_body", Type: "FULLTEXT", Expressions: []string{"body"}},{Name: "sp_location", Type: "SPATIAL", Expressions: []string{"location"}},@@ -339,26 +338,26 @@ func TestLoader_FulltextAndSpatialIndex(t *testing.T) {func TestLoader_ForeignKeyAcrossTables(t *testing.T) {meta := schemaWithTables(- &storepb.TableMetadata{+ &metadatapb.TableMetadata{Name: "parent",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},},},- &storepb.TableMetadata{+ &metadatapb.TableMetadata{Name: "child",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},{Name: "parent_id", Type: "bigint unsigned", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "idx_parent_id", Type: "BTREE", Expressions: []string{"parent_id"}},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "fk_child_parent",Columns: []string{"parent_id"},@@ -398,17 +397,17 @@ func TestLoader_ForeignKeyAcrossTables(t *testing.T) {// ----------------------------------------------------------------------func TestLoader_GeneratedColumn(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a", Type: "int", Nullable: true},{Name: "b", Type: "int", Nullable: true},{Name: "c",Type: "int",Nullable: true,- Generation: &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ Generation: &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: "a + b",},},@@ -436,24 +435,24 @@ func TestLoader_GeneratedColumn(t *testing.T) {// ----------------------------------------------------------------------func TestLoader_ViewReal(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: testDBName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},{Name: "name", Type: "varchar(255)", Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v_users",Definition: "SELECT id, name FROM users",@@ -482,9 +481,9 @@ func TestLoader_ViewReal(t *testing.T) {func TestLoader_PseudoTable(t *testing.T) {c := newLoaderTestCatalog(t)// Minimal metadata — just column names.- tblMeta := &storepb.TableMetadata{+ tblMeta := &metadatapb.TableMetadata{Name: "pt",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a"},{Name: "b"},{Name: "c"},@@ -506,7 +505,7 @@ func TestLoader_PseudoTable(t *testing.T) {func TestLoader_PseudoTable_EmptyColumns(t *testing.T) {c := newLoaderTestCatalog(t)- if err := wtInstallPseudoTable(c, testDBName, &storepb.TableMetadata{Name: "empty"}); err != nil {+ if err := wtInstallPseudoTable(c, testDBName, &metadatapb.TableMetadata{Name: "empty"}); err != nil {t.Fatalf("wtInstallPseudoTable(no columns): %v", err)}tbl := mustGetTable(t, c, "empty")@@ -520,9 +519,9 @@ func TestLoader_PseudoTable_EmptyColumns(t *testing.T) {func TestLoader_PseudoView(t *testing.T) {c := newLoaderTestCatalog(t)- if err := wtInstallPseudoView(c, testDBName, &storepb.ViewMetadata{+ if err := wtInstallPseudoView(c, testDBName, &metadatapb.ViewMetadata{Name: "pv",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "x"},{Name: "y"},},@@ -541,9 +540,9 @@ func TestLoader_PseudoView(t *testing.T) {// ----------------------------------------------------------------------func TestLoader_RealFailsFallsBackToPseudo(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "broken",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "good", Type: "int"},// Type with unbalanced parens — wtParseTypeName returns an error// for this, so wtBuildCreateTableStmt propagates and install_real@@ -576,17 +575,17 @@ func TestLoader_ForwardFKInstallsViaFKChecksOff(t *testing.T) {// after. Because the loader flips foreign_key_checks off during bulk// install, this must succeed.meta := schemaWithTables(- &storepb.TableMetadata{+ &metadatapb.TableMetadata{Name: "child",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},{Name: "parent_id", Type: "bigint unsigned", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "idx_pid", Type: "BTREE", Expressions: []string{"parent_id"}},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "fk_fwd",Columns: []string{"parent_id"},@@ -595,12 +594,12 @@ func TestLoader_ForwardFKInstallsViaFKChecksOff(t *testing.T) {},},},- &storepb.TableMetadata{+ &metadatapb.TableMetadata{Name: "parent",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint unsigned", Nullable: false, Default: autoIncrementSentinel},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},},},@@ -625,10 +624,10 @@ func TestLoader_ForwardFKInstallsViaFKChecksOff(t *testing.T) {// schemaWithTables wraps tables into a DatabaseSchemaMetadata with the// expected single empty-named schema that MySQL uses.-func schemaWithTables(tables ...*storepb.TableMetadata) *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func schemaWithTables(tables ...*metadatapb.TableMetadata) *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: testDBName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",Tables: tables,@@ -638,10 +637,10 @@ func schemaWithTables(tables ...*storepb.TableMetadata) *storepb.DatabaseSchemaM}// schemaWithEvents wraps events into a DatabaseSchemaMetadata.-func schemaWithEvents(events ...*storepb.EventMetadata) *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{+func schemaWithEvents(events ...*metadatapb.EventMetadata) *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{Name: testDBName,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Events: events},},}@@ -657,11 +656,11 @@ func schemaWithEvents(events ...*storepb.EventMetadata) *storepb.DatabaseSchemaM// accountTableForTriggers builds the `account` table used by the canonical// trigger examples in the MySQL docs.-func accountTableForTriggers() *storepb.TableMetadata {- return &storepb.TableMetadata{+func accountTableForTriggers() *metadatapb.TableMetadata {+ return &metadatapb.TableMetadata{Name: "account",Engine: "InnoDB",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "acct_num", Type: "int", Nullable: true},{Name: "amount", Type: "decimal(10,2)", Nullable: true},},@@ -673,7 +672,7 @@ func TestLoader_Trigger_SimpleSetSum(t *testing.T) {//// CREATE TRIGGER ins_sum BEFORE INSERT ON account// FOR EACH ROW SET @sum = @sum + NEW.amount;- meta := schemaWithTables(withTriggers(accountTableForTriggers(), &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(accountTableForTriggers(), &metadatapb.TriggerMetadata{Name: "ins_sum",Timing: "BEFORE",Event: "INSERT",@@ -717,7 +716,7 @@ func TestLoader_Trigger_BeginEndWithIfElse(t *testing.T) {SET NEW.amount = 100;END IF;END`- meta := schemaWithTables(withTriggers(accountTableForTriggers(), &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(accountTableForTriggers(), &metadatapb.TriggerMetadata{Name: "upd_check",Timing: "BEFORE",Event: "UPDATE",@@ -750,7 +749,7 @@ func TestLoader_Trigger_AfterUpdateWithSignal(t *testing.T) {SET MESSAGE_TEXT = 'Negative amount not allowed';END IF;END`- meta := schemaWithTables(withTriggers(accountTableForTriggers(), &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(accountTableForTriggers(), &metadatapb.TriggerMetadata{Name: "validate_amount",Timing: "AFTER",Event: "UPDATE",@@ -777,7 +776,7 @@ func TestLoader_Trigger_PseudoOnMissingFields(t *testing.T) {// metadata has only Name (+ Body) — Timing and Event empty. Real install// should fail (DefineTrigger rejects empty Timing/Event / empty Body// couldn't parse). Pseudo fills defaults.- meta := schemaWithTables(withTriggers(accountTableForTriggers(), &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(accountTableForTriggers(), &metadatapb.TriggerMetadata{Name: "trg_needs_defaults",// Timing / Event / Body intentionally empty.}))@@ -802,7 +801,7 @@ func TestLoader_Trigger_PseudoOnUnparseableBody(t *testing.T) {// Body=nil + BodyText populated (DefineTrigger tolerates nil Body), or// falls back to pseudo with body "BEGIN END". Either way the trigger// must exist in the catalog.- meta := schemaWithTables(withTriggers(accountTableForTriggers(), &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(accountTableForTriggers(), &metadatapb.TriggerMetadata{Name: "trg_bad_body",Timing: "BEFORE",Event: "INSERT",@@ -821,14 +820,14 @@ func TestLoader_Trigger_PseudoOnUnparseableBody(t *testing.T) {func TestLoader_Trigger_OnPseudoParentTable(t *testing.T) {// Parent table has a bad column type → real install fails, pseudo// installs TEXT-column table. The trigger must still attach.- parent := &storepb.TableMetadata{+ parent := &metadatapb.TableMetadata{Name: "account",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "bad", Type: "varchar((("}, // forces real install to fail},}- meta := schemaWithTables(withTriggers(parent, &storepb.TriggerMetadata{+ meta := schemaWithTables(withTriggers(parent, &metadatapb.TriggerMetadata{Name: "ins_stub",Timing: "BEFORE",Event: "INSERT",@@ -866,7 +865,7 @@ func TestLoader_Event_OneShotAT(t *testing.T) {"DO UPDATE mytable SET mycol = mycol + 1"c := newLoaderTestCatalog(t)- runLoader(t, c, schemaWithEvents(&storepb.EventMetadata{+ runLoader(t, c, schemaWithEvents(&metadatapb.EventMetadata{Name: "myevent",Definition: def,}))@@ -891,7 +890,7 @@ func TestLoader_Event_RecurringEveryWithComment(t *testing.T) {"DO DELETE FROM site_activity.sessions"c := newLoaderTestCatalog(t)- runLoader(t, c, schemaWithEvents(&storepb.EventMetadata{+ runLoader(t, c, schemaWithEvents(&metadatapb.EventMetadata{Name: "e_hourly",Definition: def,}))@@ -928,7 +927,7 @@ func TestLoader_Event_DailyBeginEndBody(t *testing.T) {"END"c := newLoaderTestCatalog(t)- runLoader(t, c, schemaWithEvents(&storepb.EventMetadata{+ runLoader(t, c, schemaWithEvents(&metadatapb.EventMetadata{Name: "e_daily",Definition: def,}))@@ -945,7 +944,7 @@ func TestLoader_Event_DailyBeginEndBody(t *testing.T) {func TestLoader_Event_PseudoOnEmptyDefinition(t *testing.T) {c := newLoaderTestCatalog(t)- runLoader(t, c, schemaWithEvents(&storepb.EventMetadata{+ runLoader(t, c, schemaWithEvents(&metadatapb.EventMetadata{Name: "e_empty",// Definition intentionally empty — real install fails, pseudo kicks in.}))@@ -954,7 +953,7 @@ func TestLoader_Event_PseudoOnEmptyDefinition(t *testing.T) {func TestLoader_Event_PseudoOnGarbageDefinition(t *testing.T) {c := newLoaderTestCatalog(t)- runLoader(t, c, schemaWithEvents(&storepb.EventMetadata{+ runLoader(t, c, schemaWithEvents(&metadatapb.EventMetadata{Name: "e_broken",Definition: "this is definitely not a CREATE EVENT statement $$",}))@@ -962,7 +961,7 @@ func TestLoader_Event_PseudoOnGarbageDefinition(t *testing.T) {}// withTriggers is a tiny builder that attaches triggers to a given table.-func withTriggers(tbl *storepb.TableMetadata, triggers ...*storepb.TriggerMetadata) *storepb.TableMetadata {+func withTriggers(tbl *metadatapb.TableMetadata, triggers ...*metadatapb.TriggerMetadata) *metadatapb.TableMetadata {tbl.Triggers = append(tbl.Triggers, triggers...)return tbl}@@ -975,9 +974,9 @@ func withTriggers(tbl *storepb.TableMetadata, triggers ...*storepb.TriggerMetada// ----------------------------------------------------------------------func TestLoader_DefaultNull_OnBlobJsonGeometry_StaysReal(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int", Nullable: false, Default: autoIncrementSentinel},// All three of these are nullable — sync fills Default="NULL"// for them. MySQL grammar does NOT accept DEFAULT on these@@ -1036,13 +1035,13 @@ func TestLoader_FunctionalIndex_ParenthesizedExpression(t *testing.T) {// col1 INT, col2 INT,// INDEX func_index ((ABS(col1)))// );- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "col1", Type: "int", Nullable: true},{Name: "col2", Type: "int", Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "func_index",Type: "BTREE",@@ -1078,13 +1077,13 @@ func TestLoader_FunctionalIndex_FunctionCallForm(t *testing.T) {// Same thing but key part is stored as bare function-call text// (lower(name) without outer parens) — another shape the proto comment// explicitly calls out.- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int", Nullable: false, Default: autoIncrementSentinel},{Name: "name", Type: "varchar(255)", Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "idx_lower_name", Type: "BTREE", Expressions: []string{"lower(`name`)"}},},@@ -1112,14 +1111,14 @@ func TestLoader_FunctionalIndex_FunctionCallForm(t *testing.T) {// test: when one key part is an expression and another is a bare column, the// whole index must still install — all parts route through IndexColumns.func TestLoader_FunctionalIndex_MixedWithBareColumns(t *testing.T) {- meta := schemaWithTables(&storepb.TableMetadata{+ meta := schemaWithTables(&metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int", Nullable: false, Default: autoIncrementSentinel},{Name: "tag", Type: "varchar(64)", Nullable: true},{Name: "name", Type: "varchar(255)", Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Type: "BTREE", Primary: true, Unique: true, Expressions: []string{"id"}},{Name: "idx_mixed",diff --git a/backend/plugin/schema/mysql/walk_through_test.go b/backend/plugin/schema/mysql/walk_through_test.goindex 06e37f0ac6..c2d2849f30 100644--- a/backend/plugin/schema/mysql/walk_through_test.go+++ b/backend/plugin/schema/mysql/walk_through_test.go@@ -6,6 +6,7 @@ import ("path/filepath""testing"+ metadatapb "github.com/bytebase/omni/metadata"omniast "github.com/bytebase/omni/mysql/ast""github.com/google/go-cmp/cmp""github.com/stretchr/testify/require"@@ -31,7 +32,7 @@ type testData struct {}func TestWalkThrough(t *testing.T) {- originDatabase := &storepb.DatabaseSchemaMetadata{+ originDatabase := &metadatapb.DatabaseSchemaMetadata{Name: "test",}@@ -49,7 +50,7 @@ func TestWalkThrough(t *testing.T) {for _, test := range tests {// Make a deep copy to avoid mutation across tests- protoData, ok := proto.Clone(originDatabase).(*storepb.DatabaseSchemaMetadata)+ protoData, ok := proto.Clone(originDatabase).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)// Create DatabaseMetadata for walk-through@@ -71,28 +72,28 @@ func TestWalkThrough(t *testing.T) {continue}- want := &storepb.DatabaseSchemaMetadata{}+ want := &metadatapb.DatabaseSchemaMetadata{}err = common.ProtojsonUnmarshaler.Unmarshal([]byte(test.Want), want)require.NoError(t, err)result := state.GetProto()diff := cmp.Diff(want, result, protocmp.Transform(),- protocmp.SortRepeatedFields(&storepb.DatabaseSchemaMetadata{}, "schemas"),- protocmp.SortRepeatedFields(&storepb.SchemaMetadata{}, "tables", "views"),- protocmp.SortRepeatedFields(&storepb.TableMetadata{}, "indexes", "columns"),+ protocmp.SortRepeatedFields(&metadatapb.DatabaseSchemaMetadata{}, "schemas"),+ protocmp.SortRepeatedFields(&metadatapb.SchemaMetadata{}, "tables", "views"),+ protocmp.SortRepeatedFields(&metadatapb.TableMetadata{}, "indexes", "columns"),)require.Empty(t, diff, "statement %q", test.Statement)}}func TestWalkThroughCreateTableIfNotExistsCTASExistingTable(t *testing.T) {- originDatabase := &storepb.DatabaseSchemaMetadata{+ originDatabase := &metadatapb.DatabaseSchemaMetadata{Name: "test",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a",Position: 1,@@ -123,13 +124,13 @@ func TestWalkThroughCreateTableIfNotExistsCTASExistingTable(t *testing.T) {require.NotNil(t, state.GetSchemaMetadata("").GetTable("t1"))}-// TestWalkThroughSRIDInvisible verifies the omni catalog -> storepb.ColumnMetadata+// TestWalkThroughSRIDInvisible verifies the omni catalog -> metadatapb.ColumnMetadata// conversion (tableToProto) carries the spatial SRID (presence + value, including the// valid explicit SRID 0) and the INVISIBLE flag. Without this the WalkThroughWithContext// simulation path — used to compute the schema a changeset would produce — would silently// drop these attributes, mirroring the v1-converter gap.func TestWalkThroughSRIDInvisible(t *testing.T) {- state := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{Name: "test"}, nil, nil, storepb.Engine_MYSQL, true)+ state := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "test"}, nil, nil, storepb.Engine_MYSQL, true)statement := "CREATE TABLE t (" +"id INT PRIMARY KEY, " +"g4326 GEOMETRY NOT NULL SRID 4326, " +@@ -143,7 +144,7 @@ func TestWalkThroughSRIDInvisible(t *testing.T) {advice := WalkThroughWithContext(schema.WalkThroughContext{RawSQL: statement}, state, asts)require.Nil(t, advice)- cols := map[string]*storepb.ColumnMetadata{}+ cols := map[string]*metadatapb.ColumnMetadata{}for _, c := range state.GetProto().GetSchemas()[0].GetTables()[0].GetColumns() {cols[c.GetName()] = c}@@ -169,19 +170,19 @@ func TestWalkThroughSRIDInvisible(t *testing.T) {// plain/no-SRID and — because columnsEqual now compares these fields — surface as phantom// changes.func TestWalkThroughSRIDInvisibleSeeded(t *testing.T) {- origin := &storepb.DatabaseSchemaMetadata{+ origin := &metadatapb.DatabaseSchemaMetadata{Name: "test",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "geo",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Position: 1, Type: "int", Nullable: false, Default: "AUTO_INCREMENT"},{Name: "pt", Position: 2, Type: "point", Nullable: false, Srid: func() *uint32 { v := uint32(4326); return &v }()},{Name: "secret", Position: 3, Type: "int", Nullable: false, Default: "0", IsInvisible: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "PRIMARY", Expressions: []string{"id"}, Primary: true, Unique: true},},},@@ -200,7 +201,7 @@ func TestWalkThroughSRIDInvisibleSeeded(t *testing.T) {geo := state.GetSchemaMetadata("").GetTable("geo")require.NotNil(t, geo)- cols := map[string]*storepb.ColumnMetadata{}+ cols := map[string]*metadatapb.ColumnMetadata{}for _, c := range geo.GetProto().GetColumns() {cols[c.GetName()] = c}diff --git a/backend/plugin/schema/oracle/generate_migration.go b/backend/plugin/schema/oracle/generate_migration.goindex 2912cfc999..a50fef2be9 100644--- a/backend/plugin/schema/oracle/generate_migration.go+++ b/backend/plugin/schema/oracle/generate_migration.go@@ -5,6 +5,8 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/schema"@@ -739,7 +741,7 @@ func createObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) {generateSequenceCommentChanges(buf, diff)}-func generateCreateTable(schemaName, tableName string, table *storepb.TableMetadata, includeForeignKeys bool) (string, error) {+func generateCreateTable(schemaName, tableName string, table *metadatapb.TableMetadata, includeForeignKeys bool) (string, error) {var buf strings.BuilderwriteMigrationCreateTable(&buf, schemaName, tableName, table.Columns, table.CheckConstraints)@@ -832,7 +834,7 @@ func generateAlterColumn(schemaName, tableName string, colDiff *schema.ColumnDif}// hasDefaultValue checks if a column has any default value-func hasDefaultValue(column *storepb.ColumnMetadata) bool {+func hasDefaultValue(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}@@ -840,7 +842,7 @@ func hasDefaultValue(column *storepb.ColumnMetadata) bool {}// defaultValuesEqual checks if two columns have the same default value-func defaultValuesEqual(col1, col2 *storepb.ColumnMetadata) bool {+func defaultValuesEqual(col1, col2 *metadatapb.ColumnMetadata) bool {if col1 == nil || col2 == nil {return col1 == col2}@@ -852,7 +854,7 @@ func defaultValuesEqual(col1, col2 *storepb.ColumnMetadata) bool {}// getDefaultExpression returns the SQL expression for a column's default value-func getDefaultExpression(column *storepb.ColumnMetadata) string {+func getDefaultExpression(column *metadatapb.ColumnMetadata) string {if column == nil {return ""}@@ -1031,7 +1033,7 @@ func writeCreateSchema(out *strings.Builder, schema string) {_, _ = out.WriteString("\n")}-func writeAddColumn(out *strings.Builder, schema, table string, column *storepb.ColumnMetadata) {+func writeAddColumn(out *strings.Builder, schema, table string, column *metadatapb.ColumnMetadata) {_, _ = out.WriteString(`ALTER TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1137,7 +1139,7 @@ func writeAlterColumnDropDefault(out *strings.Builder, schema, table, column str_, _ = out.WriteString("\n")}-func writeAddCheckConstraint(out *strings.Builder, schema, table string, check *storepb.CheckConstraintMetadata) {+func writeAddCheckConstraint(out *strings.Builder, schema, table string, check *metadatapb.CheckConstraintMetadata) {_, _ = out.WriteString(`ALTER TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1254,7 +1256,7 @@ func isSystemGeneratedSequence(sequenceName string) bool {}// writeCreateSequence writes a CREATE SEQUENCE statement-func writeMigrationCreateSequence(out *strings.Builder, schema string, seq *storepb.SequenceMetadata) {+func writeMigrationCreateSequence(out *strings.Builder, schema string, seq *metadatapb.SequenceMetadata) {_, _ = out.WriteString(`CREATE SEQUENCE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1335,7 +1337,7 @@ func writeProcedureDiff(out *strings.Builder, procDiff *schema.ProcedureDiff) {}// writeView writes a CREATE VIEW statement-func writeMigrationView(out *strings.Builder, schema string, view *storepb.ViewMetadata) {+func writeMigrationView(out *strings.Builder, schema string, view *metadatapb.ViewMetadata) {_, _ = out.WriteString(`CREATE VIEW `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1358,7 +1360,7 @@ func writeMigrationView(out *strings.Builder, schema string, view *storepb.ViewM}// writeMaterializedView writes a CREATE MATERIALIZED VIEW statement-func writeMigrationMaterializedView(out *strings.Builder, schema string, view *storepb.MaterializedViewMetadata) {+func writeMigrationMaterializedView(out *strings.Builder, schema string, view *metadatapb.MaterializedViewMetadata) {_, _ = out.WriteString(`CREATE MATERIALIZED VIEW `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1381,7 +1383,7 @@ func writeMigrationMaterializedView(out *strings.Builder, schema string, view *s}// writeForeignKey writes an ALTER TABLE ADD CONSTRAINT statement for a foreign key-func writeMigrationForeignKey(out *strings.Builder, schema, table string, fk *storepb.ForeignKeyMetadata) {+func writeMigrationForeignKey(out *strings.Builder, schema, table string, fk *metadatapb.ForeignKeyMetadata) {_, _ = out.WriteString(`ALTER TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1438,7 +1440,7 @@ func writeMigrationForeignKey(out *strings.Builder, schema, table string, fk *st}// writeCreateTable writes a CREATE TABLE statement-func writeMigrationCreateTable(out *strings.Builder, schema, table string, columns []*storepb.ColumnMetadata, checks []*storepb.CheckConstraintMetadata) {+func writeMigrationCreateTable(out *strings.Builder, schema, table string, columns []*metadatapb.ColumnMetadata, checks []*metadatapb.CheckConstraintMetadata) {_, _ = out.WriteString(`CREATE TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1485,7 +1487,7 @@ func writeMigrationCreateTable(out *strings.Builder, schema, table string, colum}// writePrimaryKey writes an ALTER TABLE ADD PRIMARY KEY statement-func writeMigrationPrimaryKey(out *strings.Builder, schema, table string, index *storepb.IndexMetadata) {+func writeMigrationPrimaryKey(out *strings.Builder, schema, table string, index *metadatapb.IndexMetadata) {_, _ = out.WriteString(`ALTER TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1510,7 +1512,7 @@ func writeMigrationPrimaryKey(out *strings.Builder, schema, table string, index}// writeUniqueKey writes an ALTER TABLE ADD UNIQUE statement-func writeMigrationUniqueKey(out *strings.Builder, schema, table string, index *storepb.IndexMetadata) {+func writeMigrationUniqueKey(out *strings.Builder, schema, table string, index *metadatapb.IndexMetadata) {_, _ = out.WriteString(`ALTER TABLE `)if schema != "" {_, _ = out.WriteString(`"`)@@ -1535,7 +1537,7 @@ func writeMigrationUniqueKey(out *strings.Builder, schema, table string, index *}// writeIndex writes a CREATE INDEX statement-func writeMigrationIndex(out *strings.Builder, schema, table string, index *storepb.IndexMetadata) {+func writeMigrationIndex(out *strings.Builder, schema, table string, index *metadatapb.IndexMetadata) {_, _ = out.WriteString(`CREATE `)if index.Unique {_, _ = out.WriteString(`UNIQUE `)@@ -1746,12 +1748,12 @@ func generateColumnCommentChanges(buf *strings.Builder, tableDiff *schema.TableD}// Build maps for efficient lookup- oldColumnMap := make(map[string]*storepb.ColumnMetadata)+ oldColumnMap := make(map[string]*metadatapb.ColumnMetadata)for _, col := range tableDiff.OldTable.Columns {oldColumnMap[col.Name] = col}- newColumnMap := make(map[string]*storepb.ColumnMetadata)+ newColumnMap := make(map[string]*metadatapb.ColumnMetadata)for _, col := range tableDiff.NewTable.Columns {newColumnMap[col.Name] = col}@@ -1946,7 +1948,7 @@ func writeColumnComment(out *strings.Builder, schema, table, column, comment str}// writeMigrationTrigger writes a CREATE TRIGGER statement for migration-func writeMigrationTrigger(out *strings.Builder, trigger *storepb.TriggerMetadata) {+func writeMigrationTrigger(out *strings.Builder, trigger *metadatapb.TriggerMetadata) {if trigger == nil {return}diff --git a/backend/plugin/schema/oracle/generate_migration_test.go b/backend/plugin/schema/oracle/generate_migration_test.goindex c041f4f832..4f51b70cf2 100644--- a/backend/plugin/schema/oracle/generate_migration_test.go+++ b/backend/plugin/schema/oracle/generate_migration_test.go@@ -5,6 +5,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -64,7 +65,7 @@ func TestGenerateMigration(t *testing.T) {func parseMetadata(t *testing.T, encoded string) *model.DatabaseMetadata {t.Helper()- metadata := &storepb.DatabaseSchemaMetadata{}+ metadata := &metadatapb.DatabaseSchemaMetadata{}require.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(encoded), metadata))return model.NewDatabaseMetadata(metadata, nil, nil, storepb.Engine_ORACLE, false)}@@ -84,13 +85,13 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "ORDERS",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "ORDERS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "CUSTOMER_ID", Type: "NUMBER", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "FK_ORDERS_CUSTOMER",Columns: []string{"CUSTOMER_ID"},@@ -106,9 +107,9 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "CUSTOMERS",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "CUSTOMERS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "NAME", Type: "VARCHAR2(100)", Nullable: false},},@@ -126,9 +127,9 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "USERS",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "USERS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "NAME", Type: "VARCHAR2(100)", Nullable: false},},@@ -138,9 +139,9 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "ORDERS",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "ORDERS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "USER_ID", Type: "NUMBER", Nullable: false},},@@ -152,10 +153,10 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",ViewName: "USER_ORDERS",- NewView: &storepb.ViewMetadata{+ NewView: &metadatapb.ViewMetadata{Name: "USER_ORDERS",Definition: "SELECT u.NAME, o.ID FROM USERS u JOIN ORDERS o ON u.ID = o.USER_ID",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "TESTUSER", Table: "USERS", Column: "ID"},{Schema: "TESTUSER", Table: "USERS", Column: "NAME"},{Schema: "TESTUSER", Table: "ORDERS", Column: "ID"},@@ -179,7 +180,7 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {ColumnChanges: []*schema.ColumnDiff{{Action: schema.MetadataDiffActionCreate,- NewColumn: &storepb.ColumnMetadata{+ NewColumn: &metadatapb.ColumnMetadata{Name: "CUSTOMER_REF",Type: "NUMBER",Nullable: true,@@ -195,7 +196,7 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {ColumnChanges: []*schema.ColumnDiff{{Action: schema.MetadataDiffActionCreate,- NewColumn: &storepb.ColumnMetadata{+ NewColumn: &metadatapb.ColumnMetadata{Name: "STATUS",Type: "VARCHAR2(20)",Nullable: true,@@ -215,9 +216,9 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "PRODUCTS",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "PRODUCTS",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "NAME", Type: "VARCHAR2(100)", Nullable: false},{Name: "PRICE", Type: "NUMBER(10,2)", Nullable: false},@@ -230,10 +231,10 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",ViewName: "EXPENSIVE_PRODUCTS",- NewView: &storepb.ViewMetadata{+ NewView: &metadatapb.ViewMetadata{Name: "EXPENSIVE_PRODUCTS",Definition: "SELECT * FROM PRODUCTS WHERE PRICE > 100",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "TESTUSER", Table: "PRODUCTS", Column: "ID"},{Schema: "TESTUSER", Table: "PRODUCTS", Column: "NAME"},{Schema: "TESTUSER", Table: "PRODUCTS", Column: "PRICE"},@@ -246,10 +247,10 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",MaterializedViewName: "EXPENSIVE_PRODUCTS_MV",- NewMaterializedView: &storepb.MaterializedViewMetadata{+ NewMaterializedView: &metadatapb.MaterializedViewMetadata{Name: "EXPENSIVE_PRODUCTS_MV",Definition: "SELECT NAME FROM EXPENSIVE_PRODUCTS",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "TESTUSER", Table: "EXPENSIVE_PRODUCTS", Column: "NAME"},},},@@ -266,9 +267,9 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "EMPLOYEES",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "EMPLOYEES",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "SALARY", Type: "NUMBER(10,2)", Nullable: false},},@@ -280,10 +281,10 @@ func TestTopologicalOrderCreateObjects(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",FunctionName: "GET_AVG_SALARY",- NewFunction: &storepb.FunctionMetadata{+ NewFunction: &metadatapb.FunctionMetadata{Name: "GET_AVG_SALARY",Definition: "CREATE OR REPLACE FUNCTION GET_AVG_SALARY RETURN NUMBER IS avg_sal NUMBER; BEGIN SELECT AVG(SALARY) INTO avg_sal FROM EMPLOYEES; RETURN avg_sal; END;",- DependencyTables: []*storepb.DependencyTable{+ DependencyTables: []*metadatapb.DependencyTable{{Schema: "TESTUSER", Table: "EMPLOYEES"},},},@@ -364,13 +365,13 @@ func TestTopologicalOrderWithCycles(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "TABLE_A",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "TABLE_A",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "B_ID", Type: "NUMBER", Nullable: true},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "FK_A_TO_B",Columns: []string{"B_ID"},@@ -385,13 +386,13 @@ func TestTopologicalOrderWithCycles(t *testing.T) {Action: schema.MetadataDiffActionCreate,SchemaName: "TESTUSER",TableName: "TABLE_B",- NewTable: &storepb.TableMetadata{+ NewTable: &metadatapb.TableMetadata{Name: "TABLE_B",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "ID", Type: "NUMBER", Nullable: false},{Name: "A_ID", Type: "NUMBER", Nullable: true},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "FK_B_TO_A",Columns: []string{"A_ID"},diff --git a/backend/plugin/schema/oracle/get_database_definition.go b/backend/plugin/schema/oracle/get_database_definition.goindex dc011504bc..8e1f61da21 100644--- a/backend/plugin/schema/oracle/get_database_definition.go+++ b/backend/plugin/schema/oracle/get_database_definition.go@@ -3,6 +3,8 @@ package oracleimport ("strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/schema"@@ -28,7 +30,7 @@ func init() {schema.RegisterGetProcedureDefinition(storepb.Engine_ORACLE, GetProcedureDefinition)}-func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *metadatapb.DatabaseSchemaMetadata) (string, error) {if len(to.Schemas) == 0 {return "", nil}@@ -50,11 +52,11 @@ func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseSc// Build dependency graph for topological sortinggraph := base.NewGraph()- tableMap := make(map[string]*storepb.TableMetadata)- viewMap := make(map[string]*storepb.ViewMetadata)- materializedViewMap := make(map[string]*storepb.MaterializedViewMetadata)- functionMap := make(map[string]*storepb.FunctionMetadata)- procedureMap := make(map[string]*storepb.ProcedureMetadata)+ tableMap := make(map[string]*metadatapb.TableMetadata)+ viewMap := make(map[string]*metadatapb.ViewMetadata)+ materializedViewMap := make(map[string]*metadatapb.MaterializedViewMetadata)+ functionMap := make(map[string]*metadatapb.FunctionMetadata)+ procedureMap := make(map[string]*metadatapb.ProcedureMetadata)// Add tables to graphfor _, table := range schema.Tables {@@ -183,7 +185,7 @@ func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseScreturn buf.String(), nil}-func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(_ string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var buf strings.Builderif err := writeTable(&buf, table); err != nil {return "", err@@ -196,7 +198,7 @@ func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.Seq// one schema per database and the writers emit unqualified names, matching// GetTableDefinition and the whole-database output.-func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(_ string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.Builderif err := writeView(&buf, view); err != nil {return "", err@@ -205,7 +207,7 @@ func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {return buf.String(), nil}-func GetMaterializedViewDefinition(_ string, view *storepb.MaterializedViewMetadata) (string, error) {+func GetMaterializedViewDefinition(_ string, view *metadatapb.MaterializedViewMetadata) (string, error) {var buf strings.Builderif err := writeMaterializedView(&buf, view); err != nil {return "", err@@ -214,7 +216,7 @@ func GetMaterializedViewDefinition(_ string, view *storepb.MaterializedViewMetadreturn buf.String(), nil}-func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(_ string, function *metadatapb.FunctionMetadata) (string, error) {var buf strings.Builderif err := writeFunction(&buf, function); err != nil {return "", err@@ -223,7 +225,7 @@ func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (stringreturn buf.String(), nil}-func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (string, error) {+func GetProcedureDefinition(_ string, procedure *metadatapb.ProcedureMetadata) (string, error) {var buf strings.Builderif err := writeProcedure(&buf, procedure); err != nil {return "", err@@ -232,7 +234,7 @@ func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (strreturn buf.String(), nil}-func writeTable(buf *strings.Builder, table *storepb.TableMetadata) error {+func writeTable(buf *strings.Builder, table *metadatapb.TableMetadata) error {if _, err := buf.WriteString(`CREATE TABLE "`); err != nil {return err}@@ -308,7 +310,7 @@ func writeTable(buf *strings.Builder, table *storepb.TableMetadata) error {return writeTriggers(buf, table.Triggers)}-func writeIndex(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeIndex(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {if _, err := buf.WriteString(`CREATE`); err != nil {return err}@@ -417,7 +419,7 @@ func writeIndex(buf *strings.Builder, table string, index *storepb.IndexMetadatareturn nil}-func writeForeignKey(buf *strings.Builder, fk *storepb.ForeignKeyMetadata) error {+func writeForeignKey(buf *strings.Builder, fk *metadatapb.ForeignKeyMetadata) error {if _, err := buf.WriteString(`CONSTRAINT "`); err != nil {return err}@@ -485,7 +487,7 @@ func writeForeignKey(buf *strings.Builder, fk *storepb.ForeignKeyMetadata) errorreturn err}-func writeCheckConstraint(buf *strings.Builder, check *storepb.CheckConstraintMetadata) error {+func writeCheckConstraint(buf *strings.Builder, check *metadatapb.CheckConstraintMetadata) error {if _, err := buf.WriteString(`CONSTRAINT "`); err != nil {return err}@@ -505,7 +507,7 @@ func writeCheckConstraint(buf *strings.Builder, check *storepb.CheckConstraintMereturn err}-func writeConstraint(buf *strings.Builder, constraint *storepb.IndexMetadata) error {+func writeConstraint(buf *strings.Builder, constraint *metadatapb.IndexMetadata) error {if _, err := buf.WriteString(`CONSTRAINT "`); err != nil {return err}@@ -569,7 +571,7 @@ func writeConstraint(buf *strings.Builder, constraint *storepb.IndexMetadata) erreturn nil}-func writeColumn(buf *strings.Builder, column *storepb.ColumnMetadata) error {+func writeColumn(buf *strings.Builder, column *metadatapb.ColumnMetadata) error {if _, err := buf.WriteString(`"`); err != nil {return err}@@ -622,7 +624,7 @@ func writeColumn(buf *strings.Builder, column *storepb.ColumnMetadata) error {return nil}-func writeSequence(buf *strings.Builder, sequence *storepb.SequenceMetadata) error {+func writeSequence(buf *strings.Builder, sequence *metadatapb.SequenceMetadata) error {if _, err := buf.WriteString("CREATE SEQUENCE \""); err != nil {return err}@@ -682,7 +684,7 @@ func getObjectID(schema, objectName string) string {}// writeView writes a CREATE VIEW statement-func writeView(buf *strings.Builder, view *storepb.ViewMetadata) error {+func writeView(buf *strings.Builder, view *metadatapb.ViewMetadata) error {if _, err := buf.WriteString(`CREATE VIEW "`); err != nil {return err}@@ -717,7 +719,7 @@ func writeView(buf *strings.Builder, view *storepb.ViewMetadata) error {}// writeMaterializedView writes a CREATE MATERIALIZED VIEW statement-func writeMaterializedView(buf *strings.Builder, view *storepb.MaterializedViewMetadata) error {+func writeMaterializedView(buf *strings.Builder, view *metadatapb.MaterializedViewMetadata) error {if _, err := buf.WriteString(`CREATE MATERIALIZED VIEW "`); err != nil {return err}@@ -743,7 +745,7 @@ func writeMaterializedView(buf *strings.Builder, view *storepb.MaterializedViewM}// writeFunction writes a CREATE FUNCTION statement-func writeFunction(buf *strings.Builder, function *storepb.FunctionMetadata) error {+func writeFunction(buf *strings.Builder, function *metadatapb.FunctionMetadata) error {definition := function.Definition// If the definition doesn't start with CREATE, add the CREATE OR REPLACE prefixif !strings.HasPrefix(strings.ToUpper(strings.TrimSpace(definition)), "CREATE") {@@ -766,7 +768,7 @@ func writeFunction(buf *strings.Builder, function *storepb.FunctionMetadata) err}// writeProcedure writes a CREATE PROCEDURE statement-func writeProcedure(buf *strings.Builder, procedure *storepb.ProcedureMetadata) error {+func writeProcedure(buf *strings.Builder, procedure *metadatapb.ProcedureMetadata) error {definition := procedure.Definition// If the definition doesn't start with CREATE, add the CREATE OR REPLACE prefixif !strings.HasPrefix(strings.ToUpper(strings.TrimSpace(definition)), "CREATE") {@@ -789,7 +791,7 @@ func writeProcedure(buf *strings.Builder, procedure *storepb.ProcedureMetadata)}// writeTriggers writes the CREATE TRIGGER statements owned by a table or view.-func writeTriggers(buf *strings.Builder, triggers []*storepb.TriggerMetadata) error {+func writeTriggers(buf *strings.Builder, triggers []*metadatapb.TriggerMetadata) error {for _, trigger := range triggers {if err := writeTrigger(buf, trigger); err != nil {return err@@ -799,7 +801,7 @@ func writeTriggers(buf *strings.Builder, triggers []*storepb.TriggerMetadata) er}// writeTrigger writes a CREATE TRIGGER statement-func writeTrigger(buf *strings.Builder, trigger *storepb.TriggerMetadata) error {+func writeTrigger(buf *strings.Builder, trigger *metadatapb.TriggerMetadata) error {// The trigger body should already contain the full CREATE TRIGGER statementif _, err := buf.WriteString(trigger.Body); err != nil {return errdiff --git a/backend/plugin/schema/oracle/get_database_definition_test.go b/backend/plugin/schema/oracle/get_database_definition_test.goindex e84a403569..570f520544 100644--- a/backend/plugin/schema/oracle/get_database_definition_test.go+++ b/backend/plugin/schema/oracle/get_database_definition_test.go@@ -3,6 +3,7 @@ package oracleimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""os"@@ -18,7 +19,7 @@ import (func TestGetTableDefinition(t *testing.T) {tests := []struct {name string- table *storepb.TableMetadata+ table *metadatapb.TableMetadatawant string}{{@@ -26,13 +27,13 @@ func TestGetTableDefinition(t *testing.T) {// table-level FOREIGN KEY with no other indexes or constraints.// The FK must be separated from the column by a comma (ORA-02253).name: "foreign key after default not null column without other constraints",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1", Type: "NUMBER", Nullable: false},{Name: "C2", Type: "NUMBER(1)", Default: "0", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "T1_FK",Columns: []string{"C1"},@@ -51,12 +52,12 @@ func TestGetTableDefinition(t *testing.T) {},{name: "check constraint after column without other constraints",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1", Type: "NUMBER", Nullable: false},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "T1_CK", Expression: `"C1" > 0`},},},@@ -69,13 +70,13 @@ func TestGetTableDefinition(t *testing.T) {},{name: "primary key, check, and foreign key",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "T1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "C1", Type: "NUMBER", Nullable: false},{Name: "C2", Type: "NUMBER(1)", Default: "0", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "T1_PK",Expressions: []string{"C1"},@@ -84,10 +85,10 @@ func TestGetTableDefinition(t *testing.T) {IsConstraint: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "T1_CK", Expression: `"C2" IN (0, 1)`},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "T1_FK",Columns: []string{"C1"},@@ -130,7 +131,7 @@ func TestGetObjectDefinition(t *testing.T) {{name: "view",get: func() (string, error) {- return GetViewDefinition("", &storepb.ViewMetadata{+ return GetViewDefinition("", &metadatapb.ViewMetadata{Name: "DEPT_EMPLOYEE_COUNT",Definition: "SELECT D.ID AS DEPT_ID, COUNT(E.ID) AS EMP_COUNT\nFROM DEPARTMENTS D",})@@ -143,7 +144,7 @@ FROM DEPARTMENTS D;{name: "materialized view",get: func() (string, error) {- return GetMaterializedViewDefinition("", &storepb.MaterializedViewMetadata{+ return GetMaterializedViewDefinition("", &metadatapb.MaterializedViewMetadata{Name: "PRODUCT_STATS",Definition: "SELECT PRODUCT_ID, COUNT(*) AS ORDER_COUNT FROM ORDERS GROUP BY PRODUCT_ID",})@@ -157,7 +158,7 @@ FROM DEPARTMENTS D;// CREATE OR REPLACE prefix has to be supplied here.name: "function gains the CREATE OR REPLACE prefix",get: func() (string, error) {- return GetFunctionDefinition("", &storepb.FunctionMetadata{+ return GetFunctionDefinition("", &metadatapb.FunctionMetadata{Name: "CALCULATE_DISCOUNT",Definition: "FUNCTION CALCULATE_DISCOUNT(AMOUNT NUMBER)\nRETURN NUMBER\nIS\nBEGIN\n RETURN AMOUNT * 0.1;\nEND;",})@@ -174,7 +175,7 @@ END;{name: "procedure gains the CREATE OR REPLACE prefix",get: func() (string, error) {- return GetProcedureDefinition("", &storepb.ProcedureMetadata{+ return GetProcedureDefinition("", &metadatapb.ProcedureMetadata{Name: "LOG_AUDIT",Definition: "PROCEDURE LOG_AUDIT(P_TABLE_NAME VARCHAR2)\nIS\nBEGIN\n NULL;\nEND;",})@@ -194,10 +195,10 @@ END;// prepends CREATE OR REPLACE TRIGGER to ALL_TRIGGERS.DESCRIPTION.name: "view keeps its INSTEAD OF trigger",get: func() (string, error) {- return GetViewDefinition("", &storepb.ViewMetadata{+ return GetViewDefinition("", &metadatapb.ViewMetadata{Name: "EMPLOYEE_VIEW",Definition: "SELECT EMP_ID, EMAIL FROM EMPLOYEES",- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "EMPLOYEE_VIEW_INSERT_TRG",Body: "CREATE OR REPLACE TRIGGER EMPLOYEE_VIEW_INSERT_TRG\nINSTEAD OF INSERT ON EMPLOYEE_VIEW\nFOR EACH ROW\nBEGIN\n NULL;\nEND;",@@ -241,25 +242,25 @@ func TestObjectDefinitionsRegisteredForOracle(t *testing.T) {{name: "view",get: func() (string, error) {- return schema.GetViewDefinition(storepb.Engine_ORACLE, "", &storepb.ViewMetadata{Name: "V", Definition: "SELECT 1 FROM DUAL"})+ return schema.GetViewDefinition(storepb.Engine_ORACLE, "", &metadatapb.ViewMetadata{Name: "V", Definition: "SELECT 1 FROM DUAL"})},},{name: "materialized view",get: func() (string, error) {- return schema.GetMaterializedViewDefinition(storepb.Engine_ORACLE, "", &storepb.MaterializedViewMetadata{Name: "MV", Definition: "SELECT 1 FROM DUAL"})+ return schema.GetMaterializedViewDefinition(storepb.Engine_ORACLE, "", &metadatapb.MaterializedViewMetadata{Name: "MV", Definition: "SELECT 1 FROM DUAL"})},},{name: "function",get: func() (string, error) {- return schema.GetFunctionDefinition(storepb.Engine_ORACLE, "", &storepb.FunctionMetadata{Name: "F", Definition: "FUNCTION F RETURN NUMBER IS BEGIN RETURN 1; END;"})+ return schema.GetFunctionDefinition(storepb.Engine_ORACLE, "", &metadatapb.FunctionMetadata{Name: "F", Definition: "FUNCTION F RETURN NUMBER IS BEGIN RETURN 1; END;"})},},{name: "procedure",get: func() (string, error) {- return schema.GetProcedureDefinition(storepb.Engine_ORACLE, "", &storepb.ProcedureMetadata{Name: "P", Definition: "PROCEDURE P IS BEGIN NULL; END;"})+ return schema.GetProcedureDefinition(storepb.Engine_ORACLE, "", &metadatapb.ProcedureMetadata{Name: "P", Definition: "PROCEDURE P IS BEGIN NULL; END;"})},},}@@ -298,7 +299,7 @@ func TestGetDatabaseDefinition(t *testing.T) {for i, tc := range tests {t.Run(tc.Description, func(t *testing.T) {- var metadata storepb.DatabaseSchemaMetadata+ var metadata metadatapb.DatabaseSchemaMetadatarequire.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), &metadata))definition, err := GetDatabaseDefinition(schema.GetDefinitionContext{}, &metadata)diff --git a/backend/plugin/schema/oracle/get_database_metadata.go b/backend/plugin/schema/oracle/get_database_metadata.goindex ea5ba7cc64..b24c7b3657 100644--- a/backend/plugin/schema/oracle/get_database_metadata.go+++ b/backend/plugin/schema/oracle/get_database_metadata.go@@ -5,6 +5,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"@@ -19,7 +20,7 @@ func init() {// GetDatabaseMetadata parses Oracle schema DDL text and returns database metadata// using the omni parser AST.-func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error) {+func GetDatabaseMetadata(schemaText string) (*metadatapb.DatabaseSchemaMetadata, error) {list, err := plsqlparser.ParsePLSQL(schemaText)if err != nil {return nil, errors.Wrapf(err, "failed to parse Oracle schema")@@ -29,14 +30,14 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, er}extractor := &oracleOmniMetadataExtractor{- tables: make(map[string]*storepb.TableMetadata),- views: make(map[string]*storepb.ViewMetadata),- materializedViews: make(map[string]*storepb.MaterializedViewMetadata),- functions: make(map[string]*storepb.FunctionMetadata),- procedures: make(map[string]*storepb.ProcedureMetadata),- triggers: make(map[string]*storepb.TriggerMetadata),- sequences: make(map[string]*storepb.SequenceMetadata),- packages: make(map[string]*storepb.PackageMetadata),+ tables: make(map[string]*metadatapb.TableMetadata),+ views: make(map[string]*metadatapb.ViewMetadata),+ materializedViews: make(map[string]*metadatapb.MaterializedViewMetadata),+ functions: make(map[string]*metadatapb.FunctionMetadata),+ procedures: make(map[string]*metadatapb.ProcedureMetadata),+ triggers: make(map[string]*metadatapb.TriggerMetadata),+ sequences: make(map[string]*metadatapb.SequenceMetadata),+ packages: make(map[string]*metadatapb.PackageMetadata),checkNames: make(map[string]map[string]bool),checkNameNext: make(map[string]map[string]int),schemaText: schemaText,@@ -56,35 +57,35 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, ertype oracleOmniMetadataExtractor struct {currentDatabase stringcurrentSchema string- tables map[string]*storepb.TableMetadata- views map[string]*storepb.ViewMetadata- materializedViews map[string]*storepb.MaterializedViewMetadata- functions map[string]*storepb.FunctionMetadata- procedures map[string]*storepb.ProcedureMetadata- triggers map[string]*storepb.TriggerMetadata- sequences map[string]*storepb.SequenceMetadata- packages map[string]*storepb.PackageMetadata+ tables map[string]*metadatapb.TableMetadata+ views map[string]*metadatapb.ViewMetadata+ materializedViews map[string]*metadatapb.MaterializedViewMetadata+ functions map[string]*metadatapb.FunctionMetadata+ procedures map[string]*metadatapb.ProcedureMetadata+ triggers map[string]*metadatapb.TriggerMetadata+ sequences map[string]*metadatapb.SequenceMetadata+ packages map[string]*metadatapb.PackageMetadatacheckNames map[string]map[string]boolcheckNameNext map[string]map[string]intschemaText string}-func (e *oracleOmniMetadataExtractor) databaseMetadata() *storepb.DatabaseSchemaMetadata {+func (e *oracleOmniMetadataExtractor) databaseMetadata() *metadatapb.DatabaseSchemaMetadata {e.resolveForeignKeyReferencedColumns()- schemaMetadata := &storepb.DatabaseSchemaMetadata{+ schemaMetadata := &metadatapb.DatabaseSchemaMetadata{Name: e.currentDatabase,- Schemas: []*storepb.SchemaMetadata{},+ Schemas: []*metadatapb.SchemaMetadata{},}- schema := &storepb.SchemaMetadata{+ schema := &metadatapb.SchemaMetadata{Name: e.currentSchema,- Tables: []*storepb.TableMetadata{},- Views: []*storepb.ViewMetadata{},- MaterializedViews: []*storepb.MaterializedViewMetadata{},- Procedures: []*storepb.ProcedureMetadata{},- Functions: []*storepb.FunctionMetadata{},- Sequences: []*storepb.SequenceMetadata{},- Packages: []*storepb.PackageMetadata{},+ Tables: []*metadatapb.TableMetadata{},+ Views: []*metadatapb.ViewMetadata{},+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{},+ Procedures: []*metadatapb.ProcedureMetadata{},+ Functions: []*metadatapb.FunctionMetadata{},+ Sequences: []*metadatapb.SequenceMetadata{},+ Packages: []*metadatapb.PackageMetadata{},}var tableNames []string@@ -156,18 +157,18 @@ func (e *oracleOmniMetadataExtractor) databaseMetadata() *storepb.DatabaseSchemareturn schemaMetadata}-func (e *oracleOmniMetadataExtractor) getOrCreateTable(tableName string) *storepb.TableMetadata {+func (e *oracleOmniMetadataExtractor) getOrCreateTable(tableName string) *metadatapb.TableMetadata {if table, ok := e.tables[tableName]; ok {return table}- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: tableName,- Columns: []*storepb.ColumnMetadata{},- Indexes: []*storepb.IndexMetadata{},- ForeignKeys: []*storepb.ForeignKeyMetadata{},- CheckConstraints: []*storepb.CheckConstraintMetadata{},- Triggers: []*storepb.TriggerMetadata{},- Partitions: []*storepb.TablePartitionMetadata{},+ Columns: []*metadatapb.ColumnMetadata{},+ Indexes: []*metadatapb.IndexMetadata{},+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{},+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{},+ Triggers: []*metadatapb.TriggerMetadata{},+ Partitions: []*metadatapb.TablePartitionMetadata{},}e.tables[tableName] = tablereturn table@@ -187,11 +188,11 @@ func (e *oracleOmniMetadataExtractor) extractStatement(stmt ast.StmtNode) {e.extractCreateSequence(n)case *ast.CreateProcedureStmt:if name := objectName(n.Name); name != "" {- e.procedures[name] = &storepb.ProcedureMetadata{Name: name, Definition: e.definitionText(n)}+ e.procedures[name] = &metadatapb.ProcedureMetadata{Name: name, Definition: e.definitionText(n)}}case *ast.CreateFunctionStmt:if name := objectName(n.Name); name != "" {- e.functions[name] = &storepb.FunctionMetadata{Name: name, Definition: e.functionDefinitionText(n)}+ e.functions[name] = &metadatapb.FunctionMetadata{Name: name, Definition: e.functionDefinitionText(n)}}case *ast.CreatePackageStmt:if name := objectName(n.Name); name != "" {@@ -246,8 +247,8 @@ func (e *oracleOmniMetadataExtractor) extractCreateTable(n *ast.CreateTableStmt)}}-func (e *oracleOmniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *storepb.TableMetadata) {- column := &storepb.ColumnMetadata{+func (e *oracleOmniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *metadatapb.TableMetadata) {+ column := &metadatapb.ColumnMetadata{Name: n.Name,Type: "VARCHAR2(100)",Nullable: true,@@ -293,7 +294,7 @@ func (e *oracleOmniMetadataExtractor) extractColumn(n *ast.ColumnDef, table *stotable.Columns = append(table.Columns, column)}-func (e *oracleOmniMetadataExtractor) extractColumnConstraint(n *ast.ColumnConstraint, table *storepb.TableMetadata, column *storepb.ColumnMetadata) {+func (e *oracleOmniMetadataExtractor) extractColumnConstraint(n *ast.ColumnConstraint, table *metadatapb.TableMetadata, column *metadatapb.ColumnMetadata) {switch n.Type {case ast.CONSTRAINT_NOT_NULL:column.Nullable = false@@ -306,7 +307,7 @@ func (e *oracleOmniMetadataExtractor) extractColumnConstraint(n *ast.ColumnConstcase ast.CONSTRAINT_PRIMARY:column.Nullable = falseif !hasPrimaryIndex(table) {- table.Indexes = append(table.Indexes, &storepb.IndexMetadata{+ table.Indexes = append(table.Indexes, &metadatapb.IndexMetadata{Name: fallbackName(n.Name, fmt.Sprintf("PK_%s", table.Name)),Primary: true,Unique: true,@@ -319,7 +320,7 @@ func (e *oracleOmniMetadataExtractor) extractColumnConstraint(n *ast.ColumnConstcase ast.CONSTRAINT_UNIQUE:name := fallbackName(n.Name, fmt.Sprintf("UK_%s_%s", table.Name, column.Name))if !hasUniqueIndex(table, []string{column.Name}) {- table.Indexes = append(table.Indexes, &storepb.IndexMetadata{+ table.Indexes = append(table.Indexes, &metadatapb.IndexMetadata{Name: name,Unique: true,Type: "NORMAL",@@ -336,14 +337,14 @@ func (e *oracleOmniMetadataExtractor) extractColumnConstraint(n *ast.ColumnConst}}-func (e *oracleOmniMetadataExtractor) extractTableConstraint(n *ast.TableConstraint, table *storepb.TableMetadata) {+func (e *oracleOmniMetadataExtractor) extractTableConstraint(n *ast.TableConstraint, table *metadatapb.TableMetadata) {columns := stringList(n.Columns)switch n.Type {case ast.CONSTRAINT_PRIMARY:if len(columns) == 0 {return}- table.Indexes = append(table.Indexes, &storepb.IndexMetadata{+ table.Indexes = append(table.Indexes, &metadatapb.IndexMetadata{Name: fallbackName(n.Name, fmt.Sprintf("PK_%s", table.Name)),Primary: true,Unique: true,@@ -357,7 +358,7 @@ func (e *oracleOmniMetadataExtractor) extractTableConstraint(n *ast.TableConstraif len(columns) == 0 {return}- table.Indexes = append(table.Indexes, &storepb.IndexMetadata{+ table.Indexes = append(table.Indexes, &metadatapb.IndexMetadata{Name: fallbackName(n.Name, fmt.Sprintf("UK_%s_%d", table.Name, len(table.Indexes)+1)),Unique: true,Type: "NORMAL",@@ -405,25 +406,25 @@ func (e *oracleOmniMetadataExtractor) extractAlterTable(n *ast.AlterTableStmt) {}}-func (e *oracleOmniMetadataExtractor) appendCheckConstraint(table *storepb.TableMetadata, name string, expr ast.ExprNode) {+func (e *oracleOmniMetadataExtractor) appendCheckConstraint(table *metadatapb.TableMetadata, name string, expr ast.ExprNode) {if expr == nil {return}e.reserveCheckConstraintName(table, name)- table.CheckConstraints = append(table.CheckConstraints, &storepb.CheckConstraintMetadata{+ table.CheckConstraints = append(table.CheckConstraints, &metadatapb.CheckConstraintMetadata{Name: name,Expression: e.exprText(expr),})}-func (e *oracleOmniMetadataExtractor) checkConstraintName(table *storepb.TableMetadata, name string, fallback string) string {+func (e *oracleOmniMetadataExtractor) checkConstraintName(table *metadatapb.TableMetadata, name string, fallback string) string {if name != "" {return name}return e.uniqueCheckConstraintName(table, fallback)}-func (e *oracleOmniMetadataExtractor) uniqueCheckConstraintName(table *storepb.TableMetadata, fallback string) string {+func (e *oracleOmniMetadataExtractor) uniqueCheckConstraintName(table *metadatapb.TableMetadata, fallback string) string {used := e.checkConstraintNameSet(table)if !used[fallback] {return fallback@@ -443,11 +444,11 @@ func (e *oracleOmniMetadataExtractor) uniqueCheckConstraintName(table *storepb.T}}-func (e *oracleOmniMetadataExtractor) reserveCheckConstraintName(table *storepb.TableMetadata, name string) {+func (e *oracleOmniMetadataExtractor) reserveCheckConstraintName(table *metadatapb.TableMetadata, name string) {e.checkConstraintNameSet(table)[name] = true}-func (e *oracleOmniMetadataExtractor) checkConstraintNameSet(table *storepb.TableMetadata) map[string]bool {+func (e *oracleOmniMetadataExtractor) checkConstraintNameSet(table *metadatapb.TableMetadata) map[string]bool {used := e.checkNames[table.Name]if used != nil {return used@@ -460,7 +461,7 @@ func (e *oracleOmniMetadataExtractor) checkConstraintNameSet(table *storepb.Tablreturn used}-func (e *oracleOmniMetadataExtractor) checkConstraintNameNextSet(table *storepb.TableMetadata) map[string]int {+func (e *oracleOmniMetadataExtractor) checkConstraintNameNextSet(table *metadatapb.TableMetadata) map[string]int {next := e.checkNameNext[table.Name]if next != nil {return next@@ -470,13 +471,13 @@ func (e *oracleOmniMetadataExtractor) checkConstraintNameNextSet(table *storepb.return next}-func (*oracleOmniMetadataExtractor) appendForeignKey(table *storepb.TableMetadata, name string, columns []string, refTable *ast.ObjectName, refColumns *ast.List, onDelete string) {+func (*oracleOmniMetadataExtractor) appendForeignKey(table *metadatapb.TableMetadata, name string, columns []string, refTable *ast.ObjectName, refColumns *ast.List, onDelete string) {referencedTable := objectName(refTable)referencedColumns := stringList(refColumns)if len(columns) == 0 || referencedTable == "" {return}- foreignKey := &storepb.ForeignKeyMetadata{+ foreignKey := &metadatapb.ForeignKeyMetadata{Name: name,Columns: columns,ReferencedTable: referencedTable,@@ -488,7 +489,7 @@ func (*oracleOmniMetadataExtractor) appendForeignKey(table *storepb.TableMetadatfunc (e *oracleOmniMetadataExtractor) resolveForeignKeyReferencedColumns() {for _, table := range e.tables {- var foreignKeys []*storepb.ForeignKeyMetadata+ var foreignKeys []*metadatapb.ForeignKeyMetadatafor _, foreignKey := range table.ForeignKeys {if len(foreignKey.ReferencedColumns) == 0 {referencedTable := e.tables[foreignKey.ReferencedTable]@@ -513,7 +514,7 @@ func (e *oracleOmniMetadataExtractor) extractCreateIndex(n *ast.CreateIndexStmt)e.currentSchema = n.Name.Schema}- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: indexName,Unique: n.Unique,Type: "NORMAL",@@ -571,7 +572,7 @@ func (e *oracleOmniMetadataExtractor) extractCreateView(n *ast.CreateViewStmt) {definition := e.nodeText(n.Query)if n.Materialized {- materializedView := &storepb.MaterializedViewMetadata{+ materializedView := &metadatapb.MaterializedViewMetadata{Name: viewName,Definition: definition,}@@ -587,7 +588,7 @@ func (e *oracleOmniMetadataExtractor) extractCreateView(n *ast.CreateViewStmt) {return}- view := &storepb.ViewMetadata{+ view := &metadatapb.ViewMetadata{Name: viewName,Definition: definition,}@@ -603,7 +604,7 @@ func (e *oracleOmniMetadataExtractor) extractCreateSequence(n *ast.CreateSequencif sequenceName == "" {return}- sequence := &storepb.SequenceMetadata{Name: sequenceName}+ sequence := &metadatapb.SequenceMetadata{Name: sequenceName}if start := e.nodeText(n.StartWith); start != "" {sequence.Start = start}@@ -620,7 +621,7 @@ func (e *oracleOmniMetadataExtractor) extractCreatePackage(name string, n *ast.C}pkg := e.packages[name]if pkg == nil {- e.packages[name] = &storepb.PackageMetadata{Name: name, Definition: definition}+ e.packages[name] = &metadatapb.PackageMetadata{Name: name, Definition: definition}return}if pkg.Definition == "" {@@ -636,7 +637,7 @@ func (e *oracleOmniMetadataExtractor) extractCreateTrigger(n *ast.CreateTriggerSif triggerName == "" || tableName == "" {return}- trigger := &storepb.TriggerMetadata{+ trigger := &metadatapb.TriggerMetadata{Name: triggerName,Body: e.definitionText(n),}@@ -859,7 +860,7 @@ func fallbackName(name, fallback string) string {return fallback}-func hasPrimaryIndex(table *storepb.TableMetadata) bool {+func hasPrimaryIndex(table *metadatapb.TableMetadata) bool {for _, index := range table.Indexes {if index.Primary {return true@@ -868,7 +869,7 @@ func hasPrimaryIndex(table *storepb.TableMetadata) bool {return false}-func primaryKeyColumns(table *storepb.TableMetadata) []string {+func primaryKeyColumns(table *metadatapb.TableMetadata) []string {if table == nil {return nil}@@ -880,7 +881,7 @@ func primaryKeyColumns(table *storepb.TableMetadata) []string {return nil}-func hasUniqueIndex(table *storepb.TableMetadata, columns []string) bool {+func hasUniqueIndex(table *metadatapb.TableMetadata, columns []string) bool {for _, index := range table.Indexes {if !index.Unique || index.Primary || len(index.Expressions) != len(columns) {continue@@ -899,7 +900,7 @@ func hasUniqueIndex(table *storepb.TableMetadata, columns []string) bool {return false}-func markColumnsNotNull(table *storepb.TableMetadata, columns []string) {+func markColumnsNotNull(table *metadatapb.TableMetadata, columns []string) {for _, column := range table.Columns {if slices.Contains(columns, column.Name) {column.Nullable = falsediff --git a/backend/plugin/schema/oracle/get_database_metadata_test.go b/backend/plugin/schema/oracle/get_database_metadata_test.goindex d84eab907f..61988a2bdd 100644--- a/backend/plugin/schema/oracle/get_database_metadata_test.go+++ b/backend/plugin/schema/oracle/get_database_metadata_test.go@@ -5,6 +5,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -60,7 +61,7 @@ func TestGetDatabaseMetadataObjectKinds(t *testing.T) {tests := []struct {name stringddl string- verify func(*testing.T, *storepb.DatabaseSchemaMetadata)+ verify func(*testing.T, *metadatapb.DatabaseSchemaMetadata)}{{name: "table_constraints_indexes_view_sequence",@@ -91,7 +92,7 @@ WHERE EMAIL IS NOT NULL;CREATE SEQUENCE emp_seq START WITH 1 INCREMENT BY 1;`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)departments := requireTable(t, schemaMetadata, "DEPARTMENTS")@@ -133,7 +134,7 @@ CREATE TABLE EMPLOYEES (CREATE VIEW EMPLOYEE_VIEW ASSELECT EMP_ID, EMAIL FROM EMPLOYEES;`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)require.Equal(t, "HR", schemaMetadata.Name)employees := requireTable(t, schemaMetadata, "EMPLOYEES")@@ -167,7 +168,7 @@ GROUP BY PRODUCT_ID, CATEGORY;COMMENT ON VIEW PRODUCT_SALES_VIEW IS 'Product sales view';COMMENT ON MATERIALIZED VIEW PRODUCT_SALES_MV IS 'Product sales materialized view';`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)require.Equal(t, "Product sales view", requireView(t, schemaMetadata, "PRODUCT_SALES_VIEW").Comment)require.Len(t, schemaMetadata.MaterializedViews, 1)@@ -186,7 +187,7 @@ CREATE TABLE ORDERS (CREATE INDEX idx_orders_status_invisible ON ORDERS(STATUS) INVISIBLE;CREATE BITMAP INDEX idx_orders_lower_status ON ORDERS(LOWER(STATUS));`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {orders := requireTable(t, requireSingleSchema(t, metadata), "ORDERS")invisibleIndex := requireIndexMetadata(t, orders, "IDX_ORDERS_STATUS_INVISIBLE")require.False(t, invisibleIndex.Visible)@@ -215,7 +216,7 @@ BEGINEND;/`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)view := requireView(t, schemaMetadata, "EMPLOYEE_VIEW")require.Len(t, view.Triggers, 1)@@ -242,7 +243,7 @@ GROUP BY PRODUCT_ID, CATEGORY;CREATE INDEX idx_mv_category ON PRODUCT_SALES_MV(CATEGORY);`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)requireTable(t, schemaMetadata, "PRODUCT_SALES")require.Len(t, schemaMetadata.MaterializedViews, 1)@@ -267,7 +268,7 @@ CREATE TABLE EMPLOYEES (ALTER TABLE DEPARTMENTS ADD CONSTRAINT fk_dept_managerFOREIGN KEY (MANAGER_ID) REFERENCES EMPLOYEES(EMP_ID) ON DELETE SET NULL;`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)departments := requireTable(t, schemaMetadata, "DEPARTMENTS")requireForeignKey(t, departments, "FK_DEPT_MANAGER", []string{"MANAGER_ID"}, "EMPLOYEES", []string{"EMP_ID"}, "SET NULL")@@ -285,7 +286,7 @@ ALTER TABLE EMPLOYEES ADD (STATUS VARCHAR2(20) DEFAULT 'ACTIVE');`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {employees := requireTable(t, requireSingleSchema(t, metadata), "EMPLOYEES")require.Len(t, employees.Columns, 3)require.Equal(t, "EMAIL", employees.Columns[1].Name)@@ -311,7 +312,7 @@ CREATE TABLE EMPLOYEES (CONSTRAINT fk_manager_dept FOREIGN KEY (MANAGER_DEPT_ID) REFERENCES DEPARTMENTS);`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {employees := requireTable(t, requireSingleSchema(t, metadata), "EMPLOYEES")requireCheckConstraint(t, employees, "CHK_EMPLOYEES_SALARY", "SALARY>0")requireCheckConstraint(t, employees, "CHK_EMPLOYEES_SALARY_2", "SALARY<1000000")@@ -328,7 +329,7 @@ CREATE TABLE ORDER_ITEMS (TOTAL AS (QTY * PRICE));`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {orderItems := requireTable(t, requireSingleSchema(t, metadata), "ORDER_ITEMS")require.Len(t, orderItems.Columns, 3)require.Equal(t, "TOTAL", orderItems.Columns[2].Name)@@ -345,7 +346,7 @@ CREATE TABLE AUTHORS (CONSTRAINT chk_author_name CHECK (NAME <> 'O''Reilly'));`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {authors := requireTable(t, requireSingleSchema(t, metadata), "AUTHORS")require.Len(t, authors.Columns, 2)require.Equal(t, "CASEWHENNAME='O''Reilly'THEN1ELSE0END", authors.Columns[1].Default)@@ -360,7 +361,7 @@ CREATE TABLE ORDERS (STATUS VARCHAR2(20) DEFAULT ON NULL 'PENDING');`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {orders := requireTable(t, requireSingleSchema(t, metadata), "ORDERS")require.Len(t, orders.Columns, 2)require.Equal(t, "STATUS", orders.Columns[1].Name)@@ -385,7 +386,7 @@ CREATE OR REPLACE PACKAGE BODY financial_utils ASEND financial_utils;/`,- verify: func(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) {+ verify: func(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) {schemaMetadata := requireSingleSchema(t, metadata)require.Len(t, schemaMetadata.Packages, 1)require.Equal(t, "FINANCIAL_UTILS", schemaMetadata.Packages[0].Name)@@ -440,20 +441,20 @@ END;requireIndex(t, table, "PK_AUDIT_LOG", []string{"LOG_ID"}, true, true)}-func requireSingleSchema(t *testing.T, metadata *storepb.DatabaseSchemaMetadata) *storepb.SchemaMetadata {+func requireSingleSchema(t *testing.T, metadata *metadatapb.DatabaseSchemaMetadata) *metadatapb.SchemaMetadata {t.Helper()require.Len(t, metadata.Schemas, 1)return metadata.Schemas[0]}-func requireTable(t *testing.T, schemaMetadata *storepb.SchemaMetadata, name string) *storepb.TableMetadata {+func requireTable(t *testing.T, schemaMetadata *metadatapb.SchemaMetadata, name string) *metadatapb.TableMetadata {t.Helper()table := findTable(schemaMetadata, name)require.NotNil(t, table)return table}-func requireView(t *testing.T, schemaMetadata *storepb.SchemaMetadata, name string) *storepb.ViewMetadata {+func requireView(t *testing.T, schemaMetadata *metadatapb.SchemaMetadata, name string) *metadatapb.ViewMetadata {t.Helper()for _, view := range schemaMetadata.Views {if view.Name == name {@@ -464,7 +465,7 @@ func requireView(t *testing.T, schemaMetadata *storepb.SchemaMetadata, name strireturn nil}-func findTable(schemaMetadata *storepb.SchemaMetadata, name string) *storepb.TableMetadata {+func findTable(schemaMetadata *metadatapb.SchemaMetadata, name string) *metadatapb.TableMetadata {for _, table := range schemaMetadata.Tables {if table.Name == name {return table@@ -473,7 +474,7 @@ func findTable(schemaMetadata *storepb.SchemaMetadata, name string) *storepb.Tabreturn nil}-func requireIndex(t *testing.T, table *storepb.TableMetadata, name string, expressions []string, primary bool, unique bool) {+func requireIndex(t *testing.T, table *metadatapb.TableMetadata, name string, expressions []string, primary bool, unique bool) {t.Helper()index := requireIndexMetadata(t, table, name)require.Equal(t, expressions, index.Expressions)@@ -481,7 +482,7 @@ func requireIndex(t *testing.T, table *storepb.TableMetadata, name string, exprerequire.Equal(t, unique, index.Unique)}-func requireIndexMetadata(t *testing.T, table *storepb.TableMetadata, name string) *storepb.IndexMetadata {+func requireIndexMetadata(t *testing.T, table *metadatapb.TableMetadata, name string) *metadatapb.IndexMetadata {t.Helper()for _, index := range table.Indexes {if index.Name == name {@@ -492,7 +493,7 @@ func requireIndexMetadata(t *testing.T, table *storepb.TableMetadata, name strinreturn nil}-func requireMaterializedViewIndex(t *testing.T, materializedView *storepb.MaterializedViewMetadata, name string, expressions []string, primary bool, unique bool) {+func requireMaterializedViewIndex(t *testing.T, materializedView *metadatapb.MaterializedViewMetadata, name string, expressions []string, primary bool, unique bool) {t.Helper()for _, index := range materializedView.Indexes {if index.Name != name {@@ -510,7 +511,7 @@ func requireMaterializedViewIndex(t *testing.T, materializedView *storepb.Materi// which for most nodes means with every space removed: "SALARY > 0" arrives as// "SALARY>0". The assertions below spell out that form rather than the readable// one so they describe what the package returns today.-func requireCheckConstraint(t *testing.T, table *storepb.TableMetadata, name string, expression string) {+func requireCheckConstraint(t *testing.T, table *metadatapb.TableMetadata, name string, expression string) {t.Helper()for _, check := range table.CheckConstraints {if check.Name != name {@@ -522,7 +523,7 @@ func requireCheckConstraint(t *testing.T, table *storepb.TableMetadata, name strt.Fatalf("check constraint %q not found in table %q", name, table.Name)}-func requireForeignKey(t *testing.T, table *storepb.TableMetadata, name string, columns []string, referencedTable string, referencedColumns []string, onDelete string) {+func requireForeignKey(t *testing.T, table *metadatapb.TableMetadata, name string, columns []string, referencedTable string, referencedColumns []string, onDelete string) {t.Helper()for _, fk := range table.ForeignKeys {if fk.Name != name {diff --git a/backend/plugin/schema/pg/get_database_definition.go b/backend/plugin/schema/pg/get_database_definition.goindex 7761ccc5be..2398727f2c 100644--- a/backend/plugin/schema/pg/get_database_definition.go+++ b/backend/plugin/schema/pg/get_database_definition.go@@ -9,6 +9,7 @@ import ("github.com/pkg/errors""google.golang.org/protobuf/proto"+ metadatapb "github.com/bytebase/omni/metadata"omnipg "github.com/bytebase/omni/pg""github.com/bytebase/omni/pg/ast"@@ -49,7 +50,7 @@ func init() {}}-func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {metadata = filterBackupSchemaIfNecessary(ctx, metadata)// Clone before mutating: the caller's *DatabaseSchemaMetadata is often a@@ -124,10 +125,10 @@ func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.Da// Build the graph for topological sort.graph := parserbase.NewGraph()- functionMap := make(map[string]*storepb.FunctionMetadata)- tableMap := make(map[string]*storepb.TableMetadata)- viewMap := make(map[string]*storepb.ViewMetadata)- materializedViewMap := make(map[string]*storepb.MaterializedViewMetadata)+ functionMap := make(map[string]*metadatapb.FunctionMetadata)+ tableMap := make(map[string]*metadatapb.TableMetadata)+ viewMap := make(map[string]*metadatapb.ViewMetadata)+ materializedViewMap := make(map[string]*metadatapb.MaterializedViewMetadata)// Construct functions.for _, schema := range metadata.Schemas {@@ -150,7 +151,7 @@ func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.Da// Build identity column map once for O(m*c) instead of O(s*m*c) when checking each sequence.identityColumnMap := buildIdentityColumnMap(metadata)- sequenceOwnershipMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceOwnershipMap := make(map[string][]*metadatapb.SequenceMetadata)for _, schema := range metadata.Schemas {for _, sequence := range schema.Sequences {if sequence.SkipDump {@@ -322,16 +323,16 @@ func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.Dareturn buf.String(), nil}-func GetSchemaSDLDefinition(schema *storepb.SchemaMetadata) (string, error) {+func GetSchemaSDLDefinition(schema *metadatapb.SchemaMetadata) (string, error) {// Create a temporary database metadata containing just this schema- tempMetadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{schema},+ tempMetadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{schema},}return getSDLFormat(tempMetadata)}-func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error) {+func GetSchemaDefinition(schema *metadatapb.SchemaMetadata) (string, error) {var buf strings.Builderif err := writeSchema(&buf, schema); err != nil {return "", err@@ -371,10 +372,10 @@ func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error) {// Build the graph for topological sort.graph := parserbase.NewGraph()- functionMap := make(map[string]*storepb.FunctionMetadata)- tableMap := make(map[string]*storepb.TableMetadata)- viewMap := make(map[string]*storepb.ViewMetadata)- materializedViewMap := make(map[string]*storepb.MaterializedViewMetadata)+ functionMap := make(map[string]*metadatapb.FunctionMetadata)+ tableMap := make(map[string]*metadatapb.TableMetadata)+ viewMap := make(map[string]*metadatapb.ViewMetadata)+ materializedViewMap := make(map[string]*metadatapb.MaterializedViewMetadata)// Construct functions.for _, function := range schema.Functions {@@ -395,7 +396,7 @@ func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error) {// Build identity column map once for O(m*c) instead of O(s*m*c) when checking each sequence.identityColumnMap := buildIdentityColumnMapForSchema(schema)- sequenceOwnershipMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceOwnershipMap := make(map[string][]*metadatapb.SequenceMetadata)for _, sequence := range schema.Sequences {if sequence.SkipDump {continue@@ -533,14 +534,14 @@ func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error) {}// Construct foreign keys.- if err := writeSchemaForeignKeys(&buf, schema, collectTables([]*storepb.SchemaMetadata{schema}, tableMissingColumnMetadata)); err != nil {+ if err := writeSchemaForeignKeys(&buf, schema, collectTables([]*metadatapb.SchemaMetadata{schema}, tableMissingColumnMetadata)); err != nil {return "", err}return buf.String(), nil}-func GetTableDefinition(schema string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(schema string, table *metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata) (string, error) {var buf strings.Builderif err := writeTable(&buf, schema, table, sequences); err != nil {return "", err@@ -574,7 +575,7 @@ func GetTableDefinition(schema string, table *storepb.TableMetadata, sequences [return buf.String(), nil}-func GetViewDefinition(schema string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(schema string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.Builderif err := writeView(&buf, schema, view); err != nil {return "", err@@ -589,7 +590,7 @@ func GetViewDefinition(schema string, view *storepb.ViewMetadata) (string, error}}// Construct rules (non-SELECT rules only, as SELECT rules are part of the view definition).- var nonSelectRules []*storepb.RuleMetadata+ var nonSelectRules []*metadatapb.RuleMetadatafor _, rule := range view.Rules {if rule.Event != "SELECT" {nonSelectRules = append(nonSelectRules, rule)@@ -603,7 +604,7 @@ func GetViewDefinition(schema string, view *storepb.ViewMetadata) (string, errorreturn buf.String(), nil}-func GetMaterializedViewDefinition(schema string, view *storepb.MaterializedViewMetadata) (string, error) {+func GetMaterializedViewDefinition(schema string, view *metadatapb.MaterializedViewMetadata) (string, error) {var buf strings.Builderif err := writeMaterializedView(&buf, schema, view); err != nil {return "", err@@ -620,7 +621,7 @@ func GetMaterializedViewDefinition(schema string, view *storepb.MaterializedViewreturn buf.String(), nil}-func GetFunctionDefinition(schema string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(schema string, function *metadatapb.FunctionMetadata) (string, error) {var buf strings.Builderif err := writeFunction(&buf, schema, function); err != nil {return "", err@@ -628,7 +629,7 @@ func GetFunctionDefinition(schema string, function *storepb.FunctionMetadata) (sreturn buf.String(), nil}-func GetSequenceDefinition(schema string, sequence *storepb.SequenceMetadata) (string, error) {+func GetSequenceDefinition(schema string, sequence *metadatapb.SequenceMetadata) (string, error) {var buf strings.Builderif err := writeCreateSequence(&buf, schema, sequence); err != nil {return "", err@@ -641,12 +642,12 @@ func GetSequenceDefinition(schema string, sequence *storepb.SequenceMetadata) (sreturn buf.String(), nil}-func filterBackupSchemaIfNecessary(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) *storepb.DatabaseSchemaMetadata {+func filterBackupSchemaIfNecessary(ctx schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) *metadatapb.DatabaseSchemaMetadata {if !ctx.SkipBackupSchema {return metadata}- filtered := &storepb.DatabaseSchemaMetadata{+ filtered := &metadatapb.DatabaseSchemaMetadata{Extensions: metadata.Extensions,EventTriggers: metadata.EventTriggers,}@@ -659,7 +660,7 @@ func filterBackupSchemaIfNecessary(ctx schema.GetDefinitionContext, metadata *streturn filtered}-func writeTrigger(out io.Writer, schema string, table string, trigger *storepb.TriggerMetadata) error {+func writeTrigger(out io.Writer, schema string, table string, trigger *metadatapb.TriggerMetadata) error {if _, err := io.WriteString(out, trigger.Body); err != nil {return err}@@ -676,7 +677,7 @@ func writeTrigger(out io.Writer, schema string, table string, trigger *storepb.Treturn nil}-func writeTriggerComment(out io.Writer, schema string, table string, trigger *storepb.TriggerMetadata) error {+func writeTriggerComment(out io.Writer, schema string, table string, trigger *metadatapb.TriggerMetadata) error {if _, err := io.WriteString(out, `COMMENT ON TRIGGER "`); err != nil {return err}@@ -717,7 +718,7 @@ func writeTriggerComment(out io.Writer, schema string, table string, trigger *streturn err}-func writeEventTrigger(out io.Writer, eventTrigger *storepb.EventTriggerMetadata) error {+func writeEventTrigger(out io.Writer, eventTrigger *metadatapb.EventTriggerMetadata) error {// Use the stored definition if availableif eventTrigger.Definition != "" {if _, err := io.WriteString(out, eventTrigger.Definition); err != nil {@@ -803,7 +804,7 @@ func writeEventTrigger(out io.Writer, eventTrigger *storepb.EventTriggerMetadatareturn nil}-func writeEventTriggerComment(out io.Writer, eventTrigger *storepb.EventTriggerMetadata) error {+func writeEventTriggerComment(out io.Writer, eventTrigger *metadatapb.EventTriggerMetadata) error {if _, err := io.WriteString(out, `COMMENT ON EVENT TRIGGER "`); err != nil {return err}@@ -828,7 +829,7 @@ func writeEventTriggerComment(out io.Writer, eventTrigger *storepb.EventTriggerMreturn err}-func writeEnum(out io.Writer, schema string, enum *storepb.EnumTypeMetadata) error {+func writeEnum(out io.Writer, schema string, enum *metadatapb.EnumTypeMetadata) error {if _, err := io.WriteString(out, `CREATE TYPE "`); err != nil {return err}@@ -872,7 +873,7 @@ func escapeSingleQuote(s string) string {return strings.ReplaceAll(s, "'", "''")}-func writeCompositeType(out io.Writer, schema string, composite *storepb.CompositeTypeMetadata) error {+func writeCompositeType(out io.Writer, schema string, composite *metadatapb.CompositeTypeMetadata) error {if _, err := io.WriteString(out, `CREATE TYPE "`); err != nil {return err}@@ -925,7 +926,7 @@ func writeCompositeType(out io.Writer, schema string, composite *storepb.Composireturn nil}-func compositeTypeHasComments(composite *storepb.CompositeTypeMetadata) bool {+func compositeTypeHasComments(composite *metadatapb.CompositeTypeMetadata) bool {if composite.Comment != "" {return true}@@ -937,7 +938,7 @@ func compositeTypeHasComments(composite *storepb.CompositeTypeMetadata) bool {return false}-func writeCompositeTypeComments(out io.Writer, schema string, composite *storepb.CompositeTypeMetadata) error {+func writeCompositeTypeComments(out io.Writer, schema string, composite *metadatapb.CompositeTypeMetadata) error {if composite.Comment != "" {if _, err := fmt.Fprintf(out, "COMMENT ON TYPE \"%s\".\"%s\" IS '%s';\n\n", schema, composite.Name, escapeSingleQuote(composite.Comment)); err != nil {return err@@ -958,13 +959,13 @@ func writeCompositeTypeComments(out io.Writer, schema string, composite *storepb// cross-schema ordering.type qualifiedCompositeType struct {Schema string- Composite *storepb.CompositeTypeMetadata+ Composite *metadatapb.CompositeTypeMetadata}// collectCompositeTypes gathers the dumpable composite types of the given// schemas. Schemas with SkipDump never get a CREATE SCHEMA statement, so// their types must not be emitted either.-func collectCompositeTypes(schemas []*storepb.SchemaMetadata) []qualifiedCompositeType {+func collectCompositeTypes(schemas []*metadatapb.SchemaMetadata) []qualifiedCompositeType {var compositeTypes []qualifiedCompositeTypefor _, schema := range schemas {if schema.SkipDump {@@ -1190,7 +1191,7 @@ func signatureTypesOnly(signature string) string {return funcName + "(" + strings.Join(typesOnly, ", ") + ")"}-func writeEnumComment(out io.Writer, schema string, enum *storepb.EnumTypeMetadata) error {+func writeEnumComment(out io.Writer, schema string, enum *metadatapb.EnumTypeMetadata) error {if _, err := io.WriteString(out, `COMMENT ON TYPE "`); err != nil {return err}@@ -1223,7 +1224,7 @@ func writeEnumComment(out io.Writer, schema string, enum *storepb.EnumTypeMetadareturn err}-func writeMaterializedView(out io.Writer, schema string, view *storepb.MaterializedViewMetadata) error {+func writeMaterializedView(out io.Writer, schema string, view *metadatapb.MaterializedViewMetadata) error {if _, err := io.WriteString(out, `CREATE MATERIALIZED VIEW "`); err != nil {return err}@@ -1261,7 +1262,7 @@ func writeMaterializedView(out io.Writer, schema string, view *storepb.Materialireturn nil}-func writeMaterializedViewComment(out io.Writer, schema string, view *storepb.MaterializedViewMetadata) error {+func writeMaterializedViewComment(out io.Writer, schema string, view *metadatapb.MaterializedViewMetadata) error {if _, err := io.WriteString(out, `COMMENT ON MATERIALIZED VIEW "`); err != nil {return err}@@ -1294,7 +1295,7 @@ func writeMaterializedViewComment(out io.Writer, schema string, view *storepb.Mareturn err}-func writeView(out io.Writer, schema string, view *storepb.ViewMetadata) error {+func writeView(out io.Writer, schema string, view *metadatapb.ViewMetadata) error {if _, err := io.WriteString(out, `CREATE VIEW "`); err != nil {return err}@@ -1326,7 +1327,7 @@ func writeView(out io.Writer, schema string, view *storepb.ViewMetadata) error {return nil}-func writeViewComment(out io.Writer, schema string, view *storepb.ViewMetadata) error {+func writeViewComment(out io.Writer, schema string, view *metadatapb.ViewMetadata) error {if _, err := io.WriteString(out, `COMMENT ON VIEW "`); err != nil {return err}@@ -1359,7 +1360,7 @@ func writeViewComment(out io.Writer, schema string, view *storepb.ViewMetadata)return err}-func writeRules(out io.Writer, _ string, _ string, rules []*storepb.RuleMetadata) error {+func writeRules(out io.Writer, _ string, _ string, rules []*metadatapb.RuleMetadata) error {for _, rule := range rules {// Write the full rule definitionif _, err := io.WriteString(out, rule.Definition); err != nil {@@ -1384,7 +1385,7 @@ func getSchemaNameFromID(id string) string {return ""}-func writeColumnIdentityGeneration(out io.Writer, schema string, generationTypes storepb.ColumnMetadata_IdentityGeneration, sequence *storepb.SequenceMetadata) error {+func writeColumnIdentityGeneration(out io.Writer, schema string, generationTypes metadatapb.ColumnMetadata_IdentityGeneration, sequence *metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `ALTER TABLE "`); err != nil {return err}@@ -1406,7 +1407,7 @@ func writeColumnIdentityGeneration(out io.Writer, schema string, generationTypesif _, err := io.WriteString(out, `" ADD GENERATED `); err != nil {return err}- if generationTypes == storepb.ColumnMetadata_ALWAYS {+ if generationTypes == metadatapb.ColumnMetadata_ALWAYS {if _, err := io.WriteString(out, "ALWAYS "); err != nil {return err}@@ -1467,7 +1468,7 @@ func writeColumnIdentityGeneration(out io.Writer, schema string, generationTypesreturn err}-func writeCreateSequence(out io.Writer, schema string, sequence *storepb.SequenceMetadata) error {+func writeCreateSequence(out io.Writer, schema string, sequence *metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `CREATE SEQUENCE "`); err != nil {return err}@@ -1535,7 +1536,7 @@ func writeCreateSequence(out io.Writer, schema string, sequence *storepb.Sequencreturn nil}-func writeSequenceComment(out io.Writer, schema string, sequence *storepb.SequenceMetadata) error {+func writeSequenceComment(out io.Writer, schema string, sequence *metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `COMMENT ON SEQUENCE "`); err != nil {return err}@@ -1568,7 +1569,7 @@ func writeSequenceComment(out io.Writer, schema string, sequence *storepb.Sequenreturn err}-func writeAlterSequenceOwnedBy(out io.Writer, schema string, sequence *storepb.SequenceMetadata) error {+func writeAlterSequenceOwnedBy(out io.Writer, schema string, sequence *metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `ALTER SEQUENCE "`); err != nil {return err}@@ -1605,7 +1606,7 @@ func writeAlterSequenceOwnedBy(out io.Writer, schema string, sequence *storepb.S// funcIdentity returns the unique identity for a function, preferring// the full signature (name + parameter types) to support overloaded functions.-func funcIdentity(f *storepb.FunctionMetadata) string {+func funcIdentity(f *metadatapb.FunctionMetadata) string {if f.Signature != "" {return f.Signature}@@ -1621,7 +1622,7 @@ func getObjectID(schema string, object string) string {}// writePrimaryKeyConstraintSDL writes a single primary key constraint SDL-func writePrimaryKeyConstraintSDL(out io.Writer, index *storepb.IndexMetadata) error {+func writePrimaryKeyConstraintSDL(out io.Writer, index *metadatapb.IndexMetadata) error {if index == nil || !index.Primary {return errors.New("invalid primary key constraint")}@@ -1652,7 +1653,7 @@ func writePrimaryKeyConstraintSDL(out io.Writer, index *storepb.IndexMetadata) e}// writeUniqueKeyConstraintSDL writes a single unique key constraint SDL-func writeUniqueKeyConstraintSDL(out io.Writer, index *storepb.IndexMetadata) error {+func writeUniqueKeyConstraintSDL(out io.Writer, index *metadatapb.IndexMetadata) error {if index == nil || !index.Unique || index.Primary || !index.IsConstraint {return errors.New("invalid unique key constraint")}@@ -1682,7 +1683,7 @@ func writeUniqueKeyConstraintSDL(out io.Writer, index *storepb.IndexMetadata) erreturn nil}-func writeCreateTable(out io.Writer, schema string, tableName string, columns []*storepb.ColumnMetadata, checks []*storepb.CheckConstraintMetadata, excludes []*storepb.ExcludeConstraintMetadata) error {+func writeCreateTable(out io.Writer, schema string, tableName string, columns []*metadatapb.ColumnMetadata, checks []*metadatapb.CheckConstraintMetadata, excludes []*metadatapb.ExcludeConstraintMetadata) error {if _, err := io.WriteString(out, `CREATE TABLE "`); err != nil {return err}@@ -1780,15 +1781,15 @@ func writeCreateTable(out io.Writer, schema string, tableName string, columns []}// isIdentityColumn checks if a column is an identity column.-func isIdentityColumn(column *storepb.ColumnMetadata) bool {- return column.IdentityGeneration == storepb.ColumnMetadata_ALWAYS ||- column.IdentityGeneration == storepb.ColumnMetadata_BY_DEFAULT+func isIdentityColumn(column *metadatapb.ColumnMetadata) bool {+ return column.IdentityGeneration == metadatapb.ColumnMetadata_ALWAYS ||+ column.IdentityGeneration == metadatapb.ColumnMetadata_BY_DEFAULT}// buildIdentityColumnMap builds a map of identity columns for the entire database.// Key format: "schemaName.tableName.columnName" -> true// This is O(m*c) which is done once, vs O(s*m*c) when checking each sequence individually.-func buildIdentityColumnMap(metadata *storepb.DatabaseSchemaMetadata) map[string]bool {+func buildIdentityColumnMap(metadata *metadatapb.DatabaseSchemaMetadata) map[string]bool {identityMap := make(map[string]bool)for _, schema := range metadata.Schemas {for _, table := range schema.Tables {@@ -1805,7 +1806,7 @@ func buildIdentityColumnMap(metadata *storepb.DatabaseSchemaMetadata) map[string// buildIdentityColumnMapForSchema builds a map of identity columns for a single schema.// Key format: "tableName.columnName" -> true-func buildIdentityColumnMapForSchema(schema *storepb.SchemaMetadata) map[string]bool {+func buildIdentityColumnMapForSchema(schema *metadatapb.SchemaMetadata) map[string]bool {identityMap := make(map[string]bool)for _, table := range schema.Tables {for _, column := range table.Columns {@@ -1818,14 +1819,14 @@ func buildIdentityColumnMapForSchema(schema *storepb.SchemaMetadata) map[string]return identityMap}-func splitSequencesByIdentityOrNot(table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) ([]storepb.ColumnMetadata_IdentityGeneration, []*storepb.SequenceMetadata, []*storepb.SequenceMetadata) {- columnMap := make(map[string]*storepb.ColumnMetadata)+func splitSequencesByIdentityOrNot(table *metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata) ([]metadatapb.ColumnMetadata_IdentityGeneration, []*metadatapb.SequenceMetadata, []*metadatapb.SequenceMetadata) {+ columnMap := make(map[string]*metadatapb.ColumnMetadata)for _, column := range table.Columns {columnMap[column.Name] = column}- var generationType []storepb.ColumnMetadata_IdentityGeneration- var identitySequences []*storepb.SequenceMetadata- var nonIdentitySequences []*storepb.SequenceMetadata+ var generationType []metadatapb.ColumnMetadata_IdentityGeneration+ var identitySequences []*metadatapb.SequenceMetadata+ var nonIdentitySequences []*metadatapb.SequenceMetadatafor _, sequence := range sequences {if column, ok := columnMap[sequence.OwnerColumn]; ok {if isIdentityColumn(column) {@@ -1854,7 +1855,7 @@ func splitSequencesByIdentityOrNot(table *storepb.TableMetadata, sequences []*st// limited to constant-expression corner cases. Treat zero columns as missing// metadata only when such objects are present, so genuine zero-column tables// keep their objects.-func tableMissingColumnMetadata(table *storepb.TableMetadata) bool {+func tableMissingColumnMetadata(table *metadatapb.TableMetadata) bool {return len(table.Columns) == 0 &&(len(table.Indexes) > 0 || len(table.ForeignKeys) > 0 || len(table.Partitions) > 0)}@@ -1862,13 +1863,13 @@ func tableMissingColumnMetadata(table *storepb.TableMetadata) bool {// tableHasNoColumns reports an empty synced column list, whether genuinely// zero-column or privilege-filtered. A sequence cannot be owned by a column// of such a table, so ALTER SEQUENCE ... OWNED BY is skipped either way.-func tableHasNoColumns(table *storepb.TableMetadata) bool {+func tableHasNoColumns(table *metadatapb.TableMetadata) bool {return len(table.Columns) == 0}// collectTables returns the tables matching include, keyed by// getObjectID(schema, table).-func collectTables(schemas []*storepb.SchemaMetadata, include func(*storepb.TableMetadata) bool) map[string]bool {+func collectTables(schemas []*metadatapb.SchemaMetadata, include func(*metadatapb.TableMetadata) bool) map[string]bool {set := make(map[string]bool)for _, schema := range schemas {for _, table := range schema.Tables {@@ -1884,7 +1885,7 @@ func collectTables(schemas []*storepb.SchemaMetadata, include func(*storepb.Tabl// materialized view in the schema. Triggers on tables without column// metadata are skipped; their definitions (UPDATE OF, WHEN clauses) can// reference the missing columns.-func writeSchemaTriggers(out io.Writer, schema *storepb.SchemaMetadata) error {+func writeSchemaTriggers(out io.Writer, schema *metadatapb.SchemaMetadata) error {for _, table := range schema.Tables {if tableMissingColumnMetadata(table) {continue@@ -1927,7 +1928,7 @@ func writeSchemaTriggers(out io.Writer, schema *storepb.SchemaMetadata) error {// of every view in the schema (SELECT rules are part of the view// definition). Rules on tables without column metadata are skipped; their// definitions can reference the missing columns.-func writeSchemaRules(out io.Writer, schema *storepb.SchemaMetadata) error {+func writeSchemaRules(out io.Writer, schema *metadatapb.SchemaMetadata) error {for _, table := range schema.Tables {if len(table.Rules) > 0 && !tableMissingColumnMetadata(table) {if err := writeRules(out, schema.Name, table.Name, table.Rules); err != nil {@@ -1937,7 +1938,7 @@ func writeSchemaRules(out io.Writer, schema *storepb.SchemaMetadata) error {}for _, view := range schema.Views {- var nonSelectRules []*storepb.RuleMetadata+ var nonSelectRules []*metadatapb.RuleMetadatafor _, rule := range view.Rules {if rule.Event != "SELECT" {nonSelectRules = append(nonSelectRules, rule)@@ -1955,7 +1956,7 @@ func writeSchemaRules(out io.Writer, schema *storepb.SchemaMetadata) error {// writeSchemaForeignKeys writes the foreign keys of every table in the// schema, skipping foreign keys touching a table without column metadata on// either side; they would reference columns absent from the dump.-func writeSchemaForeignKeys(out io.Writer, schema *storepb.SchemaMetadata, tablesMissingColumns map[string]bool) error {+func writeSchemaForeignKeys(out io.Writer, schema *metadatapb.SchemaMetadata, tablesMissingColumns map[string]bool) error {for _, table := range schema.Tables {if table.SkipDump || tablesMissingColumns[getObjectID(schema.Name, table.Name)] {continue@@ -1972,7 +1973,7 @@ func writeSchemaForeignKeys(out io.Writer, schema *storepb.SchemaMetadata, tablereturn nil}-func writeTable(out io.Writer, schema string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) error {+func writeTable(out io.Writer, schema string, table *metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata) error {if tableMissingColumnMetadata(table) {// Emit a bare CREATE TABLE so the table still exists on replay, and// skip constraints, indexes, partitions, and sequence ownership —@@ -2107,7 +2108,7 @@ func writeTable(out io.Writer, schema string, table *storepb.TableMetadata, sequreturn nil}-func writeForeignKey(out io.Writer, schema string, table string, fk *storepb.ForeignKeyMetadata) error {+func writeForeignKey(out io.Writer, schema string, table string, fk *metadatapb.ForeignKeyMetadata) error {if _, err := io.WriteString(out, `ALTER TABLE "`); err != nil {return err}@@ -2204,7 +2205,7 @@ func writeForeignKey(out io.Writer, schema string, table string, fk *storepb.Forreturn err}-func writeAttachPartitionIndex(out io.Writer, schema string, partition *storepb.TablePartitionMetadata) error {+func writeAttachPartitionIndex(out io.Writer, schema string, partition *metadatapb.TablePartitionMetadata) error {for _, index := range partition.Indexes {if err := writeAttachIndex(out, schema, index); err != nil {return err@@ -2219,7 +2220,7 @@ func writeAttachPartitionIndex(out io.Writer, schema string, partition *storepb.return nil}-func writeAttachIndex(out io.Writer, schema string, index *storepb.IndexMetadata) error {+func writeAttachIndex(out io.Writer, schema string, index *metadatapb.IndexMetadata) error {if len(index.ParentIndexName) == 0 || len(index.ParentIndexSchema) == 0 {return nil}@@ -2252,7 +2253,7 @@ func writeAttachIndex(out io.Writer, schema string, index *storepb.IndexMetadatareturn err}-func writePartitionIndex(out io.Writer, schema string, partition *storepb.TablePartitionMetadata) error {+func writePartitionIndex(out io.Writer, schema string, partition *metadatapb.TablePartitionMetadata) error {for _, index := range partition.Indexes {if !index.IsConstraint && !index.Primary {if err := writeIndex(out, schema, partition.Name, index, len(partition.Subpartitions) > 0); err != nil {@@ -2269,11 +2270,11 @@ func writePartitionIndex(out io.Writer, schema string, partition *storepb.TablePreturn nil}-func writeIndex(out io.Writer, schema string, table string, index *storepb.IndexMetadata, useOnlyClause bool) error {+func writeIndex(out io.Writer, schema string, table string, index *metadatapb.IndexMetadata, useOnlyClause bool) error {return writeIndexInternal(out, schema, table, index, useOnlyClause, true)}-func writeIndexKeyList(out io.Writer, index *storepb.IndexMetadata) error {+func writeIndexKeyList(out io.Writer, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `(`); err != nil {return err}@@ -2319,7 +2320,7 @@ func writeIndexKeyList(out io.Writer, index *storepb.IndexMetadata) error {return err}-func writeIndexComment(out io.Writer, schema string, index *storepb.IndexMetadata) error {+func writeIndexComment(out io.Writer, schema string, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `COMMENT ON INDEX "`); err != nil {return err}@@ -2348,7 +2349,7 @@ func writeIndexComment(out io.Writer, schema string, index *storepb.IndexMetadatreturn err}-func writePartitionUniqueKey(out io.Writer, schema string, partition *storepb.TablePartitionMetadata) error {+func writePartitionUniqueKey(out io.Writer, schema string, partition *metadatapb.TablePartitionMetadata) error {for _, index := range partition.Indexes {if index.Unique && !index.Primary && index.IsConstraint {if err := writeUniqueKey(out, schema, partition.Name, index); err != nil {@@ -2365,7 +2366,7 @@ func writePartitionUniqueKey(out io.Writer, schema string, partition *storepb.Tareturn nil}-func writeUniqueKey(out io.Writer, schema string, table string, index *storepb.IndexMetadata) error {+func writeUniqueKey(out io.Writer, schema string, table string, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `ALTER TABLE ONLY "`); err != nil {return err}@@ -2410,7 +2411,7 @@ func writeUniqueKey(out io.Writer, schema string, table string, index *storepb.Ireturn nil}-func writePartitionPrimaryKey(out io.Writer, schema string, partition *storepb.TablePartitionMetadata) error {+func writePartitionPrimaryKey(out io.Writer, schema string, partition *metadatapb.TablePartitionMetadata) error {for _, index := range partition.Indexes {if index.Primary {if err := writePrimaryKey(out, schema, partition.Name, index); err != nil {@@ -2427,7 +2428,7 @@ func writePartitionPrimaryKey(out io.Writer, schema string, partition *storepb.Treturn nil}-func writePrimaryKey(out io.Writer, schema string, table string, index *storepb.IndexMetadata) error {+func writePrimaryKey(out io.Writer, schema string, table string, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `ALTER TABLE ONLY "`); err != nil {return err}@@ -2472,7 +2473,7 @@ func writePrimaryKey(out io.Writer, schema string, table string, index *storepb.return nil}-func writeConstraintComment(out io.Writer, schema string, table string, index *storepb.IndexMetadata) error {+func writeConstraintComment(out io.Writer, schema string, table string, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `COMMENT ON CONSTRAINT "`); err != nil {return err}@@ -2513,7 +2514,7 @@ func writeConstraintComment(out io.Writer, schema string, table string, index *sreturn err}-func writeColumnComment(out io.Writer, schema string, table string, column *storepb.ColumnMetadata) error {+func writeColumnComment(out io.Writer, schema string, table string, column *metadatapb.ColumnMetadata) error {if _, err := io.WriteString(out, `COMMENT ON COLUMN "`); err != nil {return err}@@ -2542,7 +2543,7 @@ func writeColumnComment(out io.Writer, schema string, table string, column *storreturn err}-func writeTableComment(out io.Writer, schema string, table *storepb.TableMetadata) error {+func writeTableComment(out io.Writer, schema string, table *metadatapb.TableMetadata) error {if _, err := io.WriteString(out, `COMMENT ON TABLE "`); err != nil {return err}@@ -2565,7 +2566,7 @@ func writeTableComment(out io.Writer, schema string, table *storepb.TableMetadatreturn err}-func writePartitionClause(out io.Writer, partition *storepb.TablePartitionMetadata) error {+func writePartitionClause(out io.Writer, partition *metadatapb.TablePartitionMetadata) error {if _, err := io.WriteString(out, " PARTITION BY "); err != nil {return err}@@ -2573,7 +2574,7 @@ func writePartitionClause(out io.Writer, partition *storepb.TablePartitionMetadareturn err}-func writeAttachPartition(out io.Writer, schema string, tableName string, partition *storepb.TablePartitionMetadata) error {+func writeAttachPartition(out io.Writer, schema string, tableName string, partition *metadatapb.TablePartitionMetadata) error {if _, err := io.WriteString(out, `ALTER TABLE ONLY "`); err != nil {return err}@@ -2608,7 +2609,7 @@ func writeAttachPartition(out io.Writer, schema string, tableName string, partitreturn err}-func writePartitionTable(out io.Writer, schema string, columns []*storepb.ColumnMetadata, partition *storepb.TablePartitionMetadata) error {+func writePartitionTable(out io.Writer, schema string, columns []*metadatapb.ColumnMetadata, partition *metadatapb.TablePartitionMetadata) error {if err := writeCreateTable(out, schema, partition.Name, columns, partition.CheckConstraints, partition.ExcludeConstraints); err != nil {return err}@@ -2639,7 +2640,7 @@ func writePartitionTable(out io.Writer, schema string, columns []*storepb.Columnreturn nil}-func writeFunction(out io.Writer, schema string, function *storepb.FunctionMetadata) error {+func writeFunction(out io.Writer, schema string, function *metadatapb.FunctionMetadata) error {if _, err := io.WriteString(out, function.Definition); err != nil {return err}@@ -2679,7 +2680,7 @@ func isDefinitionProcedure(definition string) bool {return false}-func writeFunctionComment(out io.Writer, schema string, function *storepb.FunctionMetadata) error {+func writeFunctionComment(out io.Writer, schema string, function *metadatapb.FunctionMetadata) error {// Determine if this is a PROCEDURE or FUNCTION by checking the definitionobjectType := "FUNCTION"if isDefinitionProcedure(function.Definition) {@@ -2714,7 +2715,7 @@ func writeFunctionComment(out io.Writer, schema string, function *storepb.Functireturn err}-func writeExtension(out io.Writer, extension *storepb.ExtensionMetadata) error {+func writeExtension(out io.Writer, extension *metadatapb.ExtensionMetadata) error {if _, err := io.WriteString(out, `CREATE EXTENSION IF NOT EXISTS "`); err != nil {return err}@@ -2779,7 +2780,7 @@ func writeExtension(out io.Writer, extension *storepb.ExtensionMetadata) error {return nil}-func writeExtensionComment(out io.Writer, extension *storepb.ExtensionMetadata) error {+func writeExtensionComment(out io.Writer, extension *metadatapb.ExtensionMetadata) error {if _, err := io.WriteString(out, `COMMENT ON EXTENSION "`); err != nil {return err}@@ -2804,7 +2805,7 @@ func writeExtensionComment(out io.Writer, extension *storepb.ExtensionMetadata)return err}-func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func getSDLFormat(metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {var buf strings.BuildertablesMissingColumns := collectTables(metadata.Schemas, tableMissingColumnMetadata)@@ -2913,7 +2914,7 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {// Write all sequences before tables to ensure they exist before any table references them.// Skip sequences that belong to serial or identity columns as they will be implicitly created.- sequenceOwnershipMap := make(map[string][]*storepb.SequenceMetadata)+ sequenceOwnershipMap := make(map[string][]*metadatapb.SequenceMetadata)for _, schema := range metadata.Schemas {if schema.SkipDump {@@ -2952,7 +2953,7 @@ func getSDLFormat(metadata *storepb.DatabaseSchemaMetadata) (string, error) {}// Build a map of sequences by table for easy lookup during table creation- tableSequencesMap := make(map[string][]*storepb.SequenceMetadata)+ tableSequencesMap := make(map[string][]*metadatapb.SequenceMetadata)for _, schema := range metadata.Schemas {if schema.SkipDump {continue@@ -3281,7 +3282,7 @@ func extractIdentifierFromQualifiedName(qualifiedName string) string {return qualifiedName}-func isSerialColumn(column *storepb.ColumnMetadata, tableName string, sequences []*storepb.SequenceMetadata) (isSerial bool, serialType string) {+func isSerialColumn(column *metadatapb.ColumnMetadata, tableName string, sequences []*metadatapb.SequenceMetadata) (isSerial bool, serialType string) {// Serial columns must be NOT NULLif column.Nullable {return false, ""@@ -3327,7 +3328,7 @@ func isSerialColumn(column *storepb.ColumnMetadata, tableName string, sequences// This function is extracted from writeCreateTableSDL to enable code reuse// sequences parameter is optional and used to find identity sequences for the column// tableName is used to verify sequence ownership for serial column detection-func writeColumnSDL(out io.Writer, column *storepb.ColumnMetadata, tableName string, sequences []*storepb.SequenceMetadata) error {+func writeColumnSDL(out io.Writer, column *metadatapb.ColumnMetadata, tableName string, sequences []*metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `"`); err != nil {return err}@@ -3343,7 +3344,7 @@ func writeColumnSDL(out io.Writer, column *storepb.ColumnMetadata, tableName str// Check if this is an identity columnif isIdentityColumn(column) {// Find the sequence for this identity column- var identitySequence *storepb.SequenceMetadata+ var identitySequence *metadatapb.SequenceMetadatafor _, seq := range sequences {if seq.OwnerColumn == column.Name {identitySequence = seq@@ -3360,7 +3361,7 @@ func writeColumnSDL(out io.Writer, column *storepb.ColumnMetadata, tableName strif _, err := io.WriteString(out, " GENERATED "); err != nil {return err}- if column.IdentityGeneration == storepb.ColumnMetadata_ALWAYS {+ if column.IdentityGeneration == metadatapb.ColumnMetadata_ALWAYS {if _, err := io.WriteString(out, "ALWAYS"); err != nil {return err}@@ -3462,7 +3463,7 @@ func writeColumnSDL(out io.Writer, column *storepb.ColumnMetadata, tableName strreturn nil}-func writeCreateTableSDL(out io.Writer, schemaName string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata, tablesMissingColumns map[string]bool) error {+func writeCreateTableSDL(out io.Writer, schemaName string, table *metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata, tablesMissingColumns map[string]bool) error {if _, err := io.WriteString(out, `CREATE TABLE "`); err != nil {return err}@@ -3515,7 +3516,7 @@ func writeCreateTableSDL(out io.Writer, schemaName string, table *storepb.TableMreturn err}-func writeTableConstraintsSDL(out io.Writer, table *storepb.TableMetadata, writeSep func() error, tablesMissingColumns map[string]bool) error {+func writeTableConstraintsSDL(out io.Writer, table *metadatapb.TableMetadata, writeSep func() error, tablesMissingColumns map[string]bool) error {if tableMissingColumnMetadata(table) {// Constraints would reference columns absent from the dump.return nil@@ -3583,7 +3584,7 @@ func writeTableConstraintsSDL(out io.Writer, table *storepb.TableMetadata, writereturn nil}-func writeIndexesSDL(out io.Writer, schemaName string, table *storepb.TableMetadata) error {+func writeIndexesSDL(out io.Writer, schemaName string, table *metadatapb.TableMetadata) error {if tableMissingColumnMetadata(table) {// Indexes would reference columns absent from the dump.return nil@@ -3606,12 +3607,12 @@ func writeIndexesSDL(out io.Writer, schemaName string, table *storepb.TableMetadreturn nil}-func writeIndexSDL(out io.Writer, schemaName string, tableName string, index *storepb.IndexMetadata, useOnlyClause bool) error {+func writeIndexSDL(out io.Writer, schemaName string, tableName string, index *metadatapb.IndexMetadata, useOnlyClause bool) error {return writeIndexInternal(out, schemaName, tableName, index, useOnlyClause, false)}// writeIndexInternal is the core index writing function with options for different modes-func writeIndexInternal(out io.Writer, schema string, table string, index *storepb.IndexMetadata, useOnlyClause bool, includeTerminatorAndComment bool) error {+func writeIndexInternal(out io.Writer, schema string, table string, index *metadatapb.IndexMetadata, useOnlyClause bool, includeTerminatorAndComment bool) error {if index.Unique {if _, err := io.WriteString(out, `CREATE UNIQUE INDEX "`); err != nil {return err@@ -3695,7 +3696,7 @@ func writeIndexInternal(out io.Writer, schema string, table string, index *storereturn nil}-func writeViewSDL(out io.Writer, schemaName string, view *storepb.ViewMetadata) error {+func writeViewSDL(out io.Writer, schemaName string, view *metadatapb.ViewMetadata) error {if _, err := io.WriteString(out, `CREATE VIEW "`); err != nil {return err}@@ -3725,7 +3726,7 @@ func writeViewSDL(out io.Writer, schemaName string, view *storepb.ViewMetadata)return err}-func writeMaterializedViewSDL(out io.Writer, schemaName string, view *storepb.MaterializedViewMetadata) error {+func writeMaterializedViewSDL(out io.Writer, schemaName string, view *metadatapb.MaterializedViewMetadata) error {if _, err := io.WriteString(out, `CREATE MATERIALIZED VIEW "`); err != nil {return err}@@ -3755,7 +3756,7 @@ func writeMaterializedViewSDL(out io.Writer, schemaName string, view *storepb.Mareturn err}-func writeFunctionSDL(out io.Writer, _ string, function *storepb.FunctionMetadata) error {+func writeFunctionSDL(out io.Writer, _ string, function *metadatapb.FunctionMetadata) error {// The function definition should already include the complete CREATE FUNCTION statementdefinition := strings.TrimSpace(function.Definition)// Remove trailing semicolon if present@@ -3765,7 +3766,7 @@ func writeFunctionSDL(out io.Writer, _ string, function *storepb.FunctionMetadatreturn err}-func writeSequenceSDL(out io.Writer, schemaName string, sequence *storepb.SequenceMetadata) error {+func writeSequenceSDL(out io.Writer, schemaName string, sequence *metadatapb.SequenceMetadata) error {// Write CREATE SEQUENCE statement with schema and nameif _, err := fmt.Fprintf(out, "CREATE SEQUENCE \"%s\".\"%s\"", schemaName, sequence.Name); err != nil {return err@@ -3827,7 +3828,7 @@ func writeSequenceSDL(out io.Writer, schemaName string, sequence *storepb.Sequenreturn nil}-func writeSchema(out io.Writer, schema *storepb.SchemaMetadata) error {+func writeSchema(out io.Writer, schema *metadatapb.SchemaMetadata) error {if schema.Name == "public" {return nil}@@ -3849,7 +3850,7 @@ func writeSchema(out io.Writer, schema *storepb.SchemaMetadata) error {}// writeCheckConstraintSDL writes a single check constraint SDL-func writeCheckConstraintSDL(out io.Writer, check *storepb.CheckConstraintMetadata) error {+func writeCheckConstraintSDL(out io.Writer, check *metadatapb.CheckConstraintMetadata) error {if _, err := io.WriteString(out, `CONSTRAINT "`); err != nil {return err}@@ -3865,7 +3866,7 @@ func writeCheckConstraintSDL(out io.Writer, check *storepb.CheckConstraintMetadareturn nil}-func writeExcludeConstraintSDL(out io.Writer, exclude *storepb.ExcludeConstraintMetadata) error {+func writeExcludeConstraintSDL(out io.Writer, exclude *metadatapb.ExcludeConstraintMetadata) error {if _, err := io.WriteString(out, `CONSTRAINT "`); err != nil {return err}@@ -3883,7 +3884,7 @@ func writeExcludeConstraintSDL(out io.Writer, exclude *storepb.ExcludeConstraint}// writeForeignKeyConstraintSDL writes a single foreign key constraint SDL-func writeForeignKeyConstraintSDL(out io.Writer, fk *storepb.ForeignKeyMetadata) error {+func writeForeignKeyConstraintSDL(out io.Writer, fk *metadatapb.ForeignKeyMetadata) error {if _, err := io.WriteString(out, `CONSTRAINT "`); err != nil {return err}@@ -3978,7 +3979,7 @@ func writeForeignKeyConstraintSDL(out io.Writer, fk *storepb.ForeignKeyMetadata)}// GetMultiFileDatabaseDefinition generates multi-file SDL schema for PostgreSQL.-func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error) {+func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error) {metadata = filterBackupSchemaIfNecessary(ctx, metadata)// Clone before mutating: the caller's *DatabaseSchemaMetadata is often a@@ -4061,7 +4062,7 @@ func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *s}// Collect independent sequences (no owner) for this schema- var independentSequences []*storepb.SequenceMetadata+ var independentSequences []*metadatapb.SequenceMetadatafor _, sequence := range schemaMetadata.Sequences {if sequence.SkipDump {continue@@ -4422,17 +4423,17 @@ func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *sreturn &schema.MultiFileSchemaResult{Files: files}, nil}-func getMultiFileSchemaSDL(schemaName string, schemaMetadata *storepb.SchemaMetadata) (string, error) {+func getMultiFileSchemaSDL(schemaName string, schemaMetadata *metadatapb.SchemaMetadata) (string, error) {var buf strings.Builderif schemaName != "public" {- if err := writeSchema(&buf, &storepb.SchemaMetadata{Name: schemaName}); err != nil {+ if err := writeSchema(&buf, &metadatapb.SchemaMetadata{Name: schemaName}); err != nil {return "", err}}if schemaMetadata.GetComment() != "" {- if err := writeSchemaCommentSDL(&buf, &storepb.SchemaMetadata{+ if err := writeSchemaCommentSDL(&buf, &metadatapb.SchemaMetadata{Name: schemaName,Comment: schemaMetadata.GetComment(),}); err != nil {@@ -4444,7 +4445,7 @@ func getMultiFileSchemaSDL(schemaName string, schemaMetadata *storepb.SchemaMeta}// buildSkipSequencesMap builds a map of sequences that should be skipped (serial and identity sequences).-func buildSkipSequencesMap(metadata *storepb.DatabaseSchemaMetadata) map[string]bool {+func buildSkipSequencesMap(metadata *metadatapb.DatabaseSchemaMetadata) map[string]bool {skipSequences := make(map[string]bool)for _, schema := range metadata.Schemas {if schema.SkipDump {@@ -4490,8 +4491,8 @@ func buildSkipSequencesMap(metadata *storepb.DatabaseSchemaMetadata) map[string]}// buildTableSequencesMap builds a map of sequences by table for easy lookup during table creation.-func buildTableSequencesMap(metadata *storepb.DatabaseSchemaMetadata) map[string][]*storepb.SequenceMetadata {- tableSequencesMap := make(map[string][]*storepb.SequenceMetadata)+func buildTableSequencesMap(metadata *metadatapb.DatabaseSchemaMetadata) map[string][]*metadatapb.SequenceMetadata {+ tableSequencesMap := make(map[string][]*metadatapb.SequenceMetadata)for _, schema := range metadata.Schemas {if schema.SkipDump {continue@@ -4509,7 +4510,7 @@ func buildTableSequencesMap(metadata *storepb.DatabaseSchemaMetadata) map[stringreturn tableSequencesMap}-func writeMaterializedViewCommentSDL(out io.Writer, schemaName string, view *storepb.MaterializedViewMetadata) error {+func writeMaterializedViewCommentSDL(out io.Writer, schemaName string, view *metadatapb.MaterializedViewMetadata) error {if _, err := io.WriteString(out, `COMMENT ON MATERIALIZED VIEW "`); err != nil {return err}@@ -4537,7 +4538,7 @@ func writeMaterializedViewCommentSDL(out io.Writer, schemaName string, view *sto// SDL Comment Functions-func writeSchemaCommentSDL(out io.Writer, schema *storepb.SchemaMetadata) error {+func writeSchemaCommentSDL(out io.Writer, schema *metadatapb.SchemaMetadata) error {if _, err := io.WriteString(out, `COMMENT ON SCHEMA "`); err != nil {return err}@@ -4557,7 +4558,7 @@ func writeSchemaCommentSDL(out io.Writer, schema *storepb.SchemaMetadata) errorreturn err}-func writeTableCommentSDL(out io.Writer, schemaName string, table *storepb.TableMetadata) error {+func writeTableCommentSDL(out io.Writer, schemaName string, table *metadatapb.TableMetadata) error {if _, err := io.WriteString(out, `COMMENT ON TABLE "`); err != nil {return err}@@ -4583,7 +4584,7 @@ func writeTableCommentSDL(out io.Writer, schemaName string, table *storepb.Tablereturn err}-func writeColumnCommentSDL(out io.Writer, schemaName, tableName string, column *storepb.ColumnMetadata) error {+func writeColumnCommentSDL(out io.Writer, schemaName, tableName string, column *metadatapb.ColumnMetadata) error {if _, err := io.WriteString(out, `COMMENT ON COLUMN "`); err != nil {return err}@@ -4615,7 +4616,7 @@ func writeColumnCommentSDL(out io.Writer, schemaName, tableName string, column *return err}-func writeViewCommentSDL(out io.Writer, schemaName string, view *storepb.ViewMetadata) error {+func writeViewCommentSDL(out io.Writer, schemaName string, view *metadatapb.ViewMetadata) error {if _, err := io.WriteString(out, `COMMENT ON VIEW "`); err != nil {return err}@@ -4641,7 +4642,7 @@ func writeViewCommentSDL(out io.Writer, schemaName string, view *storepb.ViewMetreturn err}-func writeFunctionCommentSDL(out io.Writer, schemaName string, function *storepb.FunctionMetadata) error {+func writeFunctionCommentSDL(out io.Writer, schemaName string, function *metadatapb.FunctionMetadata) error {// Determine if this is a PROCEDURE or FUNCTION by checking the definitionobjectType := "FUNCTION"if isDefinitionProcedure(function.Definition) {@@ -4673,7 +4674,7 @@ func writeFunctionCommentSDL(out io.Writer, schemaName string, function *storepbreturn err}-func writeSequenceCommentSDL(out io.Writer, schemaName string, sequence *storepb.SequenceMetadata) error {+func writeSequenceCommentSDL(out io.Writer, schemaName string, sequence *metadatapb.SequenceMetadata) error {if _, err := io.WriteString(out, `COMMENT ON SEQUENCE "`); err != nil {return err}@@ -4699,7 +4700,7 @@ func writeSequenceCommentSDL(out io.Writer, schemaName string, sequence *storepbreturn err}-func writeIndexCommentSDL(out io.Writer, schemaName string, index *storepb.IndexMetadata) error {+func writeIndexCommentSDL(out io.Writer, schemaName string, index *metadatapb.IndexMetadata) error {if _, err := io.WriteString(out, `COMMENT ON INDEX "`); err != nil {return err}@@ -4725,7 +4726,7 @@ func writeIndexCommentSDL(out io.Writer, schemaName string, index *storepb.Indexreturn err}-func writeTriggersSDL(out io.Writer, schemaName string, table *storepb.TableMetadata) error {+func writeTriggersSDL(out io.Writer, schemaName string, table *metadatapb.TableMetadata) error {if tableMissingColumnMetadata(table) {// Trigger definitions (UPDATE OF, WHEN clauses) can reference// columns absent from the dump.@@ -4747,14 +4748,14 @@ func writeTriggersSDL(out io.Writer, schemaName string, table *storepb.TableMetareturn nil}-func writeTriggerSDL(out io.Writer, _ /* schemaName */, _ /* tableName */ string, trigger *storepb.TriggerMetadata) error {+func writeTriggerSDL(out io.Writer, _ /* schemaName */, _ /* tableName */ string, trigger *metadatapb.TriggerMetadata) error {// For PostgreSQL, trigger.Body contains the complete CREATE TRIGGER statement// built by buildTriggerDefinition in get_database_metadata.go_, err := io.WriteString(out, trigger.Body)return err}-func writeTriggerCommentSDL(out io.Writer, schemaName, tableName string, trigger *storepb.TriggerMetadata) error {+func writeTriggerCommentSDL(out io.Writer, schemaName, tableName string, trigger *metadatapb.TriggerMetadata) error {if len(trigger.Comment) == 0 {return nil}diff --git a/backend/plugin/schema/pg/get_database_definition_test.go b/backend/plugin/schema/pg/get_database_definition_test.goindex 1a7d3abb3c..81a774644c 100644--- a/backend/plugin/schema/pg/get_database_definition_test.go+++ b/backend/plugin/schema/pg/get_database_definition_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata"omnipg "github.com/bytebase/omni/pg""github.com/bytebase/omni/pg/catalog""github.com/stretchr/testify/assert"@@ -23,19 +24,19 @@ import (func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {tests := []struct {name string- metadata *storepb.DatabaseSchemaMetadata+ metadata *metadatapb.DatabaseSchemaMetadataexpected string}{{name: "Simple table with basic columns",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -67,14 +68,14 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {},{name: "Table with default values",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -114,14 +115,14 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {},{name: "Table with constraints",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -138,7 +139,7 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {Nullable: true,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},@@ -151,7 +152,7 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {IsConstraint: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "users_age_check",Expression: "(age >= 0)",@@ -175,14 +176,14 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {},{name: "Table with foreign key",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -194,14 +195,14 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "orders_pkey",Expressions: []string{"id"},Primary: true,},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "orders_user_id_fkey",Columns: []string{"user_id"},@@ -228,14 +229,14 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {},{name: "Multiple tables",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "categories",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -250,7 +251,7 @@ func TestGetDatabaseDefinitionSDLFormat(t *testing.T) {},{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -281,14 +282,14 @@ CREATE TABLE "public"."products" (},{name: "Table with indexes",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -310,7 +311,7 @@ CREATE TABLE "public"."products" (Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "products_pkey",Expressions: []string{"id"},@@ -355,14 +356,14 @@ CREATE UNIQUE INDEX "idx_products_name_unique" ON "public"."products" (name);},{name: "Table with views",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -385,7 +386,7 @@ CREATE UNIQUE INDEX "idx_products_name_unique" ON "public"."products" (name);Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},@@ -395,7 +396,7 @@ CREATE UNIQUE INDEX "idx_products_name_unique" ON "public"."products" (name);},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -412,7 +413,7 @@ CREATE UNIQUE INDEX "idx_products_name_unique" ON "public"."products" (name);Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "orders_pkey",Expressions: []string{"id"},@@ -421,7 +422,7 @@ CREATE UNIQUE INDEX "idx_products_name_unique" ON "public"."products" (name);},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_users",Definition: `SELECT id, name, email@@ -475,14 +476,14 @@ GROUP BY u.id, u.name;},{name: "Database with functions and procedures",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -500,7 +501,7 @@ GROUP BY u.id, u.name;Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},@@ -509,7 +510,7 @@ GROUP BY u.id, u.name;},},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "get_user_count",Definition: `CREATE FUNCTION "public"."get_user_count"() RETURNS integer@@ -587,11 +588,11 @@ $$;},{name: "Database with sequences",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "independent_seq",DataType: "bigint",@@ -624,10 +625,10 @@ $$;OwnerTable: "", // Independent sequence},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "INTEGER",@@ -658,18 +659,18 @@ CREATE TABLE "public"."users" (},{name: "Empty database",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{},+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{},},expected: "",},{name: "Serial columns should use serial types",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "users_id_seq",DataType: "bigint",@@ -704,10 +705,10 @@ CREATE TABLE "public"."users" (OwnerColumn: "id",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "bigint",@@ -723,7 +724,7 @@ CREATE TABLE "public"."users" (},{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -739,7 +740,7 @@ CREATE TABLE "public"."users" (},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "smallint",@@ -776,11 +777,11 @@ CREATE TABLE "public"."orders" (},{name: "Identity columns should use GENERATED AS IDENTITY syntax",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "users_id_seq",DataType: "bigint",@@ -804,15 +805,15 @@ CREATE TABLE "public"."orders" (OwnerColumn: "id",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "bigint",Nullable: false,- IdentityGeneration: storepb.ColumnMetadata_ALWAYS,+ IdentityGeneration: metadatapb.ColumnMetadata_ALWAYS,},{Name: "name",@@ -823,12 +824,12 @@ CREATE TABLE "public"."orders" (},{Name: "products",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",Nullable: false,- IdentityGeneration: storepb.ColumnMetadata_BY_DEFAULT,+ IdentityGeneration: metadatapb.ColumnMetadata_BY_DEFAULT,},{Name: "name",@@ -855,14 +856,14 @@ CREATE TABLE "public"."products" (},{name: "Table with indexes using custom opclass",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "documents",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -879,7 +880,7 @@ CREATE TABLE "public"."products" (Nullable: false,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "documents_pkey",Expressions: []string{"id"},@@ -929,11 +930,11 @@ CREATE INDEX "idx_documents_default_opclass" ON "public"."documents" (title);},{name: "Sequence with ownership (non-serial, non-identity)",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "custom_seq",DataType: "bigint",@@ -947,10 +948,10 @@ CREATE INDEX "idx_documents_default_opclass" ON "public"."documents" (title);OwnerColumn: "order_number",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "INTEGER",@@ -1001,12 +1002,12 @@ ALTER SEQUENCE "public"."custom_seq" OWNED BY "public"."orders"."order_number";}func TestGetSchemaSDLDefinition(t *testing.T) {- schemaMetadata := &storepb.SchemaMetadata{+ schemaMetadata := &metadatapb.SchemaMetadata{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -1037,14 +1038,14 @@ func TestGetSchemaSDLDefinition(t *testing.T) {func TestGetDatabaseDefinitionNormalVsSDLFormat(t *testing.T) {// Create a more complex metadata to show the difference- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -1061,7 +1062,7 @@ func TestGetDatabaseDefinitionNormalVsSDLFormat(t *testing.T) {Nullable: true,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},@@ -1080,13 +1081,13 @@ func TestGetDatabaseDefinitionNormalVsSDLFormat(t *testing.T) {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_users_view",Definition: "SELECT id, name, email FROM users WHERE active = true",},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "count_active_users",Definition: `CREATE FUNCTION "public"."count_active_users"() RETURNS integer@@ -1141,19 +1142,19 @@ $$`,func TestCheckConstraintNotValidFormat(t *testing.T) {tests := []struct {name string- metadata *storepb.DatabaseSchemaMetadata+ metadata *metadatapb.DatabaseSchemaMetadataexpected string}{{name: "Check constraint with NOT VALID",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "namespace_settings",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "namespace_id",Type: "bigint",@@ -1165,14 +1166,14 @@ func TestCheckConstraintNotValidFormat(t *testing.T) {Nullable: true,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "namespace_settings_pkey",Expressions: []string{"namespace_id"},Primary: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "default_branch_protection_defaults_size_constraint",Expression: "(octet_length(default_branch_protection_defaults::text) <= 1024) NOT VALID",@@ -1194,14 +1195,14 @@ func TestCheckConstraintNotValidFormat(t *testing.T) {},{name: "Multiple check constraints with and without NOT VALID",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "test",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "table1",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "serial",@@ -1218,14 +1219,14 @@ func TestCheckConstraintNotValidFormat(t *testing.T) {Nullable: true,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "table1_pkey",Expressions: []string{"id"},Primary: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "table1_data_size_check",Expression: "(octet_length(data::text) <= 1024) NOT VALID",@@ -1255,14 +1256,14 @@ CREATE TABLE "test"."table1" (},{name: "Regular check constraint without NOT VALID",- metadata: &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata: &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "serial",@@ -1274,14 +1275,14 @@ CREATE TABLE "test"."table1" (Nullable: true,},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},Primary: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "users_age_check",Expression: "(age >= 0)",@@ -1331,14 +1332,14 @@ CREATE TABLE "test"."table1" (// TestCheckConstraintNotValidFormatNormalMode tests that CHECK constraints with NOT VALID// are formatted correctly in normal (non-SDL) modefunc TestCheckConstraintNotValidFormatNormalMode(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "namespace_settings",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "namespace_id",Type: "bigint",@@ -1350,7 +1351,7 @@ func TestCheckConstraintNotValidFormatNormalMode(t *testing.T) {Nullable: true,},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "default_branch_protection_defaults_size_constraint",Expression: "(octet_length(default_branch_protection_defaults::text) <= 1024) NOT VALID",@@ -1383,16 +1384,16 @@ func TestCheckConstraintNotValidFormatNormalMode(t *testing.T) {}func TestGetDatabaseDefinitionSDLFormat_WithComments(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "test_schema",Comment: "Test schema for comments",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",Comment: "Users table with comments",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "SERIAL",@@ -1412,7 +1413,7 @@ func TestGetDatabaseDefinitionSDLFormat_WithComments(t *testing.T) {Comment: "User email address",},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx_users_email",Expressions: []string{"email"},@@ -1423,14 +1424,14 @@ func TestGetDatabaseDefinitionSDLFormat_WithComments(t *testing.T) {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_users",Definition: "SELECT id, name, email FROM test_schema.users WHERE active = true",Comment: "View of active users",},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "get_user_count",Signature: "get_user_count()",@@ -1438,7 +1439,7 @@ func TestGetDatabaseDefinitionSDLFormat_WithComments(t *testing.T) {Comment: "Function to get user count",},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "custom_seq",DataType: "bigint",@@ -1492,15 +1493,15 @@ func TestGetDatabaseDefinitionSDLFormat_WithComments(t *testing.T) {}func TestGetDatabaseDefinitionSDLFormat_WithCommentsEscaping(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "test_table",Comment: "Table with 'single quotes' and \"double quotes\"",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "INTEGER",@@ -1531,16 +1532,16 @@ func TestGetDatabaseDefinitionSDLFormat_WithCommentsEscaping(t *testing.T) {}func TestGetMultiFileDatabaseDefinition_WithComments(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "app_schema",Comment: "Application schema",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "products",Comment: "Product catalog",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "INTEGER",@@ -1554,7 +1555,7 @@ func TestGetMultiFileDatabaseDefinition_WithComments(t *testing.T) {Comment: "Product name",},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx_products_name",Expressions: []string{"name"},@@ -1565,21 +1566,21 @@ func TestGetMultiFileDatabaseDefinition_WithComments(t *testing.T) {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_products",Definition: "SELECT id, name FROM app_schema.products WHERE active = true",Comment: "View of active products",},},- MaterializedViews: []*storepb.MaterializedViewMetadata{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "product_summary_mv",Definition: "SELECT id, name FROM app_schema.products",Comment: "Materialized view of product summary",},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "count_products",Signature: "count_products()",@@ -1587,7 +1588,7 @@ func TestGetMultiFileDatabaseDefinition_WithComments(t *testing.T) {Comment: "Returns product count",},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1665,14 +1666,14 @@ func TestGetMultiFileDatabaseDefinition_WithComments(t *testing.T) {}func TestGetMultiFileDatabaseDefinition_SchemaFileMakesCombinedSDLLoadable(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "metric_helpers",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "metrics",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "INTEGER",@@ -1707,11 +1708,11 @@ func TestGetMultiFileDatabaseDefinition_SchemaFileMakesCombinedSDLLoadable(t *tefunc TestGetDatabaseDefinitionSDLFormat_SerialColumnWithSequence(t *testing.T) {// This test reproduces the issue where a SERIAL column causes duplicate CREATE SEQUENCE statements// SERIAL columns automatically create sequences, so we should NOT output separate CREATE SEQUENCE for them- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "users_id_seq",DataType: "integer",@@ -1736,10 +1737,10 @@ func TestGetDatabaseDefinitionSDLFormat_SerialColumnWithSequence(t *testing.T) {Comment: "Independent sequence - should appear in SDL",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -1782,11 +1783,11 @@ func TestGetDatabaseDefinitionSDLFormat_SerialColumnWithSequence(t *testing.T) {func TestGetMultiFileDatabaseDefinition_SerialColumnWithSequence(t *testing.T) {// This test verifies that multi-file format correctly handles serial columns and their sequences- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "users_id_seq",DataType: "integer",@@ -1822,10 +1823,10 @@ func TestGetMultiFileDatabaseDefinition_SerialColumnWithSequence(t *testing.T) {Comment: "Custom sequence for orders - should appear as separate file",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -1841,7 +1842,7 @@ func TestGetMultiFileDatabaseDefinition_SerialColumnWithSequence(t *testing.T) {},{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -1913,11 +1914,11 @@ func TestGetDatabaseDefinitionSDLFormat_MultipleSequencesClaimingOwnership(t *te// This test verifies that when multiple sequences claim ownership of the same column,// only the sequence referenced in the DEFAULT clause is skipped (treated as serial sequence).// The other sequences should still be output as CREATE SEQUENCE statements.- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "test_sequence2",DataType: "integer",@@ -1941,10 +1942,10 @@ func TestGetDatabaseDefinitionSDLFormat_MultipleSequencesClaimingOwnership(t *teOwnerColumn: "id",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "test_table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -2007,11 +2008,11 @@ ALTER SEQUENCE "public"."test_sequence2" OWNED BY "public"."test_table"."id";func TestGetDatabaseDefinitionSDLFormat_ProcedureWithComment(t *testing.T) {// This test verifies that PROCEDURE comments are correctly generated with// COMMENT ON PROCEDURE (not COMMENT ON FUNCTION)- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "get_user_count",Signature: "get_user_count()",@@ -2068,11 +2069,11 @@ $$`,func TestGetMultiFileDatabaseDefinition_FunctionAndProcedureSeparation(t *testing.T) {// This test verifies that functions and procedures are separated into different folders// in multi-file mode- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "get_user_count",Definition: `CREATE FUNCTION "public"."get_user_count"() RETURNS integer@@ -2183,11 +2184,11 @@ BEGINEND;$function$`- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "camel_to_snake",Signature: "camel_to_snake(camel_cased_text character varying)",@@ -2234,16 +2235,16 @@ $function$`// feeds. The regression surfaced as omni pgparser choking on the backslash// right after `COMMENT ON INDEX ... IS '...';`.func TestGetDatabaseDefinition_IndexCommentUsesRealNewline(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx_t_id",Type: "btree",Expressions: []string{"id"},@@ -2278,13 +2279,13 @@ func TestGetDatabaseDefinition_IndexCommentUsesRealNewline(t *testing.T) {// `CREATE TABLE "..."."..." (,` — an invalid leading comma. We force the// case by declaring a CHECK constraint on a table with no regular columns.func TestGetDatabaseDefinition_TableWithOnlyCheckConstraints(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "cons_only",- CheckConstraints: []*storepb.CheckConstraintMetadata{{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "cons_only_dummy",Expression: "(1 = 1)",}},@@ -2325,11 +2326,11 @@ func TestGetDatabaseDefinition_TableWithOnlyCheckConstraints(t *testing.T) {// column-dependent DDL for such tables instead of producing non-replayable// statements.func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "s1",- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{// Owned by a column missing from t1's metadata: the sequence// itself must dump, its OWNED BY clause must not.@@ -2357,11 +2358,11 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {OwnerColumn: "id",},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{// Broken sync: constraints and indexes, but no columns.Name: "t1",- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "pk_t1",Primary: true,@@ -2383,23 +2384,23 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {Comment: "comment on a never-created index",},},- CheckConstraints: []*storepb.CheckConstraintMetadata{{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "chk_t1_c1",Expression: "(c1 > 0)",}},- ForeignKeys: []*storepb.ForeignKeyMetadata{{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "fk_t1_t2",Columns: []string{"c1"},ReferencedSchema: "s1",ReferencedTable: "t2",ReferencedColumns: []string{"id"},}},- Triggers: []*storepb.TriggerMetadata{{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "trg_t1_c1",Body: `CREATE TRIGGER trg_t1_c1 BEFORE UPDATE OF c1 ON s1.t1 FOR EACH ROW EXECUTE FUNCTION s1.f()`,Comment: "comment on a never-created trigger",}},- Rules: []*storepb.RuleMetadata{{+ Rules: []*metadatapb.RuleMetadata{{Name: "rule_t1",Event: "INSERT",Definition: `CREATE RULE rule_t1 AS ON INSERT TO s1.t1 WHERE new.c1 > 0 DO INSTEAD NOTHING;`,@@ -2409,18 +2410,18 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {// Healthy table; its own constraints must still dump, but// its foreign key into the broken table must not.Name: "t2",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "t1_c1", Type: "integer", Nullable: true},},- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "pk_t2",Primary: true,Unique: true,IsConstraint: true,Expressions: []string{"id"},}},- ForeignKeys: []*storepb.ForeignKeyMetadata{{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "fk_t2_t1",Columns: []string{"t1_c1"},ReferencedSchema: "s1",@@ -2433,7 +2434,7 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {// partition key references missing columns, so the table// must dump bare, without the PARTITION BY clause.Name: "t3",- Partitions: []*storepb.TablePartitionMetadata{{+ Partitions: []*metadatapb.TablePartitionMetadata{{Name: "t3_p1",Expression: "RANGE (created_at)",}},@@ -2442,7 +2443,7 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {// Genuine zero-column table: no indexes, foreign keys, or// partitions. Its column-independent CHECK must be kept.Name: "t4",- CheckConstraints: []*storepb.CheckConstraintMetadata{{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "chk_t4_ok",Expression: "(1 = 1)",}},@@ -2508,13 +2509,13 @@ func TestGetDatabaseDefinition_TableWithConstraintsButNoColumns(t *testing.T) {// because the schema + "." + object object-ID was split back on the first// dot and produced an empty schema. The fix uses a NUL separator.func TestGetDatabaseDefinition_TableNameContainingDot(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "weird.name",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},}},@@ -2561,7 +2562,7 @@ func TestGetDatabaseDefinition(t *testing.T) {for i, tc := range tests {t.Run(tc.Description, func(t *testing.T) {- var metadata storepb.DatabaseSchemaMetadata+ var metadata metadatapb.DatabaseSchemaMetadatarequire.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), &metadata))definition, err := GetDatabaseDefinition(schema.GetDefinitionContext{PrintHeader: true}, &metadata)@@ -2591,15 +2592,15 @@ func TestGetDatabaseDefinition(t *testing.T) {func TestCheckConstraintOrderStability(t *testing.T) {// Simulate database metadata with multiple CHECK constraints// (similar to the packages_debian_group_distributions table shown in the screenshot)- dbMetadata := &storepb.DatabaseSchemaMetadata{+ dbMetadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "packages_debian_group_distributions",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint", Nullable: false},{Name: "suite", Type: "character varying(255)", Nullable: false},{Name: "codename", Type: "character varying(255)", Nullable: false},@@ -2611,7 +2612,7 @@ func TestCheckConstraintOrderStability(t *testing.T) {{Name: "version", Type: "character varying(255)", Nullable: true},{Name: "file_signature", Type: "character varying(4096)", Nullable: true},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "check_e7c928a24b", Expression: "(char_length((suite)::text) <= 255)"},{Name: "check_590e18405a", Expression: "(char_length((codename)::text) <= 255)"},{Name: "check_0007e0bf61", Expression: "(char_length(signed_file) <= 255)"},@@ -2655,17 +2656,17 @@ func TestCheckConstraintOrderStability(t *testing.T) {func TestGetDatabaseDefinitionSDLFormat_CompositeTypes(t *testing.T) {// aa_nested sorts before its dependency zz_base alphabetically, so correct// output proves dependency ordering rather than name ordering.- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "order_status", Values: []string{"pending", "shipped"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "aa_nested",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "home", Type: "public.zz_base"},{Name: "homes", Type: "public.zz_base[]"},{Name: "status", Type: "public.order_status"},@@ -2674,7 +2675,7 @@ func TestGetDatabaseDefinitionSDLFormat_CompositeTypes(t *testing.T) {{Name: "zz_base",Comment: "base address type",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Collation: `"C"`, Comment: "street line"},{Name: "city", Type: "character varying(50)"},},@@ -2682,7 +2683,7 @@ func TestGetDatabaseDefinitionSDLFormat_CompositeTypes(t *testing.T) {{Name: "ext_owned",SkipDump: true,- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},@@ -2693,10 +2694,10 @@ func TestGetDatabaseDefinitionSDLFormat_CompositeTypes(t *testing.T) {},{Name: "geo",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "point2",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "lat", Type: "numeric(9,6)"},{Name: "lng", Type: "numeric(9,6)"},},@@ -2739,23 +2740,23 @@ func TestGetDatabaseDefinitionSDLFormat_CompositeTypes(t *testing.T) {}func TestGetMultiFileDatabaseDefinition_CompositeTypes(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "mood", Values: []string{"happy", "sad"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "wrapper",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "public.base"},},},{Name: "base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},Comment: "base type",@@ -2822,17 +2823,17 @@ func TestParseQualifiedTypeIdent(t *testing.T) {func TestSortCompositeTypesTopologically(t *testing.T) {// Chain across schemas: public.a3 -> other.b2 -> public.c1, with names// chosen so alphabetical order is the reverse of dependency order.- c1 := &storepb.CompositeTypeMetadata{+ c1 := &metadatapb.CompositeTypeMetadata{Name: "c1",- Attributes: []*storepb.CompositeTypeAttribute{{Name: "x", Type: "integer"}},+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"}},}- b2 := &storepb.CompositeTypeMetadata{+ b2 := &metadatapb.CompositeTypeMetadata{Name: "b2",- Attributes: []*storepb.CompositeTypeAttribute{{Name: "c", Type: "public.c1"}},+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "c", Type: "public.c1"}},}- a3 := &storepb.CompositeTypeMetadata{+ a3 := &metadatapb.CompositeTypeMetadata{Name: "a3",- Attributes: []*storepb.CompositeTypeAttribute{{Name: "b", Type: "other.b2[]"}},+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "other.b2[]"}},}ordered := sortCompositeTypesTopologically([]qualifiedCompositeType{{Schema: "public", Composite: a3},@@ -2846,8 +2847,8 @@ func TestSortCompositeTypesTopologically(t *testing.T) {// Independent types come out in deterministic (schema, name) order.ordered = sortCompositeTypesTopologically([]qualifiedCompositeType{- {Schema: "public", Composite: &storepb.CompositeTypeMetadata{Name: "zz"}},- {Schema: "public", Composite: &storepb.CompositeTypeMetadata{Name: "aa"}},+ {Schema: "public", Composite: &metadatapb.CompositeTypeMetadata{Name: "zz"}},+ {Schema: "public", Composite: &metadatapb.CompositeTypeMetadata{Name: "aa"}},})require.Len(t, ordered, 2)assert.Equal(t, "aa", ordered[0].Composite.Name)@@ -2895,12 +2896,12 @@ func TestEventTriggerSDLMultiFileOutput(t *testing.T) {assert.Contains(t, eventTriggerFile, `COMMENT ON EVENT TRIGGER "audit_ddl_start" IS 'Audit DDL start';`)}-func eventTriggerSDLMetadata() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func eventTriggerSDLMetadata() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "audit_ddl",Signature: "audit_ddl()",@@ -2914,7 +2915,7 @@ $$`,},},},- EventTriggers: []*storepb.EventTriggerMetadata{+ EventTriggers: []*metadatapb.EventTriggerMetadata{{Name: "audit_ddl_start",Event: "ddl_command_start",@@ -2929,18 +2930,18 @@ $$`,}func TestTriggerSDLSingleFileOutput(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "audit_trigger",Body: "CREATE TRIGGER audit_trigger AFTER INSERT ON public.users FOR EACH ROW EXECUTE FUNCTION audit_log()",@@ -2965,18 +2966,18 @@ func TestTriggerSDLSingleFileOutput(t *testing.T) {}func TestTriggerSDLMultiFileOutput(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "audit_trigger",Body: "CREATE TRIGGER audit_trigger AFTER INSERT ON public.users FOR EACH ROW EXECUTE FUNCTION audit_log()",@@ -3013,18 +3014,18 @@ func TestTriggerSDLMultiFileOutput(t *testing.T) {func TestTriggerSDLWithCompleteDefinition(t *testing.T) {// Test that triggers with complete CREATE TRIGGER statements in Body are output correctly// This simulates triggers dumped from the database where Body contains the full statement- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "ci_builds",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "ci_builds_loose_fk_trigger",Body: "CREATE TRIGGER ci_builds_loose_fk_trigger AFTER DELETE ON public.ci_builds REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION public.loose_foreign_key_on_builds_projects()",@@ -3055,18 +3056,18 @@ func TestTriggerSDLWithCompleteDefinition(t *testing.T) {}func TestTriggerSDLWithComment(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "audit_trigger",Body: "CREATE TRIGGER audit_trigger AFTER INSERT ON public.users FOR EACH ROW EXECUTE FUNCTION audit_log()",@@ -3093,18 +3094,18 @@ func TestTriggerSDLWithComment(t *testing.T) {}func TestMultipleTriggersSDL(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "audit_insert",Body: "CREATE TRIGGER audit_insert AFTER INSERT ON public.users FOR EACH ROW EXECUTE FUNCTION audit_log()",diff --git a/backend/plugin/schema/pg/legacy_normalize.go b/backend/plugin/schema/pg/legacy_normalize.goindex 50a8fb441e..6e5b8c7176 100644--- a/backend/plugin/schema/pg/legacy_normalize.go+++ b/backend/plugin/schema/pg/legacy_normalize.go@@ -32,12 +32,12 @@ import ("regexp""strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// normalizeLegacyMetadata mutates meta in place to match the canonical// IndexMetadata.expressions contract. Idempotent and cheap on canonical input.-func normalizeLegacyMetadata(meta *storepb.DatabaseSchemaMetadata) {+func normalizeLegacyMetadata(meta *metadatapb.DatabaseSchemaMetadata) {if meta == nil {return}@@ -54,7 +54,7 @@ func normalizeLegacyMetadata(meta *storepb.DatabaseSchemaMetadata) {}}-func canonicalizePartitionIndexes(p *storepb.TablePartitionMetadata) {+func canonicalizePartitionIndexes(p *metadatapb.TablePartitionMetadata) {if p == nil {return}@@ -64,7 +64,7 @@ func canonicalizePartitionIndexes(p *storepb.TablePartitionMetadata) {}}-func canonicalizeIndexExpressions(indexes []*storepb.IndexMetadata) {+func canonicalizeIndexExpressions(indexes []*metadatapb.IndexMetadata) {for _, idx := range indexes {for i, expr := range idx.Expressions {idx.Expressions[i] = canonicalizeIndexKeyExpression(expr)diff --git a/backend/plugin/schema/pg/legacy_normalize_test.go b/backend/plugin/schema/pg/legacy_normalize_test.goindex b0ad3c5928..b82c23931e 100644--- a/backend/plugin/schema/pg/legacy_normalize_test.go+++ b/backend/plugin/schema/pg/legacy_normalize_test.go@@ -4,9 +4,9 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata"omnipg "github.com/bytebase/omni/pg"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -204,13 +204,13 @@ func TestIndexEmissionParses(t *testing.T) {{"parenthesized (canonical for expressions)", "(" + expr + ")"},}for _, shape := range shapes {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a", Position: 1, Type: "integer"},{Name: "b", Position: 2, Type: "integer"},{Name: "name", Position: 3, Type: "text"},@@ -219,7 +219,7 @@ func TestIndexEmissionParses(t *testing.T) {{Name: "tags", Position: 6, Type: "text[]"},{Name: "payload", Position: 7, Type: "jsonb"},},- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx",Type: "btree",Expressions: []string{shape.stored},@@ -243,30 +243,30 @@ func TestIndexEmissionParses(t *testing.T) {// TablePartitionMetadata.Indexes (including nested Subpartitions) and// MaterializedViewMetadata.Indexes — which are structurally easy to miss.func TestNormalizeLegacyMetadata_PartitionAndMV(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Partitions: []*storepb.TablePartitionMetadata{{+ Partitions: []*metadatapb.TablePartitionMetadata{{Name: "t_p1",- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "partition_idx",Expressions: []string{"payload ->> 'k'::text"}, // legacy: no parens}},- Subpartitions: []*storepb.TablePartitionMetadata{{+ Subpartitions: []*metadatapb.TablePartitionMetadata{{Name: "t_p1_sub",- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "subpartition_idx",Expressions: []string{"a + b"}, // legacy: no parens}},}},}},}},- MaterializedViews: []*storepb.MaterializedViewMetadata{{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "mv",- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "mv_idx",Expressions: []string{"lower(name)"}, // canonical: bare func call}},@@ -299,35 +299,35 @@ func TestNormalizeLegacyMetadata_PartitionAndMV(t *testing.T) {// through GetMultiFileDatabaseDefinition, which has its own entry point and// was previously missing the normalization pass (Codex review, PR #20009).func TestGetMultiFileDatabaseDefinition_LegacyIndexExpressionsParse(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "a", Position: 1, Type: "integer"},{Name: "b", Position: 2, Type: "integer"},{Name: "payload", Position: 3, Type: "jsonb"},},- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "t_legacy_idx",Type: "btree",Expressions: []string{"payload ->> 'k'::text"}, // legacy}},- Partitions: []*storepb.TablePartitionMetadata{{+ Partitions: []*metadatapb.TablePartitionMetadata{{Name: "t_p1",- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "t_p1_legacy_idx",Type: "btree",Expressions: []string{"a + b"}, // legacy}},}},}},- MaterializedViews: []*storepb.MaterializedViewMetadata{{+ MaterializedViews: []*metadatapb.MaterializedViewMetadata{{Name: "mv",Definition: "SELECT 1 AS x",- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "mv_legacy_idx",Type: "btree",Expressions: []string{"payload ->> 'k'::text"}, // legacy@@ -360,16 +360,16 @@ func TestGetMultiFileDatabaseDefinition_LegacyIndexExpressionsParse(t *testing.T// top of GetDatabaseDefinition. The caller's metadata (often a shared pointer// from store.dbSchemaCache) must not be altered by the normalization pass.func TestGetDatabaseDefinition_DoesNotMutateInput(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "payload", Position: 1, Type: "jsonb"},},- Indexes: []*storepb.IndexMetadata{{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx",Type: "btree",// Deliberately non-canonical: the normalizer would rewrite this.diff --git a/backend/plugin/schema/pg/metadata_migration.go b/backend/plugin/schema/pg/metadata_migration.goindex ea2e5cbfaf..5bdb41d337 100644--- a/backend/plugin/schema/pg/metadata_migration.go+++ b/backend/plugin/schema/pg/metadata_migration.go@@ -7,6 +7,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -179,7 +180,7 @@ func addUnchangedDependentMaterializedViews(diff *schema.MetadataDiff, oldSchema}}-func dependencyColumnsReferenceAffectedTable(dependencies []*storepb.DependencyColumn, affectedTables map[string]affectedTableColumns) bool {+func dependencyColumnsReferenceAffectedTable(dependencies []*metadatapb.DependencyColumn, affectedTables map[string]affectedTableColumns) bool {for _, dep := range dependencies {affected, ok := affectedTables[getMigrationObjectID(dep.GetSchema(), dep.GetTable())]if !ok {@@ -277,7 +278,7 @@ func postViewCompositeAlters(diff *schema.MetadataDiff) map[*schema.CompositeTypif compositeDiff.Action != schema.MetadataDiffActionAlter {continue}- oldAttributes := make(map[string]*storepb.CompositeTypeAttribute)+ oldAttributes := make(map[string]*metadatapb.CompositeTypeAttribute)for _, attribute := range compositeDiff.OldCompositeType.GetAttributes() {oldAttributes[attribute.Name] = attribute}@@ -316,7 +317,7 @@ func computeDeferredDrops(diff *schema.MetadataDiff) *deferredDropSet {}var topLevelDrops []*schema.CompositeTypeDiffdeferredComposites := make(map[*schema.CompositeTypeDiff]bool)- var pool []*storepb.CompositeTypeMetadata+ var pool []*metadatapb.CompositeTypeMetadatafor _, compositeDiff := range diff.CompositeTypeChanges {if compositeDiff.Action != schema.MetadataDiffActionDrop {continue@@ -460,7 +461,7 @@ func writeDeferredDropPhase(out *strings.Builder, diff *schema.MetadataDiff) err// compositePoolReferencesSchema reports whether any composite in the pool has// an attribute whose (always schema-qualified) type lives in the schema.-func compositePoolReferencesSchema(pool []*storepb.CompositeTypeMetadata, schemaName string) bool {+func compositePoolReferencesSchema(pool []*metadatapb.CompositeTypeMetadata, schemaName string) bool {for _, compositeType := range pool {for _, attribute := range compositeType.GetAttributes() {if depSchema, _, ok := parseQualifiedTypeIdent(attribute.Type); ok && depSchema == schemaName {@@ -493,7 +494,7 @@ func schemaOwnsRetypeReleasedComposite(diff *schema.MetadataDiff, schemaDiff *sc// references the given type. Attribute types are stored schema-qualified for// user-defined types; the bare fallback matches by name alone, which may// defer a drop unnecessarily — a safe direction.-func compositeReferencesType(composite *storepb.CompositeTypeMetadata, typeSchema, typeName string) bool {+func compositeReferencesType(composite *metadatapb.CompositeTypeMetadata, typeSchema, typeName string) bool {for _, attribute := range composite.GetAttributes() {if typeStringReferencesComposite(attribute.Type, typeSchema, typeName) {return true@@ -530,7 +531,7 @@ func immediateCompositeDrops(diff *schema.MetadataDiff, deferred *deferredDropSe// the same graph.func dropGraphComposites(diff *schema.MetadataDiff) (map[string]*schema.CompositeTypeDiff, []*schema.CompositeTypeDiff) {immediate := immediateCompositeDrops(diff, computeDeferredDrops(diff))- var pool []*storepb.CompositeTypeMetadata+ var pool []*metadatapb.CompositeTypeMetadatafor _, schemaDiff := range diff.SchemaChanges {if schemaDiff.Action != schema.MetadataDiffActionDrop || skipPostgresSchemaDDL(schemaDiff.SchemaName) {continue@@ -1059,7 +1060,7 @@ func writeDropTableForeignKeysForTableDrops(out *strings.Builder, diff *schema.Mreturn nil}-func isSequenceOwnedByDroppedTable(diff *schema.MetadataDiff, schemaName string, sequence *storepb.SequenceMetadata) bool {+func isSequenceOwnedByDroppedTable(diff *schema.MetadataDiff, schemaName string, sequence *metadatapb.SequenceMetadata) bool {if sequence.GetOwnerTable() == "" || sequence.GetOwnerColumn() == "" {return false}@@ -1426,7 +1427,7 @@ func writeSequenceOwnershipAfterTables(out *strings.Builder, diff *schema.Metadareturn nil}-func sequenceOwnershipChanged(oldSequence, newSequence *storepb.SequenceMetadata) bool {+func sequenceOwnershipChanged(oldSequence, newSequence *metadatapb.SequenceMetadata) bool {return oldSequence.GetOwnerTable() != newSequence.GetOwnerTable() || oldSequence.GetOwnerColumn() != newSequence.GetOwnerColumn()}@@ -1609,7 +1610,7 @@ func writeTableDiff(out *strings.Builder, tableDiff *schema.TableDiff) error {}}-func writeTableForMetadataMigration(out *strings.Builder, schemaName string, table *storepb.TableMetadata) error {+func writeTableForMetadataMigration(out *strings.Builder, schemaName string, table *metadatapb.TableMetadata) error {if err := writeCreateTableForMetadataMigration(out, schemaName, table); err != nil {return err}@@ -1687,7 +1688,7 @@ func writeTableForMetadataMigration(out *strings.Builder, schemaName string, tabreturn nil}-func writeCreateTableForMetadataMigration(out *strings.Builder, schemaName string, table *storepb.TableMetadata) error {+func writeCreateTableForMetadataMigration(out *strings.Builder, schemaName string, table *metadatapb.TableMetadata) error {if _, err := fmt.Fprintf(out, "CREATE TABLE \"%s\".\"%s\" (", schemaName, table.GetName()); err != nil {return err}@@ -1724,7 +1725,7 @@ func writeCreateTableForMetadataMigration(out *strings.Builder, schemaName strinreturn err}-func writeDropPartition(out *strings.Builder, schemaName string, partition *storepb.TablePartitionMetadata) error {+func writeDropPartition(out *strings.Builder, schemaName string, partition *metadatapb.TablePartitionMetadata) error {if partition == nil {return nil}@@ -1737,7 +1738,7 @@ func writeDropPartition(out *strings.Builder, schemaName string, partition *storreturn err}-func writeCreatePartitionDiff(out *strings.Builder, schemaName, tableName string, columns []*storepb.ColumnMetadata, partition *storepb.TablePartitionMetadata) error {+func writeCreatePartitionDiff(out *strings.Builder, schemaName, tableName string, columns []*metadatapb.ColumnMetadata, partition *metadatapb.TablePartitionMetadata) error {if partition == nil {return nil}@@ -1759,7 +1760,7 @@ func writeCreatePartitionDiff(out *strings.Builder, schemaName, tableName stringreturn writeAttachPartitionIndex(out, schemaName, partition)}-func writePartitionIndexForMetadataMigration(out *strings.Builder, schemaName string, partition *storepb.TablePartitionMetadata) error {+func writePartitionIndexForMetadataMigration(out *strings.Builder, schemaName string, partition *metadatapb.TablePartitionMetadata) error {for _, index := range partition.GetIndexes() {if !index.GetIsConstraint() && !index.GetPrimary() {if err := writeCreateRegularIndex(out, schemaName, partition.GetName(), index, len(partition.GetSubpartitions()) > 0); err != nil {@@ -1959,7 +1960,7 @@ func extractLength(typeName string) int {return length}-func writeColumnDefinition(out *strings.Builder, column *storepb.ColumnMetadata) error {+func writeColumnDefinition(out *strings.Builder, column *metadatapb.ColumnMetadata) error {if _, err := fmt.Fprintf(out, "\"%s\" %s", column.Name, column.Type); err != nil {return err}@@ -1969,11 +1970,11 @@ func writeColumnDefinition(out *strings.Builder, column *storepb.ColumnMetadata)}}switch column.GetIdentityGeneration() {- case storepb.ColumnMetadata_ALWAYS:+ case metadatapb.ColumnMetadata_ALWAYS:if _, err := out.WriteString(" GENERATED ALWAYS AS IDENTITY"); err != nil {return err}- case storepb.ColumnMetadata_BY_DEFAULT:+ case metadatapb.ColumnMetadata_BY_DEFAULT:if _, err := out.WriteString(" GENERATED BY DEFAULT AS IDENTITY"); err != nil {return err}@@ -1981,7 +1982,7 @@ func writeColumnDefinition(out *strings.Builder, column *storepb.ColumnMetadata)}if generation := column.GetGeneration(); generation != nil && generation.GetExpression() != "" {generationType := "STORED"- if generation.GetType() == storepb.GenerationMetadata_TYPE_VIRTUAL {+ if generation.GetType() == metadatapb.GenerationMetadata_TYPE_VIRTUAL {generationType = "VIRTUAL"}if _, err := fmt.Fprintf(out, " GENERATED ALWAYS AS (%s) %s", generation.GetExpression(), generationType); err != nil {@@ -2013,7 +2014,7 @@ func writeDropTableConstraint(out *strings.Builder, schemaName, tableName, constreturn err}-func writeDropIndexDiff(out *strings.Builder, schemaName, tableName string, index *storepb.IndexMetadata) error {+func writeDropIndexDiff(out *strings.Builder, schemaName, tableName string, index *metadatapb.IndexMetadata) error {if index.GetIsConstraint() {return writeDropTableConstraint(out, schemaName, tableName, index.GetName())}@@ -2024,7 +2025,7 @@ func writeDropIndexDiff(out *strings.Builder, schemaName, tableName string, indereturn err}-func writeAddCheckConstraint(out *strings.Builder, schemaName, tableName string, check *storepb.CheckConstraintMetadata) error {+func writeAddCheckConstraint(out *strings.Builder, schemaName, tableName string, check *metadatapb.CheckConstraintMetadata) error {if check == nil {return nil}@@ -2034,7 +2035,7 @@ func writeAddCheckConstraint(out *strings.Builder, schemaName, tableName string,return nil}-func writeAddExcludeConstraint(out *strings.Builder, schemaName, tableName string, exclude *storepb.ExcludeConstraintMetadata) error {+func writeAddExcludeConstraint(out *strings.Builder, schemaName, tableName string, exclude *metadatapb.ExcludeConstraintMetadata) error {if exclude == nil {return nil}@@ -2044,7 +2045,7 @@ func writeAddExcludeConstraint(out *strings.Builder, schemaName, tableName strinreturn nil}-func writeCreateIndexDiff(out *strings.Builder, schemaName, tableName string, index *storepb.IndexMetadata) error {+func writeCreateIndexDiff(out *strings.Builder, schemaName, tableName string, index *metadatapb.IndexMetadata) error {if index == nil {return nil}@@ -2058,7 +2059,7 @@ func writeCreateIndexDiff(out *strings.Builder, schemaName, tableName string, in}}-func writeCreateRegularIndex(out *strings.Builder, schemaName, tableName string, index *storepb.IndexMetadata, useOnlyClause bool) error {+func writeCreateRegularIndex(out *strings.Builder, schemaName, tableName string, index *metadatapb.IndexMetadata, useOnlyClause bool) error {if index.GetDefinition() != "" {if err := writeDefinitionStatement(out, index.GetDefinition()); err != nil {return err@@ -2151,14 +2152,14 @@ func skipPostgresSchemaDDL(schemaName string) bool {return schemaName == "pg_catalog" || schemaName == "public"}-func writeDropSchemaObjects(out *strings.Builder, schemaName string, schemaMeta *storepb.SchemaMetadata) error {+func writeDropSchemaObjects(out *strings.Builder, schemaName string, schemaMeta *metadatapb.SchemaMetadata) error {if err := writeDropSchemaNonTypeObjects(out, schemaName, schemaMeta); err != nil {return err}return writeDropSchemaTypes(out, schemaName, schemaMeta)}-func writeDropSchemaNonTypeObjects(out *strings.Builder, schemaName string, schemaMeta *storepb.SchemaMetadata) error {+func writeDropSchemaNonTypeObjects(out *strings.Builder, schemaName string, schemaMeta *metadatapb.SchemaMetadata) error {if schemaMeta == nil {return nil}@@ -2188,7 +2189,7 @@ func writeDropSchemaNonTypeObjects(out *strings.Builder, schemaName string, schereturn nil}-func writeDropSchemaTypes(out *strings.Builder, schemaName string, schemaMeta *storepb.SchemaMetadata) error {+func writeDropSchemaTypes(out *strings.Builder, schemaName string, schemaMeta *metadatapb.SchemaMetadata) error {if schemaMeta == nil {return nil}@@ -2205,7 +2206,7 @@ func writeDropSchemaTypes(out *strings.Builder, schemaName string, schemaMeta *sreturn nil}-func buildDropSchemaObjectsDiff(schemaName string, schemaMeta *storepb.SchemaMetadata) *schema.MetadataDiff {+func buildDropSchemaObjectsDiff(schemaName string, schemaMeta *metadatapb.SchemaMetadata) *schema.MetadataDiff {diff := &schema.MetadataDiff{}for _, table := range schemaMeta.GetTables() {if table.GetSkipDump() {@@ -2344,7 +2345,7 @@ func writeSequenceDiff(out *strings.Builder, sequenceDiff *schema.SequenceDiff)}}-func writeAlterSequence(out *strings.Builder, schemaName string, oldSequence *storepb.SequenceMetadata, sequence *storepb.SequenceMetadata) error {+func writeAlterSequence(out *strings.Builder, schemaName string, oldSequence *metadatapb.SequenceMetadata, sequence *metadatapb.SequenceMetadata) error {if _, err := fmt.Fprintf(out, "ALTER SEQUENCE \"%s\".\"%s\"", schemaName, sequence.Name); err != nil {return err}@@ -2416,7 +2417,7 @@ func writeFunctionDiff(out *strings.Builder, functionDiff *schema.FunctionDiff)}}-func writeFunctionStatement(out *strings.Builder, schemaName string, function *storepb.FunctionMetadata, replace bool) error {+func writeFunctionStatement(out *strings.Builder, schemaName string, function *metadatapb.FunctionMetadata, replace bool) error {definition := function.GetDefinition()if replace {definition = convertCreateFunctionToCreateOrReplace(definition)@@ -2467,7 +2468,7 @@ func writeProcedureDiff(out *strings.Builder, procedureDiff *schema.ProcedureDif}}-func writeProcedure(out *strings.Builder, schemaName string, procedure *storepb.ProcedureMetadata) error {+func writeProcedure(out *strings.Builder, schemaName string, procedure *metadatapb.ProcedureMetadata) error {if err := writeDefinitionStatement(out, procedure.Definition); err != nil {return err}@@ -2543,7 +2544,7 @@ func writeEnumTypeDiff(out *strings.Builder, enumDiff *schema.EnumTypeDiff) erro}}-func writeAlterEnumTypeAddValues(out *strings.Builder, schemaName string, oldEnum *storepb.EnumTypeMetadata, newEnum *storepb.EnumTypeMetadata) error {+func writeAlterEnumTypeAddValues(out *strings.Builder, schemaName string, oldEnum *metadatapb.EnumTypeMetadata, newEnum *metadatapb.EnumTypeMetadata) error {oldValueSet := make(map[string]bool)for _, value := range oldEnum.GetValues() {oldValueSet[value] = true@@ -2669,7 +2670,7 @@ func releasingCompositeAttributes(diff *schema.MetadataDiff) map[string]int {if compositeDiff.Action != schema.MetadataDiffActionAlter {continue}- newAttributes := make(map[string]*storepb.CompositeTypeAttribute)+ newAttributes := make(map[string]*metadatapb.CompositeTypeAttribute)for _, attribute := range compositeDiff.NewCompositeType.GetAttributes() {newAttributes[attribute.Name] = attribute}@@ -2708,7 +2709,7 @@ func writeReleasingCompositeAlters(out *strings.Builder, diff *schema.MetadataDiif compositeDiff.Action != schema.MetadataDiffActionAlter {continue}- newAttributes := make(map[string]*storepb.CompositeTypeAttribute)+ newAttributes := make(map[string]*metadatapb.CompositeTypeAttribute)for _, attribute := range compositeDiff.NewCompositeType.GetAttributes() {newAttributes[attribute.Name] = attribute}@@ -2773,12 +2774,12 @@ const alterAttributeAction = "ALTER ATTRIBUTE"// type — PostgreSQL has no online path for that change; the reviewer sees the// statement and the executor surfaces the error. Attribute reordering has no// DDL at all and only produces a warning comment.-func writeAlterCompositeType(out *strings.Builder, schemaName string, oldComposite, newComposite *storepb.CompositeTypeMetadata, released map[string]int) error {- oldAttributeMap := make(map[string]*storepb.CompositeTypeAttribute)+func writeAlterCompositeType(out *strings.Builder, schemaName string, oldComposite, newComposite *metadatapb.CompositeTypeMetadata, released map[string]int) error {+ oldAttributeMap := make(map[string]*metadatapb.CompositeTypeAttribute)for _, attribute := range oldComposite.GetAttributes() {oldAttributeMap[attribute.Name] = attribute}- newAttributeMap := make(map[string]*storepb.CompositeTypeAttribute)+ newAttributeMap := make(map[string]*metadatapb.CompositeTypeAttribute)for _, attribute := range newComposite.GetAttributes() {newAttributeMap[attribute.Name] = attribute}@@ -2858,7 +2859,7 @@ func writeAlterCompositeType(out *strings.Builder, schemaName string, oldComposireturn nil}-func writeAlterCompositeAttribute(out *strings.Builder, schemaName, typeName, action string, attribute *storepb.CompositeTypeAttribute) error {+func writeAlterCompositeAttribute(out *strings.Builder, schemaName, typeName, action string, attribute *metadatapb.CompositeTypeAttribute) error {typeClause := attribute.Typeif action == alterAttributeAction {typeClause = "TYPE " + attribute.Type@@ -2882,7 +2883,7 @@ func writeAlterCompositeAttribute(out *strings.Builder, schemaName, typeName, ac// old relative positions and ADD ATTRIBUTE always appends at the end, so any// target that deviates from that achievable order — including an attribute// inserted in the middle — is unreachable and warrants the warning.-func compositeAttributesReordered(oldComposite, newComposite *storepb.CompositeTypeMetadata) bool {+func compositeAttributesReordered(oldComposite, newComposite *metadatapb.CompositeTypeMetadata) bool {oldNames := make(map[string]bool)for _, attribute := range oldComposite.GetAttributes() {oldNames[attribute.Name] = truediff --git a/backend/plugin/schema/pg/metadata_migration_test.go b/backend/plugin/schema/pg/metadata_migration_test.goindex 8e5d7debd8..40cf87675b 100644--- a/backend/plugin/schema/pg/metadata_migration_test.go+++ b/backend/plugin/schema/pg/metadata_migration_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -33,13 +34,13 @@ func TestPGMetadataDiffRawViewAlterUsesMetadataDefinition(t *testing.T) {}func TestCockroachMetadataDiffIdenticalRawViewDoesNotLoadSDL(t *testing.T) {- source := newDatabaseMetadataWithEngine(storepb.Engine_COCKROACHDB, nil, []*storepb.ViewMetadata{+ source := newDatabaseMetadataWithEngine(storepb.Engine_COCKROACHDB, nil, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT @@@omni_unsupported@@@",},})- target := newDatabaseMetadataWithEngine(storepb.Engine_COCKROACHDB, nil, []*storepb.ViewMetadata{+ target := newDatabaseMetadataWithEngine(storepb.Engine_COCKROACHDB, nil, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT @@@omni_unsupported@@@",@@ -57,10 +58,10 @@ func TestCockroachMetadataDiffUsesCockroachFunctionComparer(t *testing.T) {t.Cleanup(func() {schema.RegisterFunctionComparer(storepb.Engine_COCKROACHDB, &schema.DefaultFunctionComparer{})})- source := newCockroachDatabaseMetadataWithFunctions([]*storepb.FunctionMetadata{+ source := newCockroachDatabaseMetadataWithFunctions([]*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 1"),})- target := newCockroachDatabaseMetadataWithFunctions([]*storepb.FunctionMetadata{+ target := newCockroachDatabaseMetadataWithFunctions([]*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 2"),})@@ -72,10 +73,10 @@ func TestCockroachMetadataDiffUsesCockroachFunctionComparer(t *testing.T) {func TestPGMetadataDiffCreateTableFromMetadata(t *testing.T) {source := newPGDatabaseMetadata(nil, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -100,15 +101,15 @@ func TestPGMetadataDiffCreateTableFromMetadata(t *testing.T) {func TestPGMetadataDiffCreateTableWithGeneratedAndIdentityColumnsFromMetadata(t *testing.T) {source := newPGDatabaseMetadata(nil, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "bigint",Nullable: false,- IdentityGeneration: storepb.ColumnMetadata_BY_DEFAULT,+ IdentityGeneration: metadatapb.ColumnMetadata_BY_DEFAULT,},{Name: "name",@@ -119,8 +120,8 @@ func TestPGMetadataDiffCreateTableWithGeneratedAndIdentityColumnsFromMetadata(tName: "name_key",Type: "text",Nullable: false,- Generation: &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ Generation: &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: "lower(name)",},},@@ -136,10 +137,10 @@ func TestPGMetadataDiffCreateTableWithGeneratedAndIdentityColumnsFromMetadata(t}func TestPGMetadataDiffAlterTableAddColumnFromMetadata(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -148,10 +149,10 @@ func TestPGMetadataDiffAlterTableAddColumnFromMetadata(t *testing.T) {},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -173,31 +174,31 @@ func TestPGMetadataDiffAlterTableAddColumnFromMetadata(t *testing.T) {}func TestPGMetadataDiffAlterTableAddGeneratedAndIdentityColumnsFromMetadata(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "name", Type: "text", Nullable: false},},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "name", Type: "text", Nullable: false},{Name: "id",Type: "bigint",Nullable: false,- IdentityGeneration: storepb.ColumnMetadata_ALWAYS,+ IdentityGeneration: metadatapb.ColumnMetadata_ALWAYS,},{Name: "name_key",Type: "text",Nullable: false,- Generation: &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ Generation: &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: "lower(name)",},},@@ -213,18 +214,18 @@ func TestPGMetadataDiffAlterTableAddGeneratedAndIdentityColumnsFromMetadata(t *t}func TestPGMetadataDiffAlterColumnTypeUsesUsingForIncompatibleCast(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "events",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "payload", Type: "text", Nullable: true},},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "events",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "payload", Type: "integer", Nullable: true},},},@@ -237,19 +238,19 @@ func TestPGMetadataDiffAlterColumnTypeUsesUsingForIncompatibleCast(t *testing.T)}func TestPGMetadataDiffAlterTableDropsColumnOnce(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "legacy", Type: "text", Nullable: true},},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},@@ -262,10 +263,10 @@ func TestPGMetadataDiffAlterTableDropsColumnOnce(t *testing.T) {}func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "accounts",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -275,7 +276,7 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {},{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -294,10 +295,10 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "accounts",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -308,7 +309,7 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {{Name: "users",Comment: "Application users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "integer",@@ -326,7 +327,7 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {Comment: "Login email",},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey",Expressions: []string{"id"},@@ -346,7 +347,7 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {Type: "btree",},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "users_account_id_fkey",Columns: []string{"account_id"},@@ -356,13 +357,13 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {OnDelete: "CASCADE",},},- CheckConstraints: []*storepb.CheckConstraintMetadata{+ CheckConstraints: []*metadatapb.CheckConstraintMetadata{{Name: "users_email_check",Expression: "(email <> '')",},},- Triggers: []*storepb.TriggerMetadata{+ Triggers: []*metadatapb.TriggerMetadata{{Name: "users_touch_updated_at",Body: "CREATE TRIGGER users_touch_updated_at BEFORE UPDATE ON public.users " +@@ -389,21 +390,21 @@ func TestPGMetadataDiffAlterTableObjectsFromMetadata(t *testing.T) {}func TestPGMetadataDiffCreateIndexUsesFullDefinitionFromMetadata(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "email", Type: "text", Nullable: false},},},}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "email", Type: "text", Nullable: false},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "idx_users_email",Expressions: []string{"email"},@@ -422,14 +423,14 @@ func TestPGMetadataDiffCreateIndexUsesFullDefinitionFromMetadata(t *testing.T) {func TestPGMetadataDiffCreateTableForeignKeysAfterAllTables(t *testing.T) {source := newPGDatabaseMetadata(nil, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "child",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "parent_id", Type: "integer", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "child_parent_id_fkey",Columns: []string{"parent_id"},@@ -441,7 +442,7 @@ func TestPGMetadataDiffCreateTableForeignKeysAfterAllTables(t *testing.T) {},{Name: "parent",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},@@ -461,20 +462,20 @@ func TestPGMetadataDiffCreateTableForeignKeysAfterAllTables(t *testing.T) {}func TestPGMetadataDiffDropTablesInForeignKeyDependencyOrder(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "parent",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},{Name: "child",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "parent_id", Type: "integer", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "child_parent_id_fkey",Columns: []string{"parent_id"},@@ -498,14 +499,14 @@ func TestPGMetadataDiffDropTablesInForeignKeyDependencyOrder(t *testing.T) {}func TestPGMetadataDiffDropTableSkipsOwnedSequenceDrop(t *testing.T) {- source := newPGDatabaseMetadataWithTablesAndSequences([]*storepb.TableMetadata{+ source := newPGDatabaseMetadataWithTablesAndSequences([]*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},- }, []*storepb.SequenceMetadata{+ }, []*metadatapb.SequenceMetadata{{Name: "orders_id_seq",DataType: "bigint",@@ -528,14 +529,14 @@ func TestPGMetadataDiffDropTableSkipsOwnedSequenceDrop(t *testing.T) {}func TestPGMetadataDiffDropCyclicForeignKeyTablesDropsForeignKeysFirst(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "a",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "b_id", Type: "integer", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "a_b_id_fkey",Columns: []string{"b_id"},@@ -547,11 +548,11 @@ func TestPGMetadataDiffDropCyclicForeignKeyTablesDropsForeignKeysFirst(t *testin},{Name: "b",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "a_id", Type: "integer", Nullable: false},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "b_a_id_fkey",Columns: []string{"a_id"},@@ -577,13 +578,13 @@ func TestPGMetadataDiffDropCyclicForeignKeyTablesDropsForeignKeysFirst(t *testin}func TestPGMetadataDiffDropSchemaDropsViewsBeforeTablesWithoutDependencyMetadata(t *testing.T) {- source := newPGDatabaseMetadataWithSchemas([]*storepb.SchemaMetadata{+ source := newPGDatabaseMetadataWithSchemas([]*metadatapb.SchemaMetadata{{Name: "analytics",- Tables: []*storepb.TableMetadata{- {Name: "a", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "a", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false}}},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "z", Definition: "SELECT id FROM analytics.a"},},},@@ -601,36 +602,36 @@ func TestPGMetadataDiffDropSchemaDropsViewsBeforeTablesWithoutDependencyMetadata}func TestPGMetadataDiffDropAlteredViewBeforeDependentTableAlter(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM public.users",Comment: "user ids",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "users"},},},})- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id::bigint AS id FROM public.users",Comment: "user ids",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "users"},},},@@ -653,38 +654,38 @@ func TestPGMetadataDiffDropAlteredViewBeforeDependentTableAlter(t *testing.T) {}func TestPGMetadataDiffDropUnchangedDependentViewBeforeTableAlter(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "name", Type: "text", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM public.users",Comment: "user ids",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "users", Column: "id"},},},})- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint", Nullable: false},{Name: "name", Type: "text", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM public.users",Comment: "user ids",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "users", Column: "id"},},},@@ -707,40 +708,40 @@ func TestPGMetadataDiffDropUnchangedDependentViewBeforeTableAlter(t *testing.T)}func TestPGMetadataDiffDropAlteredViewBeforeDroppedReferencedTable(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "legacy_users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM public.legacy_users",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "legacy_users", Column: "id"},},},})- target := newPGDatabaseMetadata([]*storepb.TableMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},},},- }, []*storepb.ViewMetadata{+ }, []*metadatapb.ViewMetadata{{Name: "v",Definition: "SELECT id FROM public.users",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "users", Column: "id"},},},@@ -760,14 +761,14 @@ func TestPGMetadataDiffDropAlteredViewBeforeDroppedReferencedTable(t *testing.T)}func TestPGMetadataDiffAlterTablePartitionChangesFromMetadata(t *testing.T) {- source := newPGDatabaseMetadata([]*storepb.TableMetadata{- newPGPartitionedOrdersTable([]*storepb.TablePartitionMetadata{+ source := newPGDatabaseMetadata([]*metadatapb.TableMetadata{+ newPGPartitionedOrdersTable([]*metadatapb.TablePartitionMetadata{newPGOrdersPartition("orders_2023", "FOR VALUES FROM ('2023-01-01') TO ('2024-01-01')"),newPGOrdersPartition("orders_2024", "FOR VALUES FROM ('2024-01-01') TO ('2025-01-01')"),}),}, nil)- target := newPGDatabaseMetadata([]*storepb.TableMetadata{- newPGPartitionedOrdersTable([]*storepb.TablePartitionMetadata{+ target := newPGDatabaseMetadata([]*metadatapb.TableMetadata{+ newPGPartitionedOrdersTable([]*metadatapb.TablePartitionMetadata{newPGOrdersPartition("orders_2024", "FOR VALUES FROM ('2024-01-01') TO ('2025-01-01')"),newPGOrdersPartition("orders_2025", "FOR VALUES FROM ('2025-01-01') TO ('2026-01-01')"),}),@@ -788,11 +789,11 @@ func TestPGMetadataDiffAlterTablePartitionChangesFromMetadata(t *testing.T) {func TestPGMetadataDiffCreateViewsInDependencyOrder(t *testing.T) {source := newPGDatabaseMetadata(nil, nil)- target := newPGDatabaseMetadata(nil, []*storepb.ViewMetadata{+ target := newPGDatabaseMetadata(nil, []*metadatapb.ViewMetadata{{Name: "b",Definition: "SELECT * FROM a",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public", Table: "a"},},},@@ -813,26 +814,26 @@ func TestPGMetadataDiffCreateViewsInDependencyOrder(t *testing.T) {}func TestPGMetadataDiffCreateFunctionAfterNewDependencyView(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "active_users",Definition: "SELECT 1 AS id",},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "get_active_users",Signature: "get_active_users()",Definition: "CREATE FUNCTION public.get_active_users() RETURNS SETOF public.active_users LANGUAGE sql AS $$ " +"SELECT * FROM public.active_users $$",- DependencyTables: []*storepb.DependencyTable{+ DependencyTables: []*metadatapb.DependencyTable{{Schema: "public", Table: "active_users"},},},@@ -854,14 +855,14 @@ func TestPGMetadataDiffCreateFunctionAfterNewDependencyView(t *testing.T) {func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.EnumTypeMetadata- target []*storepb.EnumTypeMetadata+ source []*metadatapb.EnumTypeMetadata+ target []*metadatapb.EnumTypeMetadatacontains []string}{{name: "create enum",source: nil,- target: []*storepb.EnumTypeMetadata{+ target: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active", "archived"},@@ -871,7 +872,7 @@ func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {},{name: "drop enum",- source: []*storepb.EnumTypeMetadata{+ source: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active"},@@ -882,13 +883,13 @@ func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {},{name: "append enum value",- source: []*storepb.EnumTypeMetadata{+ source: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active"},},},- target: []*storepb.EnumTypeMetadata{+ target: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active", "archived"},@@ -898,13 +899,13 @@ func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {},{name: "insert enum value before existing value",- source: []*storepb.EnumTypeMetadata{+ source: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active", "archived"},},},- target: []*storepb.EnumTypeMetadata{+ target: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active", "pending", "archived"},@@ -914,13 +915,13 @@ func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {},{name: "removed enum value emits warning",- source: []*storepb.EnumTypeMetadata{+ source: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active", "archived"},},},- target: []*storepb.EnumTypeMetadata{+ target: []*metadatapb.EnumTypeMetadata{{Name: "status",Values: []string{"active"},@@ -948,21 +949,21 @@ func TestPGMetadataDiffEnumObjectChanges(t *testing.T) {func TestPGMetadataDiffSequenceObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.SequenceMetadata- target []*storepb.SequenceMetadata+ source []*metadatapb.SequenceMetadata+ target []*metadatapb.SequenceMetadatacontains []string}{{name: "create sequence",source: nil,- target: []*storepb.SequenceMetadata{+ target: []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),},contains: []string{`CREATE SEQUENCE "public"."order_seq"`, "START WITH 1", "INCREMENT BY 1"},},{name: "drop sequence",- source: []*storepb.SequenceMetadata{+ source: []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),},target: nil,@@ -970,10 +971,10 @@ func TestPGMetadataDiffSequenceObjectChanges(t *testing.T) {},{name: "alter sequence",- source: []*storepb.SequenceMetadata{+ source: []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),},- target: []*storepb.SequenceMetadata{+ target: []*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1004,7 +1005,7 @@ func TestPGMetadataDiffSequenceObjectChanges(t *testing.T) {}func TestPGMetadataDiffAlterSequenceDropsOwnershipFromMetadata(t *testing.T) {- source := newPGDatabaseMetadataWithSequences([]*storepb.SequenceMetadata{+ source := newPGDatabaseMetadataWithSequences([]*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1017,7 +1018,7 @@ func TestPGMetadataDiffAlterSequenceDropsOwnershipFromMetadata(t *testing.T) {OwnerColumn: "id",},})- target := newPGDatabaseMetadataWithSequences([]*storepb.SequenceMetadata{+ target := newPGDatabaseMetadataWithSequences([]*metadatapb.SequenceMetadata{newPGSequenceMetadata(),})@@ -1028,17 +1029,17 @@ func TestPGMetadataDiffAlterSequenceDropsOwnershipFromMetadata(t *testing.T) {}func TestPGMetadataDiffAlterSequenceAttachesOwnershipAfterCreateTable(t *testing.T) {- source := newPGDatabaseMetadataWithTablesAndSequences(nil, []*storepb.SequenceMetadata{+ source := newPGDatabaseMetadataWithTablesAndSequences(nil, []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),})- target := newPGDatabaseMetadataWithTablesAndSequences([]*storepb.TableMetadata{+ target := newPGDatabaseMetadataWithTablesAndSequences([]*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint", Nullable: false},},},- }, []*storepb.SequenceMetadata{+ }, []*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1063,25 +1064,25 @@ func TestPGMetadataDiffAlterSequenceAttachesOwnershipAfterCreateTable(t *testing}func TestPGMetadataDiffAlterSequenceAttachesOwnershipAfterAddColumn(t *testing.T) {- source := newPGDatabaseMetadataWithTablesAndSequences([]*storepb.TableMetadata{+ source := newPGDatabaseMetadataWithTablesAndSequences([]*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "name", Type: "text", Nullable: false},},},- }, []*storepb.SequenceMetadata{+ }, []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),})- target := newPGDatabaseMetadataWithTablesAndSequences([]*storepb.TableMetadata{+ target := newPGDatabaseMetadataWithTablesAndSequences([]*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "name", Type: "text", Nullable: false},{Name: "id", Type: "bigint", Nullable: false},},},- }, []*storepb.SequenceMetadata{+ }, []*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1106,14 +1107,14 @@ func TestPGMetadataDiffAlterSequenceAttachesOwnershipAfterAddColumn(t *testing.T}func TestPGMetadataDiffAlterSequenceDetachesOwnershipBeforeOwnerTableDrop(t *testing.T) {- source := newPGDatabaseMetadataWithTablesAndSequences([]*storepb.TableMetadata{+ source := newPGDatabaseMetadataWithTablesAndSequences([]*metadatapb.TableMetadata{{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "bigint", Nullable: false},},},- }, []*storepb.SequenceMetadata{+ }, []*metadatapb.SequenceMetadata{{Name: "order_seq",DataType: "bigint",@@ -1126,7 +1127,7 @@ func TestPGMetadataDiffAlterSequenceDetachesOwnershipBeforeOwnerTableDrop(t *tesOwnerColumn: "id",},})- target := newPGDatabaseMetadataWithTablesAndSequences(nil, []*storepb.SequenceMetadata{+ target := newPGDatabaseMetadataWithTablesAndSequences(nil, []*metadatapb.SequenceMetadata{newPGSequenceMetadata(),})@@ -1143,21 +1144,21 @@ func TestPGMetadataDiffAlterSequenceDetachesOwnershipBeforeOwnerTableDrop(t *tesfunc TestPGMetadataDiffMaterializedViewObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.MaterializedViewMetadata- target []*storepb.MaterializedViewMetadata+ source []*metadatapb.MaterializedViewMetadata+ target []*metadatapb.MaterializedViewMetadatacontains []string}{{name: "create materialized view",source: nil,- target: []*storepb.MaterializedViewMetadata{+ target: []*metadatapb.MaterializedViewMetadata{{Name: "active_users_mv", Definition: "SELECT @@@active_users@@@"},},contains: []string{`CREATE MATERIALIZED VIEW "public"."active_users_mv" AS`, "SELECT @@@active_users@@@"},},{name: "drop materialized view",- source: []*storepb.MaterializedViewMetadata{+ source: []*metadatapb.MaterializedViewMetadata{{Name: "active_users_mv", Definition: "SELECT @@@active_users@@@"},},target: nil,@@ -1165,10 +1166,10 @@ func TestPGMetadataDiffMaterializedViewObjectChanges(t *testing.T) {},{name: "alter materialized view",- source: []*storepb.MaterializedViewMetadata{+ source: []*metadatapb.MaterializedViewMetadata{{Name: "active_users_mv", Definition: "SELECT @@@old_active_users@@@"},},- target: []*storepb.MaterializedViewMetadata{+ target: []*metadatapb.MaterializedViewMetadata{{Name: "active_users_mv", Definition: "SELECT @@@new_active_users@@@"},},contains: []string{@@ -1197,26 +1198,26 @@ func TestPGMetadataDiffMaterializedViewObjectChanges(t *testing.T) {func TestPGMetadataDiffFunctionObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.FunctionMetadata- target []*storepb.FunctionMetadata+ source []*metadatapb.FunctionMetadata+ target []*metadatapb.FunctionMetadatacontains []string}{{name: "create function",source: nil,- target: []*storepb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},+ target: []*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},contains: []string{"CREATE FUNCTION public.calculate_area()", "SELECT 1"},},{name: "drop function",- source: []*storepb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},+ source: []*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},target: nil,contains: []string{`DROP FUNCTION "public"."calculate_area"()`},},{name: "alter function",- source: []*storepb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},- target: []*storepb.FunctionMetadata{newPGFunctionMetadata("SELECT 2")},+ source: []*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 1")},+ target: []*metadatapb.FunctionMetadata{newPGFunctionMetadata("SELECT 2")},contains: []string{`DROP FUNCTION "public"."calculate_area"()`, "CREATE FUNCTION public.calculate_area()", "SELECT 2"},},}@@ -1239,26 +1240,26 @@ func TestPGMetadataDiffFunctionObjectChanges(t *testing.T) {func TestPGMetadataDiffProcedureObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.ProcedureMetadata- target []*storepb.ProcedureMetadata+ source []*metadatapb.ProcedureMetadata+ target []*metadatapb.ProcedureMetadatacontains []string}{{name: "create procedure",source: nil,- target: []*storepb.ProcedureMetadata{newPGProcedureMetadata("NULL")},+ target: []*metadatapb.ProcedureMetadata{newPGProcedureMetadata("NULL")},contains: []string{"CREATE PROCEDURE public.refresh_stats()", "NULL"},},{name: "drop procedure",- source: []*storepb.ProcedureMetadata{newPGProcedureMetadata("NULL")},+ source: []*metadatapb.ProcedureMetadata{newPGProcedureMetadata("NULL")},target: nil,contains: []string{`DROP PROCEDURE "public"."refresh_stats"()`},},{name: "alter procedure",- source: []*storepb.ProcedureMetadata{newPGProcedureMetadata("NULL")},- target: []*storepb.ProcedureMetadata{newPGProcedureMetadata("RAISE NOTICE 'refresh'")},+ source: []*metadatapb.ProcedureMetadata{newPGProcedureMetadata("NULL")},+ target: []*metadatapb.ProcedureMetadata{newPGProcedureMetadata("RAISE NOTICE 'refresh'")},contains: []string{`DROP PROCEDURE "public"."refresh_stats"()`, "CREATE PROCEDURE public.refresh_stats()", "RAISE NOTICE 'refresh'"},},}@@ -1281,39 +1282,39 @@ func TestPGMetadataDiffProcedureObjectChanges(t *testing.T) {func TestPGMetadataDiffSchemaObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.SchemaMetadata- target []*storepb.SchemaMetadata+ source []*metadatapb.SchemaMetadata+ target []*metadatapb.SchemaMetadatacontains []string}{{name: "create schema",- source: []*storepb.SchemaMetadata{{Name: "public"}},- target: []*storepb.SchemaMetadata{{Name: "public"}, {Name: "analytics"}},+ source: []*metadatapb.SchemaMetadata{{Name: "public"}},+ target: []*metadatapb.SchemaMetadata{{Name: "public"}, {Name: "analytics"}},contains: []string{`CREATE SCHEMA IF NOT EXISTS "analytics"`,},},{name: "drop schema",- source: []*storepb.SchemaMetadata{+ source: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "analytics",- Tables: []*storepb.TableMetadata{- {Name: "events", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "events", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false}}},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "event_ids", Definition: "SELECT id FROM analytics.events"},},- Sequences: []*storepb.SequenceMetadata{+ Sequences: []*metadatapb.SequenceMetadata{{Name: "event_id_seq", DataType: "bigint"},},- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "event_status", Values: []string{"active"}},},},},- target: []*storepb.SchemaMetadata{{Name: "public"}},+ target: []*metadatapb.SchemaMetadata{{Name: "public"}},contains: []string{`DROP VIEW "analytics"."event_ids"`,`DROP TABLE "analytics"."events"`,@@ -1324,7 +1325,7 @@ func TestPGMetadataDiffSchemaObjectChanges(t *testing.T) {},{name: "drop public schema is ignored",- source: []*storepb.SchemaMetadata{{Name: "public"}},+ source: []*metadatapb.SchemaMetadata{{Name: "public"}},target: nil,},}@@ -1349,26 +1350,26 @@ func TestPGMetadataDiffSchemaObjectChanges(t *testing.T) {func TestPGMetadataDiffExtensionObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.ExtensionMetadata- target []*storepb.ExtensionMetadata+ source []*metadatapb.ExtensionMetadata+ target []*metadatapb.ExtensionMetadatacontains []string}{{name: "create extension",source: nil,- target: []*storepb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},+ target: []*metadatapb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},contains: []string{`CREATE EXTENSION IF NOT EXISTS "pg_trgm"`},},{name: "drop extension",- source: []*storepb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},+ source: []*metadatapb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},target: nil,contains: []string{`DROP EXTENSION "pg_trgm"`},},{name: "recreate changed extension",- source: []*storepb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.5"}},- target: []*storepb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},+ source: []*metadatapb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.5"}},+ target: []*metadatapb.ExtensionMetadata{{Name: "pg_trgm", Schema: "public", Version: "1.6"}},contains: []string{`DROP EXTENSION "pg_trgm"`, `CREATE EXTENSION IF NOT EXISTS "pg_trgm"`},},}@@ -1391,21 +1392,21 @@ func TestPGMetadataDiffExtensionObjectChanges(t *testing.T) {func TestPGMetadataDiffEventTriggerObjectChanges(t *testing.T) {tests := []struct {name string- source []*storepb.EventTriggerMetadata- target []*storepb.EventTriggerMetadata+ source []*metadatapb.EventTriggerMetadata+ target []*metadatapb.EventTriggerMetadatacontains []string}{{name: "create event trigger",source: nil,- target: []*storepb.EventTriggerMetadata{+ target: []*metadatapb.EventTriggerMetadata{newPGEventTriggerMetadata("ddl_command_end"),},contains: []string{`CREATE EVENT TRIGGER "audit_ddl" ON ddl_command_end`},},{name: "drop event trigger",- source: []*storepb.EventTriggerMetadata{+ source: []*metadatapb.EventTriggerMetadata{newPGEventTriggerMetadata("ddl_command_end"),},target: nil,@@ -1413,10 +1414,10 @@ func TestPGMetadataDiffEventTriggerObjectChanges(t *testing.T) {},{name: "recreate changed event trigger",- source: []*storepb.EventTriggerMetadata{+ source: []*metadatapb.EventTriggerMetadata{newPGEventTriggerMetadata("ddl_command_start"),},- target: []*storepb.EventTriggerMetadata{+ target: []*metadatapb.EventTriggerMetadata{newPGEventTriggerMetadata("ddl_command_end"),},contains: []string{`DROP EVENT TRIGGER "audit_ddl"`, `CREATE EVENT TRIGGER "audit_ddl" ON ddl_command_end`},@@ -1439,7 +1440,7 @@ func TestPGMetadataDiffEventTriggerObjectChanges(t *testing.T) {}func newPGDatabaseMetadataWithView(definition string) *model.DatabaseMetadata {- return newPGDatabaseMetadata(nil, []*storepb.ViewMetadata{+ return newPGDatabaseMetadata(nil, []*metadatapb.ViewMetadata{{Name: "v",Definition: definition,@@ -1447,9 +1448,9 @@ func newPGDatabaseMetadataWithView(definition string) *model.DatabaseMetadata {})}-func newPGDatabaseMetadataWithEnum(enumTypes []*storepb.EnumTypeMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newPGDatabaseMetadataWithEnum(enumTypes []*metadatapb.EnumTypeMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",EnumTypes: enumTypes,@@ -1458,28 +1459,28 @@ func newPGDatabaseMetadataWithEnum(enumTypes []*storepb.EnumTypeMetadata) *model}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGDatabaseMetadataWithSchemas(schemas []*storepb.SchemaMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+func newPGDatabaseMetadataWithSchemas(schemas []*metadatapb.SchemaMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Schemas: schemas,}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGDatabaseMetadataWithExtensions(extensions []*storepb.ExtensionMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+func newPGDatabaseMetadataWithExtensions(extensions []*metadatapb.ExtensionMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},Extensions: extensions,}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGDatabaseMetadataWithEventTriggers(eventTriggers []*storepb.EventTriggerMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+func newPGDatabaseMetadataWithEventTriggers(eventTriggers []*metadatapb.EventTriggerMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},EventTriggers: eventTriggers,}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGEventTriggerMetadata(event string) *storepb.EventTriggerMetadata {- return &storepb.EventTriggerMetadata{+func newPGEventTriggerMetadata(event string) *metadatapb.EventTriggerMetadata {+ return &metadatapb.EventTriggerMetadata{Name: "audit_ddl",Event: event,FunctionSchema: "public",@@ -1488,9 +1489,9 @@ func newPGEventTriggerMetadata(event string) *storepb.EventTriggerMetadata {}}-func newPGDatabaseMetadataWithRoutines(functions []*storepb.FunctionMetadata, procedures []*storepb.ProcedureMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newPGDatabaseMetadataWithRoutines(functions []*metadatapb.FunctionMetadata, procedures []*metadatapb.ProcedureMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",Functions: functions,@@ -1500,8 +1501,8 @@ func newPGDatabaseMetadataWithRoutines(functions []*storepb.FunctionMetadata, pr}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGFunctionMetadata(body string) *storepb.FunctionMetadata {- return &storepb.FunctionMetadata{+func newPGFunctionMetadata(body string) *metadatapb.FunctionMetadata {+ return &metadatapb.FunctionMetadata{Name: "calculate_area",Signature: "calculate_area()",Definition: "CREATE FUNCTION public.calculate_area() RETURNS integer LANGUAGE sql AS $$ " +@@ -1509,8 +1510,8 @@ func newPGFunctionMetadata(body string) *storepb.FunctionMetadata {}}-func newPGProcedureMetadata(body string) *storepb.ProcedureMetadata {- return &storepb.ProcedureMetadata{+func newPGProcedureMetadata(body string) *metadatapb.ProcedureMetadata {+ return &metadatapb.ProcedureMetadata{Name: "refresh_stats",Signature: "refresh_stats()",Definition: "CREATE PROCEDURE public.refresh_stats() LANGUAGE plpgsql AS $$ BEGIN " +@@ -1518,9 +1519,9 @@ func newPGProcedureMetadata(body string) *storepb.ProcedureMetadata {}}-func newCockroachDatabaseMetadataWithFunctions(functions []*storepb.FunctionMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newCockroachDatabaseMetadataWithFunctions(functions []*metadatapb.FunctionMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",Functions: functions,@@ -1531,17 +1532,17 @@ func newCockroachDatabaseMetadataWithFunctions(functions []*storepb.FunctionMetatype alwaysEqualFunctionComparer struct{}-func (*alwaysEqualFunctionComparer) Equal(*storepb.FunctionMetadata, *storepb.FunctionMetadata) bool {+func (*alwaysEqualFunctionComparer) Equal(*metadatapb.FunctionMetadata, *metadatapb.FunctionMetadata) bool {return true}-func (*alwaysEqualFunctionComparer) CompareDetailed(*storepb.FunctionMetadata, *storepb.FunctionMetadata) (*schema.FunctionComparisonResult, error) {+func (*alwaysEqualFunctionComparer) CompareDetailed(*metadatapb.FunctionMetadata, *metadatapb.FunctionMetadata) (*schema.FunctionComparisonResult, error) {return nil, nil}-func newPGDatabaseMetadataWithMaterializedViews(views []*storepb.MaterializedViewMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newPGDatabaseMetadataWithMaterializedViews(views []*metadatapb.MaterializedViewMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",MaterializedViews: views,@@ -1550,13 +1551,13 @@ func newPGDatabaseMetadataWithMaterializedViews(views []*storepb.MaterializedVie}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGDatabaseMetadataWithSequences(sequences []*storepb.SequenceMetadata) *model.DatabaseMetadata {+func newPGDatabaseMetadataWithSequences(sequences []*metadatapb.SequenceMetadata) *model.DatabaseMetadata {return newPGDatabaseMetadataWithTablesAndSequences(nil, sequences)}-func newPGDatabaseMetadataWithTablesAndSequences(tables []*storepb.TableMetadata, sequences []*storepb.SequenceMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newPGDatabaseMetadataWithTablesAndSequences(tables []*metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",Tables: tables,@@ -1566,8 +1567,8 @@ func newPGDatabaseMetadataWithTablesAndSequences(tables []*storepb.TableMetadata}, nil, nil, storepb.Engine_POSTGRES, true)}-func newPGSequenceMetadata() *storepb.SequenceMetadata {- return &storepb.SequenceMetadata{+func newPGSequenceMetadata() *metadatapb.SequenceMetadata {+ return &metadatapb.SequenceMetadata{Name: "order_seq",DataType: "bigint",Start: "1",@@ -1578,10 +1579,10 @@ func newPGSequenceMetadata() *storepb.SequenceMetadata {}}-func newPGPartitionedOrdersTable(partitions []*storepb.TablePartitionMetadata) *storepb.TableMetadata {- return &storepb.TableMetadata{+func newPGPartitionedOrdersTable(partitions []*metadatapb.TablePartitionMetadata) *metadatapb.TableMetadata {+ return &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Nullable: false},{Name: "created_at", Type: "date", Nullable: false},},@@ -1589,22 +1590,22 @@ func newPGPartitionedOrdersTable(partitions []*storepb.TablePartitionMetadata) *}}-func newPGOrdersPartition(name string, value string) *storepb.TablePartitionMetadata {- return &storepb.TablePartitionMetadata{+func newPGOrdersPartition(name string, value string) *metadatapb.TablePartitionMetadata {+ return &metadatapb.TablePartitionMetadata{Name: name,- Type: storepb.TablePartitionMetadata_RANGE,+ Type: metadatapb.TablePartitionMetadata_RANGE,Expression: "RANGE (created_at)",Value: value,}}-func newPGDatabaseMetadata(tables []*storepb.TableMetadata, views []*storepb.ViewMetadata) *model.DatabaseMetadata {+func newPGDatabaseMetadata(tables []*metadatapb.TableMetadata, views []*metadatapb.ViewMetadata) *model.DatabaseMetadata {return newDatabaseMetadataWithEngine(storepb.Engine_POSTGRES, tables, views)}-func newDatabaseMetadataWithEngine(engine storepb.Engine, tables []*storepb.TableMetadata, views []*storepb.ViewMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newDatabaseMetadataWithEngine(engine storepb.Engine, tables []*metadatapb.TableMetadata, views []*metadatapb.ViewMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",Tables: tables,@@ -1614,9 +1615,9 @@ func newDatabaseMetadataWithEngine(engine storepb.Engine, tables []*storepb.Tabl}, nil, nil, engine, true)}-func newPGDatabaseMetadataWithCompositeTypes(compositeTypes []*storepb.CompositeTypeMetadata) *model.DatabaseMetadata {- return model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func newPGDatabaseMetadataWithCompositeTypes(compositeTypes []*metadatapb.CompositeTypeMetadata) *model.DatabaseMetadata {+ return model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",CompositeTypes: compositeTypes,@@ -1628,17 +1629,17 @@ func newPGDatabaseMetadataWithCompositeTypes(compositeTypes []*storepb.Compositefunc TestPGMetadataDiffCreateCompositeTypesInDependencyOrder(t *testing.T) {source := newPGDatabaseMetadataWithCompositeTypes(nil)// aa_nested sorts before zz_base alphabetically but depends on it.- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "aa_nested",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "home", Type: "public.zz_base"},},},{Name: "zz_base",Comment: "base type",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Collation: `"C"`, Comment: "street line"},},},@@ -1659,16 +1660,16 @@ func TestPGMetadataDiffCreateCompositeTypesInDependencyOrder(t *testing.T) {}func TestPGMetadataDiffDropCompositeTypesInReverseDependencyOrder(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "zz_base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},{Name: "aa_nested",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "home", Type: "public.zz_base"},},},@@ -1687,17 +1688,17 @@ func TestPGMetadataDiffDropCompositeTypesInReverseDependencyOrder(t *testing.T)}func TestPGMetadataDiffCompositeDropsPrecedeEnumDrops(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a", "b"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "uses_status",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "s", Type: "public.status"},},},@@ -1717,20 +1718,20 @@ func TestPGMetadataDiffCompositeDropsPrecedeEnumDrops(t *testing.T) {}func TestPGMetadataDiffAlterCompositeTypeAttributes(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},{Name: "city", Type: "character varying(50)"},{Name: "dropped_attr", Type: "integer"},},},})- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},{Name: "city", Type: "character varying(100)"},{Name: "zip", Type: "text", Collation: `"C"`},@@ -1748,19 +1749,19 @@ func TestPGMetadataDiffAlterCompositeTypeAttributes(t *testing.T) {}func TestPGMetadataDiffCompositeTypeReorderOnlyWarns(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "a", Type: "text"},{Name: "b", Type: "integer"},},},})- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "integer"},{Name: "a", Type: "text"},},@@ -1776,20 +1777,20 @@ func TestPGMetadataDiffCompositeTypeReorderOnlyWarns(t *testing.T) {}func TestPGMetadataDiffCompositeTypeCommentChanges(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",Comment: "old type comment",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Comment: "old attr comment"},},},})- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",Comment: "new type comment",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Comment: "new attr comment"},},},@@ -1804,11 +1805,11 @@ func TestPGMetadataDiffCompositeTypeCommentChanges(t *testing.T) {}func TestPGMetadataDiffIdenticalCompositeTypesProduceNoMigration(t *testing.T) {- composites := []*storepb.CompositeTypeMetadata{+ composites := []*metadatapb.CompositeTypeMetadata{{Name: "addr",Comment: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Collation: `"C"`, Comment: "s"},},},@@ -1823,22 +1824,22 @@ func TestPGMetadataDiffIdenticalCompositeTypesProduceNoMigration(t *testing.T) {}func TestPGMetadataDiffCompositeDropDeferredAfterColumnRetype(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "public.addr", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -1846,14 +1847,14 @@ func TestPGMetadataDiffCompositeDropDeferredAfterColumnRetype(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -1874,15 +1875,15 @@ func TestPGMetadataDiffCompositeDropDeferredAfterColumnRetype(t *testing.T) {}func TestPGMetadataDiffSchemaDropIncludesCompositeTypes(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -1890,8 +1891,8 @@ func TestPGMetadataDiffSchemaDropIncludesCompositeTypes(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}, nil, nil, storepb.Engine_POSTGRES, true)@@ -1907,19 +1908,19 @@ func TestPGMetadataDiffSchemaDropIncludesCompositeTypes(t *testing.T) {}func TestPGMetadataDiffCompositeTypeMiddleInsertWarns(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "a", Type: "text"},{Name: "b", Type: "text"},},},})- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "a", Type: "text"},{Name: "x", Type: "text"},{Name: "b", Type: "text"},@@ -1936,25 +1937,25 @@ func TestPGMetadataDiffCompositeTypeMiddleInsertWarns(t *testing.T) {}func TestPGMetadataDiffDeferredCompositeDefersReferencedEnumDrop(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "public.addr", Nullable: true},},},},- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a", "b"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "s", Type: "public.status"},},},@@ -1962,14 +1963,14 @@ func TestPGMetadataDiffDeferredCompositeDefersReferencedEnumDrop(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -1992,14 +1993,14 @@ func TestPGMetadataDiffDeferredCompositeDefersReferencedEnumDrop(t *testing.T) {}func TestPGMetadataDiffSchemaDropDeferredWhenCompositeReleasedByRetype(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "s.addr", Nullable: true},},},@@ -2007,10 +2008,10 @@ func TestPGMetadataDiffSchemaDropDeferredWhenCompositeReleasedByRetype(t *testin},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -2018,14 +2019,14 @@ func TestPGMetadataDiffSchemaDropDeferredWhenCompositeReleasedByRetype(t *testin},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2050,22 +2051,22 @@ func TestPGMetadataDiffSchemaDropDeferredWhenCompositeReleasedByRetype(t *testinfunc TestPGMetadataDiffSchemaDropDeferredWhenDeferredCompositeReferencesItsEnum(t *testing.T) {// public.addr is deferred (public.t.c retyped away from it) and references// s.status; schema s (containing only that enum) must defer its drop too.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "public.addr", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "st", Type: "s.status"},},},@@ -2073,20 +2074,20 @@ func TestPGMetadataDiffSchemaDropDeferredWhenDeferredCompositeReferencesItsEnum(},{Name: "s",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a"}},},},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2112,28 +2113,28 @@ func TestPGMetadataDiffDeferredSchemaCompositeDefersReferencedEnumDrop(t *testin// Schema s is deferred (public.t.c retyped away from s.addr); s.addr// references public.status, a top-level dropped enum, which therefore// must also defer until after the schema drop removes s.addr.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "s.addr", Nullable: true},},},},- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a"}},},},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "st", Type: "public.status"},},},@@ -2141,14 +2142,14 @@ func TestPGMetadataDiffDeferredSchemaCompositeDefersReferencedEnumDrop(t *testin},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2176,14 +2177,14 @@ func TestPGMetadataDiffCyclicDeferredSchemaDropsGlobalizeTypeDrops(t *testing.T)// Both are deferred (a column retype releases a.ca). Globalized type// drops must remove both composites before either enum, regardless of// the schema-level cycle.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "a.ca", Nullable: true},},},@@ -2191,13 +2192,13 @@ func TestPGMetadataDiffCyclicDeferredSchemaDropsGlobalizeTypeDrops(t *testing.T)},{Name: "a",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "ea", Values: []string{"x"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "ca",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "v", Type: "b.eb"},},},@@ -2205,13 +2206,13 @@ func TestPGMetadataDiffCyclicDeferredSchemaDropsGlobalizeTypeDrops(t *testing.T)},{Name: "b",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "eb", Values: []string{"y"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "cb",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "v", Type: "a.ea"},},},@@ -2219,14 +2220,14 @@ func TestPGMetadataDiffCyclicDeferredSchemaDropsGlobalizeTypeDrops(t *testing.T)},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2258,17 +2259,17 @@ func TestPGMetadataDiffImmediateSchemaDropOrdersTypesGlobally(t *testing.T) {// Dropping schema s (whose composite references top-level types) together// with those top-level types: s.child must drop before public.base and// public.status regardless of the schema-drop boundary.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},@@ -2276,10 +2277,10 @@ func TestPGMetadataDiffImmediateSchemaDropOrdersTypesGlobally(t *testing.T) {},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "child",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "public.base"},{Name: "st", Type: "public.status"},},@@ -2288,8 +2289,8 @@ func TestPGMetadataDiffImmediateSchemaDropOrdersTypesGlobally(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}, nil, nil, storepb.Engine_POSTGRES, true)@@ -2313,39 +2314,39 @@ func TestPGMetadataDiffImmediateSchemaDropOrdersTypesGlobally(t *testing.T) {func TestPGMetadataDiffCompositeCreateWaitsForTableRowType(t *testing.T) {// Creating table t and composites c1(public.t) and c2(c1): both// composites must be created after the table.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c1",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "public.t"},},},{Name: "c2",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "w", Type: "public.c1"},},},{Name: "plain",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},@@ -2373,28 +2374,28 @@ func TestPGMetadataDiffCompositeCreateWaitsForTableRowType(t *testing.T) {func TestPGMetadataDiffDeferredCompositeDefersItsCompositeDependency(t *testing.T) {// child(public.base) is deferred by a column retype; base, also dropped,// must defer too so it drops after child.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "public.child", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},{Name: "child",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "public.base"},},},@@ -2402,14 +2403,14 @@ func TestPGMetadataDiffDeferredCompositeDefersItsCompositeDependency(t *testing.},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2434,22 +2435,22 @@ func TestPGMetadataDiffDeferredCompositeDefersItsCompositeDependency(t *testing.func TestPGMetadataDiffRowTypeCompositeDropsBeforeTable(t *testing.T) {// Dropping table t and composite c(r public.t): the composite must drop// before the table whose row type it references.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "public.t"},},},@@ -2457,8 +2458,8 @@ func TestPGMetadataDiffRowTypeCompositeDropsBeforeTable(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}, nil, nil, storepb.Engine_POSTGRES, true)@@ -2476,30 +2477,30 @@ func TestPGMetadataDiffRowTypeCompositeDropsBeforeTable(t *testing.T) {func TestPGMetadataDiffCompositeAlterWaitsForNewTableRowType(t *testing.T) {// Existing composite gains an attribute typed with a row type of a table// created in the same migration; the alter must follow CREATE TABLE.- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},})- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},{Name: "r", Type: "public.t"},},@@ -2522,31 +2523,31 @@ func TestPGMetadataDiffCompositeAlterWaitsForNewTableRowType(t *testing.T) {func TestPGMetadataDiffCreateSandwichTableCompositeTable(t *testing.T) {// r (row-type provider) -> c (composite using r) -> holder (table using c):// creation order must interleave through the shared graph.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "r",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},{Name: "holder",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "x", Type: "public.c", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "public.r"},},},@@ -2571,28 +2572,28 @@ func TestPGMetadataDiffCreateSandwichTableCompositeTable(t *testing.T) {func TestPGMetadataDiffDropSandwichTableCompositeTable(t *testing.T) {// holder (table using c) -> c (composite using r) -> r: drop order must// interleave through the shared graph.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "r",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},{Name: "holder",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "x", Type: "public.c", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "public.r"},},},@@ -2600,8 +2601,8 @@ func TestPGMetadataDiffDropSandwichTableCompositeTable(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)sql, err := schema.DiffMigration(storepb.Engine_POSTGRES, source, target)@@ -2620,22 +2621,22 @@ func TestPGMetadataDiffDropSandwichTableCompositeTable(t *testing.T) {func TestPGMetadataDiffDeferredSchemaCompositeDefersTopLevelDependency(t *testing.T) {// Schema s is deferred (retype releases s.child); s.child references// top-level dropped public.base, which must defer too.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "s.child", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "base",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},@@ -2643,10 +2644,10 @@ func TestPGMetadataDiffDeferredSchemaCompositeDefersTopLevelDependency(t *testin},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "child",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "b", Type: "public.base"},},},@@ -2654,14 +2655,14 @@ func TestPGMetadataDiffDeferredSchemaCompositeDefersTopLevelDependency(t *testin},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "c", Type: "text", Nullable: true},},},@@ -2687,23 +2688,23 @@ func TestPGMetadataDiffCompositeDropDeferredAfterColumnDrop(t *testing.T) {// Dropping the only column using a composite (on a surviving table)// releases it in writeDropAlterTableObjects; the composite drop must// defer past that.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "c", Type: "public.addr", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -2711,14 +2712,14 @@ func TestPGMetadataDiffCompositeDropDeferredAfterColumnDrop(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},@@ -2741,22 +2742,22 @@ func TestPGMetadataDiffCompositeDropDeferredAfterColumnDrop(t *testing.T) {func TestPGMetadataDiffReleasingCompositeAlterPrecedesTableDrop(t *testing.T) {// Retyping c.r away from public.t's row type releases the dropped table;// the releasing ALTER must precede DROP TABLE.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "public.t"},},},@@ -2764,14 +2765,14 @@ func TestPGMetadataDiffReleasingCompositeAlterPrecedesTableDrop(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "text"},},},@@ -2795,25 +2796,25 @@ func TestPGMetadataDiffCompositeArrayColumnOrdersCreate(t *testing.T) {// Column sync renders composite-array columns as the bare "_name" form;// the create graph must still order the composite first. zz table name// sorts after the composite to defeat accidental ordering.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "aa_holder",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "xs", Type: "_zz_addr", Nullable: true},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "zz_addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -2833,15 +2834,15 @@ func TestPGMetadataDiffCompositeArrayColumnOrdersCreate(t *testing.T) {}func TestPGMetadataDiffSchemaDropEmitsCompositeDropOnce(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "s",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text"},},},@@ -2849,8 +2850,8 @@ func TestPGMetadataDiffSchemaDropEmitsCompositeDropOnce(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)sql, err := schema.DiffMigration(storepb.Engine_POSTGRES, source, target)@@ -2864,22 +2865,22 @@ func TestPGMetadataDiffReleasingRetypeToCreatedTableSplitsDropReadd(t *testing.T// c.r moves from dropped old_t's row type to created new_t's row type:// the drop phase removes the attribute, the create phase re-adds it// after the new table exists.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "old_t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "public.old_t"},},},@@ -2887,22 +2888,22 @@ func TestPGMetadataDiffReleasingRetypeToCreatedTableSplitsDropReadd(t *testing.T},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "new_t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},},},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "r", Type: "public.new_t"},},},@@ -2928,20 +2929,20 @@ func TestPGMetadataDiffReleasingRetypeToCreatedTableSplitsDropReadd(t *testing.T}func TestPGMetadataDiffCompositeCreateWaitsForViewRowType(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v", Definition: "SELECT 1 AS a"},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "public.v"},},},@@ -2963,24 +2964,24 @@ func TestPGMetadataDiffCompositeCreateWaitsForViewRowType(t *testing.T) {func TestPGMetadataDiffCompositeDropReleasedByCompositeAlterDefers(t *testing.T) {// parent's alter (child -> text) releases dropped child only in the// create phase, so child's drop must defer past it.- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "child",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},{Name: "parent",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "c", Type: "public.child"},},},})- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "parent",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "c", Type: "text"},},},@@ -2997,17 +2998,17 @@ func TestPGMetadataDiffCompositeDropReleasedByCompositeAlterDefers(t *testing.T)}func TestPGMetadataDiffEnumDropReleasedByCompositeAlterDefers(t *testing.T) {- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "s", Type: "public.status"},},},@@ -3015,10 +3016,10 @@ func TestPGMetadataDiffEnumDropReleasedByCompositeAlterDefers(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "addr",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "s", Type: "text"},},},@@ -3037,17 +3038,17 @@ func TestPGMetadataDiffEnumDropReleasedByCompositeAlterDefers(t *testing.T) {func TestPGMetadataDiffReleasingAlterPrecedesViewDrop(t *testing.T) {// c.row moves off dropped view v's row type; the early alter must// precede DROP VIEW.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v", Definition: "SELECT 1 AS a"},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "public.v"},},},@@ -3055,10 +3056,10 @@ func TestPGMetadataDiffReleasingAlterPrecedesViewDrop(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ target := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "text"},},},@@ -3075,25 +3076,25 @@ func TestPGMetadataDiffReleasingAlterPrecedesViewDrop(t *testing.T) {}func TestPGMetadataDiffCompositeAlterWaitsForCreatedViewRowType(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},})- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v", Definition: "SELECT 1 AS a"},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},{Name: "row", Type: "public.v"},},@@ -3116,17 +3117,17 @@ func TestPGMetadataDiffCompositeAlterWaitsForCreatedViewRowType(t *testing.T) {func TestPGMetadataDiffCompositeDropPrecedesReferencedViewDrop(t *testing.T) {// Dropping both c(row public.v) and v: the composite must drop first// despite the blanket views-before-composites edges.- source := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ source := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v", Definition: "SELECT 1 AS a"},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "c",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "row", Type: "public.v"},},},@@ -3134,8 +3135,8 @@ func TestPGMetadataDiffCompositeDropPrecedesReferencedViewDrop(t *testing.T) {},},}, nil, nil, storepb.Engine_POSTGRES, true)- target := model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{{Name: "public"}},+ target := model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"}},}, nil, nil, storepb.Engine_POSTGRES, true)sql, err := schema.DiffMigration(storepb.Engine_POSTGRES, source, target)@@ -3163,11 +3164,11 @@ func TestFilterPostgresArchiveSchemaKeepsCompositeTypes(t *testing.T) {}func TestPGMetadataDiffSkipDumpCompositeTypesIgnored(t *testing.T) {- source := newPGDatabaseMetadataWithCompositeTypes([]*storepb.CompositeTypeMetadata{+ source := newPGDatabaseMetadataWithCompositeTypes([]*metadatapb.CompositeTypeMetadata{{Name: "ext_owned",SkipDump: true,- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},diff --git a/backend/plugin/schema/pg/sdl_migration_test.go b/backend/plugin/schema/pg/sdl_migration_test.goindex 065f0c8094..f3834f017c 100644--- a/backend/plugin/schema/pg/sdl_migration_test.go+++ b/backend/plugin/schema/pg/sdl_migration_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/catalog""github.com/stretchr/testify/require"@@ -438,18 +439,18 @@ func TestOmniSDLMigration_MultipleChanges(t *testing.T) {// bbdataarchive schema are excluded from migration output.func TestOmniFilter_BbdataarchiveSchemaFiltered(t *testing.T) {// Source has tables in both public and bbdataarchive schemas.- sourceMetadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ sourceMetadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{- {Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},{Name: "bbdataarchive",- Tables: []*storepb.TableMetadata{- {Name: "archived_users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "archived_users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},},@@ -474,18 +475,18 @@ func TestOmniFilter_BbdataarchiveSchemaFiltered(t *testing.T) {// TestOmniFilter_SkipBackupSchemaInSDLGeneration verifies that MetadataToSDL// excludes the backup schema entirely from generated SDL text.func TestOmniFilter_SkipBackupSchemaInSDLGeneration(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{- {Name: "t1", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "t1", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},{Name: "bbdataarchive",- Tables: []*storepb.TableMetadata{- {Name: "backup_t1", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "backup_t1", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},},@@ -503,15 +504,15 @@ func TestOmniFilter_SkipBackupSchemaInSDLGeneration(t *testing.T) {// TestOmniFilter_SkipDumpObjectsExcluded verifies that objects marked with// SkipDump (e.g., extension-created objects) are excluded from SDL generation.func TestOmniFilter_SkipDumpObjectsExcluded(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{- {Name: "user_table", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},- {Name: "ext_table", SkipDump: true, Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "user_table", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ {Name: "ext_table", SkipDump: true, Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},- Functions: []*storepb.FunctionMetadata{+ Functions: []*metadatapb.FunctionMetadata{{Name: "my_func", Definition: "CREATE FUNCTION my_func() RETURNS void LANGUAGE sql AS $$ SELECT 1 $$;"},{Name: "ext_func", SkipDump: true, Definition: "CREATE FUNCTION ext_func() RETURNS void LANGUAGE sql AS $$ SELECT 1 $$;"},},@@ -541,18 +542,18 @@ func TestOmniFilter_ExtensionPreservedWhenArchiveFiltered(t *testing.T) {// schemas with backup objects produce no migration (backup objects are// excluded from both sides consistently).func TestOmniFilter_NoChangesForIdenticalSchemas(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{- {Name: "users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},{Name: "bbdataarchive",- Tables: []*storepb.TableMetadata{- {Name: "old_users", Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}}},+ Tables: []*metadatapb.TableMetadata{+ {Name: "old_users", Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}}},},},},diff --git a/backend/plugin/schema/pg/walk_through.go b/backend/plugin/schema/pg/walk_through.goindex 20008eced5..6ab8e9a42f 100644--- a/backend/plugin/schema/pg/walk_through.go+++ b/backend/plugin/schema/pg/walk_through.go@@ -3,6 +3,7 @@ package pgimport ("context"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/catalog"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -176,15 +177,15 @@ func getConfiguredSearchPath(d *model.DatabaseMetadata) []string {return searchPath}-// relationToTableProto converts an omni Relation to a storepb.TableMetadata.-func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.TableMetadata {- table := &storepb.TableMetadata{+// relationToTableProto converts an omni Relation to a metadatapb.TableMetadata.+func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *metadatapb.TableMetadata {+ table := &metadatapb.TableMetadata{Name: rel.Name,}// Columns.for _, col := range rel.Columns {- colMeta := &storepb.ColumnMetadata{+ colMeta := &metadatapb.ColumnMetadata{Name: col.Name,Position: int32(col.AttNum),Type: c.FormatType(col.TypeOID, col.TypeMod),@@ -192,8 +193,8 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.TaDefault: col.Default,}if col.Generated == 's' {- colMeta.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ colMeta.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: col.GenerationExpr,}}@@ -201,9 +202,9 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.TacolMeta.IsIdentity = trueswitch col.Identity {case 'a':- colMeta.IdentityGeneration = storepb.ColumnMetadata_ALWAYS+ colMeta.IdentityGeneration = metadatapb.ColumnMetadata_ALWAYScase 'd':- colMeta.IdentityGeneration = storepb.ColumnMetadata_BY_DEFAULT+ colMeta.IdentityGeneration = metadatapb.ColumnMetadata_BY_DEFAULTdefault:}}@@ -212,7 +213,7 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.Ta// Indexes.for _, idx := range c.IndexesOf(rel.OID) {- idxMeta := &storepb.IndexMetadata{+ idxMeta := &metadatapb.IndexMetadata{Name: idx.Name,Type: idx.AccessMethod,Unique: idx.IsUnique,@@ -258,7 +259,7 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.Tafor _, con := range c.ConstraintsOf(rel.OID) {switch con.Type {case 'f': // FK- fk := &storepb.ForeignKeyMetadata{+ fk := &metadatapb.ForeignKeyMetadata{Name: con.Name,}// Columns.@@ -292,12 +293,12 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.Tafk.MatchType = wtFKMatchToString(con.FKMatchType)table.ForeignKeys = append(table.ForeignKeys, fk)case 'c': // CHECK- table.CheckConstraints = append(table.CheckConstraints, &storepb.CheckConstraintMetadata{+ table.CheckConstraints = append(table.CheckConstraints, &metadatapb.CheckConstraintMetadata{Name: con.Name,Expression: con.CheckExpr,})case 'x': // EXCLUDE- table.ExcludeConstraints = append(table.ExcludeConstraints, &storepb.ExcludeConstraintMetadata{+ table.ExcludeConstraints = append(table.ExcludeConstraints, &metadatapb.ExcludeConstraintMetadata{Name: con.Name,Expression: con.CheckExpr,})@@ -308,9 +309,9 @@ func relationToTableProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.Tareturn table}-// relationToViewProto converts an omni Relation (view) to a storepb.ViewMetadata.-func relationToViewProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.ViewMetadata {- view := &storepb.ViewMetadata{+// relationToViewProto converts an omni Relation (view) to a metadatapb.ViewMetadata.+func relationToViewProto(c *catalog.Catalog, rel *catalog.Relation) *metadatapb.ViewMetadata {+ view := &metadatapb.ViewMetadata{Name: rel.Name,}if rel.Schema != nil {@@ -321,9 +322,9 @@ func relationToViewProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.Viereturn view}-// relationToMatViewProto converts an omni Relation (materialized view) to a storepb.MaterializedViewMetadata.-func relationToMatViewProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.MaterializedViewMetadata {- mv := &storepb.MaterializedViewMetadata{+// relationToMatViewProto converts an omni Relation (materialized view) to a metadatapb.MaterializedViewMetadata.+func relationToMatViewProto(c *catalog.Catalog, rel *catalog.Relation) *metadatapb.MaterializedViewMetadata {+ mv := &metadatapb.MaterializedViewMetadata{Name: rel.Name,}if rel.Schema != nil {@@ -334,7 +335,7 @@ func relationToMatViewProto(c *catalog.Catalog, rel *catalog.Relation) *storepb.// Materialized view indexes.for _, idx := range c.IndexesOf(rel.OID) {- idxMeta := &storepb.IndexMetadata{+ idxMeta := &metadatapb.IndexMetadata{Name: idx.Name,Type: idx.AccessMethod,Unique: idx.IsUnique,diff --git a/backend/plugin/schema/pg/walk_through_apply.go b/backend/plugin/schema/pg/walk_through_apply.goindex e0b6a73f48..7277c5fe54 100644--- a/backend/plugin/schema/pg/walk_through_apply.go+++ b/backend/plugin/schema/pg/walk_through_apply.go@@ -6,21 +6,20 @@ import ("google.golang.org/protobuf/proto"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/catalog"omniparser "github.com/bytebase/omni/pg/parser"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// applyDiffToMetadata applies a SchemaDiff (from user DDL execution) to a// clone of the original metadata proto, producing the post-DDL metadata.// The original proto is NOT modified.-func applyDiffToMetadata(original *storepb.DatabaseSchemaMetadata, catBefore, catAfter *catalog.Catalog, diff *catalog.SchemaDiff) *storepb.DatabaseSchemaMetadata {+func applyDiffToMetadata(original *metadatapb.DatabaseSchemaMetadata, catBefore, catAfter *catalog.Catalog, diff *catalog.SchemaDiff) *metadatapb.DatabaseSchemaMetadata {if diff == nil || diff.IsEmpty() {return original}- result, ok := proto.Clone(original).(*storepb.DatabaseSchemaMetadata)+ result, ok := proto.Clone(original).(*metadatapb.DatabaseSchemaMetadata)if !ok {return original}@@ -28,7 +27,7 @@ func applyDiffToMetadata(original *storepb.DatabaseSchemaMetadata, catBefore, cafor _, s := range diff.Schemas {switch s.Action {case catalog.DiffAdd:- result.Schemas = append(result.Schemas, &storepb.SchemaMetadata{Name: s.Name})+ result.Schemas = append(result.Schemas, &metadatapb.SchemaMetadata{Name: s.Name})case catalog.DiffDrop:result.Schemas = removeSchema(result.Schemas, s.Name)default:@@ -88,7 +87,7 @@ func applyDiffToMetadata(original *storepb.DatabaseSchemaMetadata, catBefore, casm := findOrCreateSchema(result, e.SchemaName)switch e.Action {case catalog.DiffAdd:- sm.EnumTypes = append(sm.EnumTypes, &storepb.EnumTypeMetadata{+ sm.EnumTypes = append(sm.EnumTypes, &metadatapb.EnumTypeMetadata{Name: e.Name,Values: e.ToValues,})@@ -171,7 +170,7 @@ func applyDiffToMetadata(original *storepb.DatabaseSchemaMetadata, catBefore, careturn result}-func findSchema(meta *storepb.DatabaseSchemaMetadata, name string) *storepb.SchemaMetadata {+func findSchema(meta *metadatapb.DatabaseSchemaMetadata, name string) *metadatapb.SchemaMetadata {for _, s := range meta.Schemas {if s.Name == name {return s@@ -180,19 +179,19 @@ func findSchema(meta *storepb.DatabaseSchemaMetadata, name string) *storepb.Schereturn nil}-func findOrCreateSchema(meta *storepb.DatabaseSchemaMetadata, name string) *storepb.SchemaMetadata {+func findOrCreateSchema(meta *metadatapb.DatabaseSchemaMetadata, name string) *metadatapb.SchemaMetadata {for _, s := range meta.Schemas {if s.Name == name {return s}}- s := &storepb.SchemaMetadata{Name: name}+ s := &metadatapb.SchemaMetadata{Name: name}meta.Schemas = append(meta.Schemas, s)return s}-func removeSchema(schemas []*storepb.SchemaMetadata, name string) []*storepb.SchemaMetadata {- out := make([]*storepb.SchemaMetadata, 0, len(schemas))+func removeSchema(schemas []*metadatapb.SchemaMetadata, name string) []*metadatapb.SchemaMetadata {+ out := make([]*metadatapb.SchemaMetadata, 0, len(schemas))for _, s := range schemas {if s.Name != name {out = append(out, s)@@ -201,7 +200,7 @@ func removeSchema(schemas []*storepb.SchemaMetadata, name string) []*storepb.Schreturn out}-func addRelation(sm *storepb.SchemaMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {+func addRelation(sm *metadatapb.SchemaMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {if rel.To == nil {return}@@ -216,14 +215,14 @@ func addRelation(sm *storepb.SchemaMetadata, cat *catalog.Catalog, rel catalog.R}}-func dropRelation(sm *storepb.SchemaMetadata, rel catalog.RelationDiffEntry) {+func dropRelation(sm *metadatapb.SchemaMetadata, rel catalog.RelationDiffEntry) {name := rel.Namesm.Tables = removeTableByName(sm.Tables, name)sm.Views = removeViewByName(sm.Views, name)sm.MaterializedViews = removeMatViewByName(sm.MaterializedViews, name)}-func modifyRelation(sm *storepb.SchemaMetadata, catBefore, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {+func modifyRelation(sm *metadatapb.SchemaMetadata, catBefore, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {if rel.To == nil {return}@@ -247,7 +246,7 @@ func modifyRelation(sm *storepb.SchemaMetadata, catBefore, cat *catalog.Catalog,}}-func applyColumnDiffs(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {+func applyColumnDiffs(tbl *metadatapb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {for _, cd := range rel.Columns {switch cd.Action {case catalog.DiffAdd:@@ -270,7 +269,7 @@ func applyColumnDiffs(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel cata}}-func applyIndexDiffs(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {+func applyIndexDiffs(tbl *metadatapb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry) {for _, id := range rel.Indexes {switch id.Action {case catalog.DiffAdd:@@ -293,7 +292,7 @@ func applyIndexDiffs(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel catal}}-func applyConstraintDiffs(tbl *storepb.TableMetadata, catBefore, catAfter *catalog.Catalog, rel catalog.RelationDiffEntry) {+func applyConstraintDiffs(tbl *metadatapb.TableMetadata, catBefore, catAfter *catalog.Catalog, rel catalog.RelationDiffEntry) {for _, cd := range rel.Constraints {switch cd.Action {case catalog.DiffAdd:@@ -316,7 +315,7 @@ func applyConstraintDiffs(tbl *storepb.TableMetadata, catBefore, catAfter *catal}}-func addConstraintToTable(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry, con *catalog.Constraint) {+func addConstraintToTable(tbl *metadatapb.TableMetadata, cat *catalog.Catalog, rel catalog.RelationDiffEntry, con *catalog.Constraint) {switch con.Type {case catalog.ConstraintPK, catalog.ConstraintUnique:idx := cat.GetIndexByOID(con.IndexOID)@@ -326,12 +325,12 @@ func addConstraintToTable(tbl *storepb.TableMetadata, cat *catalog.Catalog, relcase catalog.ConstraintFK:tbl.ForeignKeys = append(tbl.ForeignKeys, constraintToFKProto(cat, rel.To, con))case catalog.ConstraintCheck:- tbl.CheckConstraints = append(tbl.CheckConstraints, &storepb.CheckConstraintMetadata{+ tbl.CheckConstraints = append(tbl.CheckConstraints, &metadatapb.CheckConstraintMetadata{Name: con.Name,Expression: con.CheckExpr,})case catalog.ConstraintExclude:- tbl.ExcludeConstraints = append(tbl.ExcludeConstraints, &storepb.ExcludeConstraintMetadata{+ tbl.ExcludeConstraints = append(tbl.ExcludeConstraints, &metadatapb.ExcludeConstraintMetadata{Name: con.Name,Expression: con.CheckExpr,})@@ -339,7 +338,7 @@ func addConstraintToTable(tbl *storepb.TableMetadata, cat *catalog.Catalog, rel}}-func removeConstraintFromTable(tbl *storepb.TableMetadata, cat *catalog.Catalog, con *catalog.Constraint) {+func removeConstraintFromTable(tbl *metadatapb.TableMetadata, cat *catalog.Catalog, con *catalog.Constraint) {switch con.Type {case catalog.ConstraintPK, catalog.ConstraintUnique:// Constraint name and backing index name may differ; resolve via IndexOID.@@ -349,7 +348,7 @@ func removeConstraintFromTable(tbl *storepb.TableMetadata, cat *catalog.Catalog,}tbl.Indexes = removeIndexByName(tbl.Indexes, idxName)case catalog.ConstraintFK:- out := make([]*storepb.ForeignKeyMetadata, 0, len(tbl.ForeignKeys))+ out := make([]*metadatapb.ForeignKeyMetadata, 0, len(tbl.ForeignKeys))for _, fk := range tbl.ForeignKeys {if fk.Name != con.Name {out = append(out, fk)@@ -357,7 +356,7 @@ func removeConstraintFromTable(tbl *storepb.TableMetadata, cat *catalog.Catalog,}tbl.ForeignKeys = outcase catalog.ConstraintCheck:- out := make([]*storepb.CheckConstraintMetadata, 0, len(tbl.CheckConstraints))+ out := make([]*metadatapb.CheckConstraintMetadata, 0, len(tbl.CheckConstraints))for _, c := range tbl.CheckConstraints {if c.Name != con.Name {out = append(out, c)@@ -365,7 +364,7 @@ func removeConstraintFromTable(tbl *storepb.TableMetadata, cat *catalog.Catalog,}tbl.CheckConstraints = outcase catalog.ConstraintExclude:- out := make([]*storepb.ExcludeConstraintMetadata, 0, len(tbl.ExcludeConstraints))+ out := make([]*metadatapb.ExcludeConstraintMetadata, 0, len(tbl.ExcludeConstraints))for _, c := range tbl.ExcludeConstraints {if c.Name != con.Name {out = append(out, c)@@ -378,8 +377,8 @@ func removeConstraintFromTable(tbl *storepb.TableMetadata, cat *catalog.Catalog,// --- Conversion helpers: omni types → proto types ----func columnToProto(cat *catalog.Catalog, col *catalog.Column) *storepb.ColumnMetadata {- cm := &storepb.ColumnMetadata{+func columnToProto(cat *catalog.Catalog, col *catalog.Column) *metadatapb.ColumnMetadata {+ cm := &metadatapb.ColumnMetadata{Name: col.Name,Position: int32(col.AttNum),Type: cat.FormatType(col.TypeOID, col.TypeMod),@@ -387,8 +386,8 @@ func columnToProto(cat *catalog.Catalog, col *catalog.Column) *storepb.ColumnMetDefault: col.Default,}if col.Generated == 's' {- cm.Generation = &storepb.GenerationMetadata{- Type: storepb.GenerationMetadata_TYPE_STORED,+ cm.Generation = &metadatapb.GenerationMetadata{+ Type: metadatapb.GenerationMetadata_TYPE_STORED,Expression: col.GenerationExpr,}}@@ -396,17 +395,17 @@ func columnToProto(cat *catalog.Catalog, col *catalog.Column) *storepb.ColumnMetcm.IsIdentity = trueswitch col.Identity {case 'a':- cm.IdentityGeneration = storepb.ColumnMetadata_ALWAYS+ cm.IdentityGeneration = metadatapb.ColumnMetadata_ALWAYScase 'd':- cm.IdentityGeneration = storepb.ColumnMetadata_BY_DEFAULT+ cm.IdentityGeneration = metadatapb.ColumnMetadata_BY_DEFAULTdefault:}}return cm}-func indexToProto(_ *catalog.Catalog, rel *catalog.Relation, idx *catalog.Index) *storepb.IndexMetadata {- im := &storepb.IndexMetadata{+func indexToProto(_ *catalog.Catalog, rel *catalog.Relation, idx *catalog.Index) *metadatapb.IndexMetadata {+ im := &metadatapb.IndexMetadata{Name: idx.Name,Type: idx.AccessMethod,Unique: idx.IsUnique,@@ -442,8 +441,8 @@ func indexToProto(_ *catalog.Catalog, rel *catalog.Relation, idx *catalog.Index)return im}-func constraintToFKProto(cat *catalog.Catalog, rel *catalog.Relation, con *catalog.Constraint) *storepb.ForeignKeyMetadata {- fk := &storepb.ForeignKeyMetadata{+func constraintToFKProto(cat *catalog.Catalog, rel *catalog.Relation, con *catalog.Constraint) *metadatapb.ForeignKeyMetadata {+ fk := &metadatapb.ForeignKeyMetadata{Name: con.Name,}@@ -480,8 +479,8 @@ func constraintToFKProto(cat *catalog.Catalog, rel *catalog.Relation, con *catalreturn fk}-func sequenceToProto(cat *catalog.Catalog, seq *catalog.Sequence) *storepb.SequenceMetadata {- return &storepb.SequenceMetadata{+func sequenceToProto(cat *catalog.Catalog, seq *catalog.Sequence) *metadatapb.SequenceMetadata {+ return &metadatapb.SequenceMetadata{Name: seq.Name,DataType: cat.FormatType(seq.TypeOID, -1),Start: fmt.Sprintf("%d", seq.Start),@@ -521,7 +520,7 @@ func wtFKMatchToString(match byte) string {// --- Slice helpers ----func findTable(sm *storepb.SchemaMetadata, name string) *storepb.TableMetadata {+func findTable(sm *metadatapb.SchemaMetadata, name string) *metadatapb.TableMetadata {for _, t := range sm.Tables {if t.Name == name {return t@@ -530,8 +529,8 @@ func findTable(sm *storepb.SchemaMetadata, name string) *storepb.TableMetadata {return nil}-func removeTableByName(tables []*storepb.TableMetadata, name string) []*storepb.TableMetadata {- out := make([]*storepb.TableMetadata, 0, len(tables))+func removeTableByName(tables []*metadatapb.TableMetadata, name string) []*metadatapb.TableMetadata {+ out := make([]*metadatapb.TableMetadata, 0, len(tables))for _, t := range tables {if t.Name != name {out = append(out, t)@@ -540,8 +539,8 @@ func removeTableByName(tables []*storepb.TableMetadata, name string) []*storepb.return out}-func removeViewByName(views []*storepb.ViewMetadata, name string) []*storepb.ViewMetadata {- out := make([]*storepb.ViewMetadata, 0, len(views))+func removeViewByName(views []*metadatapb.ViewMetadata, name string) []*metadatapb.ViewMetadata {+ out := make([]*metadatapb.ViewMetadata, 0, len(views))for _, v := range views {if v.Name != name {out = append(out, v)@@ -550,8 +549,8 @@ func removeViewByName(views []*storepb.ViewMetadata, name string) []*storepb.Viereturn out}-func removeMatViewByName(mvs []*storepb.MaterializedViewMetadata, name string) []*storepb.MaterializedViewMetadata {- out := make([]*storepb.MaterializedViewMetadata, 0, len(mvs))+func removeMatViewByName(mvs []*metadatapb.MaterializedViewMetadata, name string) []*metadatapb.MaterializedViewMetadata {+ out := make([]*metadatapb.MaterializedViewMetadata, 0, len(mvs))for _, m := range mvs {if m.Name != name {out = append(out, m)@@ -560,8 +559,8 @@ func removeMatViewByName(mvs []*storepb.MaterializedViewMetadata, name string) [return out}-func removeSequenceByName(seqs []*storepb.SequenceMetadata, name string) []*storepb.SequenceMetadata {- out := make([]*storepb.SequenceMetadata, 0, len(seqs))+func removeSequenceByName(seqs []*metadatapb.SequenceMetadata, name string) []*metadatapb.SequenceMetadata {+ out := make([]*metadatapb.SequenceMetadata, 0, len(seqs))for _, s := range seqs {if s.Name != name {out = append(out, s)@@ -570,8 +569,8 @@ func removeSequenceByName(seqs []*storepb.SequenceMetadata, name string) []*storreturn out}-func removeColumnByName(cols []*storepb.ColumnMetadata, name string) []*storepb.ColumnMetadata {- out := make([]*storepb.ColumnMetadata, 0, len(cols))+func removeColumnByName(cols []*metadatapb.ColumnMetadata, name string) []*metadatapb.ColumnMetadata {+ out := make([]*metadatapb.ColumnMetadata, 0, len(cols))for _, c := range cols {if c.Name != name {out = append(out, c)@@ -580,8 +579,8 @@ func removeColumnByName(cols []*storepb.ColumnMetadata, name string) []*storepb.return out}-func removeIndexByName(indexes []*storepb.IndexMetadata, name string) []*storepb.IndexMetadata {- out := make([]*storepb.IndexMetadata, 0, len(indexes))+func removeIndexByName(indexes []*metadatapb.IndexMetadata, name string) []*metadatapb.IndexMetadata {+ out := make([]*metadatapb.IndexMetadata, 0, len(indexes))for _, i := range indexes {if i.Name != name {out = append(out, i)@@ -590,8 +589,8 @@ func removeIndexByName(indexes []*storepb.IndexMetadata, name string) []*storepbreturn out}-func removeEnumByName(enums []*storepb.EnumTypeMetadata, name string) []*storepb.EnumTypeMetadata {- out := make([]*storepb.EnumTypeMetadata, 0, len(enums))+func removeEnumByName(enums []*metadatapb.EnumTypeMetadata, name string) []*metadatapb.EnumTypeMetadata {+ out := make([]*metadatapb.EnumTypeMetadata, 0, len(enums))for _, e := range enums {if e.Name != name {out = append(out, e)@@ -600,16 +599,16 @@ func removeEnumByName(enums []*storepb.EnumTypeMetadata, name string) []*storepbreturn out}-func functionToProto(cat *catalog.Catalog, up *catalog.UserProc, identity string) *storepb.FunctionMetadata {- return &storepb.FunctionMetadata{+func functionToProto(cat *catalog.Catalog, up *catalog.UserProc, identity string) *metadatapb.FunctionMetadata {+ return &metadatapb.FunctionMetadata{Name: up.Name,Definition: buildUserProcDDL(cat, up),Signature: identity,}}-func procedureToProto(cat *catalog.Catalog, up *catalog.UserProc, identity string) *storepb.ProcedureMetadata {- return &storepb.ProcedureMetadata{+func procedureToProto(cat *catalog.Catalog, up *catalog.UserProc, identity string) *metadatapb.ProcedureMetadata {+ return &metadatapb.ProcedureMetadata{Name: up.Name,Definition: buildUserProcDDL(cat, up),Signature: identity,@@ -695,8 +694,8 @@ func buildUserProcDDL(cat *catalog.Catalog, up *catalog.UserProc) string {return b.String()}-func removeProcedureByIdentity(procs []*storepb.ProcedureMetadata, identity string) []*storepb.ProcedureMetadata {- out := make([]*storepb.ProcedureMetadata, 0, len(procs))+func removeProcedureByIdentity(procs []*metadatapb.ProcedureMetadata, identity string) []*metadatapb.ProcedureMetadata {+ out := make([]*metadatapb.ProcedureMetadata, 0, len(procs))for _, p := range procs {if p.Signature != identity {out = append(out, p)@@ -705,8 +704,8 @@ func removeProcedureByIdentity(procs []*storepb.ProcedureMetadata, identity strireturn out}-func removeFunctionByIdentity(funcs []*storepb.FunctionMetadata, identity string) []*storepb.FunctionMetadata {- out := make([]*storepb.FunctionMetadata, 0, len(funcs))+func removeFunctionByIdentity(funcs []*metadatapb.FunctionMetadata, identity string) []*metadatapb.FunctionMetadata {+ out := make([]*metadatapb.FunctionMetadata, 0, len(funcs))for _, f := range funcs {if f.Signature != identity {out = append(out, f)@@ -729,9 +728,9 @@ func removeFunctionByIdentity(funcs []*storepb.FunctionMetadata, identity string// corrupting every untouched attribute. Walk-through metadata is advisory;// post-execution sync restores ground truth. The root fix is modeling the// types the loader cannot install today (e.g. domains).-func compositeTypeToProto(cat *catalog.Catalog, name string, from, to *catalog.Relation, previous *storepb.CompositeTypeMetadata) *storepb.CompositeTypeMetadata {- previousAttributes := make(map[string]*storepb.CompositeTypeAttribute)- composite := &storepb.CompositeTypeMetadata{Name: name}+func compositeTypeToProto(cat *catalog.Catalog, name string, from, to *catalog.Relation, previous *metadatapb.CompositeTypeMetadata) *metadatapb.CompositeTypeMetadata {+ previousAttributes := make(map[string]*metadatapb.CompositeTypeAttribute)+ composite := &metadatapb.CompositeTypeMetadata{Name: name}if previous != nil {composite.Comment = previous.Commentcomposite.SkipDump = previous.SkipDump@@ -759,7 +758,7 @@ func compositeTypeToProto(cat *catalog.Catalog, name string, from, to *catalog.Rif fc != nil &&fc.TypeOID == c.TypeOID && fc.TypeMod == c.TypeMod && fc.CollationName == c.CollationName {if prev := previousAttributes[fc.Name]; prev != nil {- composite.Attributes = append(composite.Attributes, &storepb.CompositeTypeAttribute{+ composite.Attributes = append(composite.Attributes, &metadatapb.CompositeTypeAttribute{Name: c.Name,Type: prev.Type,Collation: prev.Collation,@@ -768,14 +767,14 @@ func compositeTypeToProto(cat *catalog.Catalog, name string, from, to *catalog.Rcontinue}}- attribute := &storepb.CompositeTypeAttribute{+ attribute := &metadatapb.CompositeTypeAttribute{Name: c.Name,Type: qualifyWalkThroughAttributeType(cat, c.TypeOID, cat.FormatType(c.TypeOID, c.TypeMod)),}// Previous metadata is only consulted for the column identity that// survived (same attnum): a dropped-and-re-added attribute must not// inherit the old attribute's collation reference or comment.- var surviving *storepb.CompositeTypeAttribute+ var surviving *metadatapb.CompositeTypeAttributeif fc != nil {surviving = previousAttributes[fc.Name]}@@ -801,8 +800,8 @@ func compositeTypeToProto(cat *catalog.Catalog, name string, from, to *catalog.Rreturn composite}-func removeCompositeTypeByName(composites []*storepb.CompositeTypeMetadata, name string) []*storepb.CompositeTypeMetadata {- out := make([]*storepb.CompositeTypeMetadata, 0, len(composites))+func removeCompositeTypeByName(composites []*metadatapb.CompositeTypeMetadata, name string) []*metadatapb.CompositeTypeMetadata {+ out := make([]*metadatapb.CompositeTypeMetadata, 0, len(composites))for _, composite := range composites {if composite.Name != name {out = append(out, composite)diff --git a/backend/plugin/schema/pg/walk_through_loader.go b/backend/plugin/schema/pg/walk_through_loader.goindex 829335810f..aa506e661a 100644--- a/backend/plugin/schema/pg/walk_through_loader.go+++ b/backend/plugin/schema/pg/walk_through_loader.go@@ -11,17 +11,16 @@ import ("github.com/pkg/errors"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/ast""github.com/bytebase/omni/pg/catalog"omniparser "github.com/bytebase/omni/pg/parser"-- storepb "github.com/bytebase/bytebase/backend/generated-go/store")// loadWalkThroughCatalog installs every schema object from DatabaseSchemaMetadata// into the omni catalog in dependency-topological order with pseudo fallback.// Indexes and constraints are installed after their parent tables/views.-func loadWalkThroughCatalog(ctx context.Context, cat *catalog.Catalog, meta *storepb.DatabaseSchemaMetadata) error {+func loadWalkThroughCatalog(ctx context.Context, cat *catalog.Catalog, meta *metadatapb.DatabaseSchemaMetadata) error {if cat == nil {return errors.New("loadWalkThroughCatalog: nil catalog")}@@ -63,16 +62,16 @@ type wtObjectEntry struct {name string// Exactly one of the following is set based on kind.- enumMeta *storepb.EnumTypeMetadata- compositeMeta *storepb.CompositeTypeMetadata- seqMeta *storepb.SequenceMetadata- tableMeta *storepb.TableMetadata- viewMeta *storepb.ViewMetadata- matViewMeta *storepb.MaterializedViewMetadata- funcMeta *storepb.FunctionMetadata- idxMeta *storepb.IndexMetadata+ enumMeta *metadatapb.EnumTypeMetadata+ compositeMeta *metadatapb.CompositeTypeMetadata+ seqMeta *metadatapb.SequenceMetadata+ tableMeta *metadatapb.TableMetadata+ viewMeta *metadatapb.ViewMetadata+ matViewMeta *metadatapb.MaterializedViewMetadata+ funcMeta *metadatapb.FunctionMetadata+ idxMeta *metadatapb.IndexMetadata// For kindWTConstraint: the parent table metadata.- constraintTable *storepb.TableMetadata+ constraintTable *metadatapb.TableMetadata// For kindWTConstraint, kindWTIndex: the parent relation name.parentName string}@@ -108,7 +107,7 @@ func (e *wtObjectEntry) sortKey() string {return base}-func wtFuncSigKey(fn *storepb.FunctionMetadata) string {+func wtFuncSigKey(fn *metadatapb.FunctionMetadata) string {if fn == nil {return ""}@@ -145,7 +144,7 @@ func wtKindLabel(k wtObjectKind) string {}// wtCollectObjects flattens DatabaseSchemaMetadata into wtObjectEntry values.-func wtCollectObjects(meta *storepb.DatabaseSchemaMetadata) []*wtObjectEntry {+func wtCollectObjects(meta *metadatapb.DatabaseSchemaMetadata) []*wtObjectEntry {var out []*wtObjectEntryfor _, sm := range meta.Schemas {if sm.Name == "" {@@ -265,7 +264,7 @@ func wtCollectObjects(meta *storepb.DatabaseSchemaMetadata) []*wtObjectEntry {kind: kindWTFunction,schema: sm.Name,name: proc.Name,- funcMeta: &storepb.FunctionMetadata{+ funcMeta: &metadatapb.FunctionMetadata{Name: proc.Name,Definition: proc.Definition,Signature: proc.Signature,@@ -735,7 +734,7 @@ func wtInstallSequence(cat *catalog.Catalog, obj *wtObjectEntry) error {// wtIsIdentitySequence checks if a sequence is owned by an identity column.// Identity columns auto-create their sequence during DefineRelation, so// pre-creating it would cause a duplicate error.-func wtIsIdentitySequence(seq *storepb.SequenceMetadata, tables []*storepb.TableMetadata) bool {+func wtIsIdentitySequence(seq *metadatapb.SequenceMetadata, tables []*metadatapb.TableMetadata) bool {if seq.OwnerTable == "" || seq.OwnerColumn == "" {return false}@@ -781,7 +780,7 @@ func wtInstallTable(cat *catalog.Catalog, obj *wtObjectEntry) error {colDef.RawDefault = rawDefault}}- if col.Generation != nil && col.Generation.Type == storepb.GenerationMetadata_TYPE_STORED && col.Generation.Expression != "" {+ if col.Generation != nil && col.Generation.Type == metadatapb.GenerationMetadata_TYPE_STORED && col.Generation.Expression != "" {colDef.Generated = 's'if genExpr := wtParseExpr(col.Generation.Expression); genExpr != nil {colDef.Constraints = &ast.List{Items: []ast.Node{@@ -791,9 +790,9 @@ func wtInstallTable(cat *catalog.Catalog, obj *wtObjectEntry) error {}if col.IsIdentity {switch col.IdentityGeneration {- case storepb.ColumnMetadata_ALWAYS:+ case metadatapb.ColumnMetadata_ALWAYS:colDef.Identity = 'a'- case storepb.ColumnMetadata_BY_DEFAULT:+ case metadatapb.ColumnMetadata_BY_DEFAULT:colDef.Identity = 'd'default:colDef.Identity = 'd'@@ -1072,7 +1071,7 @@ func wtPseudoConstantSelect(cols []string) (*ast.SelectStmt, error) {// ---- column name helpers -----func wtColNames(tbl *storepb.TableMetadata) []string {+func wtColNames(tbl *metadatapb.TableMetadata) []string {if tbl == nil {return nil}@@ -1088,7 +1087,7 @@ func wtColNames(tbl *storepb.TableMetadata) []string {return out}-func wtViewColNames(v *storepb.ViewMetadata) []string {+func wtViewColNames(v *metadatapb.ViewMetadata) []string {if v == nil {return nil}@@ -1116,7 +1115,7 @@ func wtViewColNames(v *storepb.ViewMetadata) []string {return out}-func wtMatViewColNames(m *storepb.MaterializedViewMetadata) []string {+func wtMatViewColNames(m *metadatapb.MaterializedViewMetadata) []string {if m == nil {return nil}diff --git a/backend/plugin/schema/pg/walk_through_loader_test.go b/backend/plugin/schema/pg/walk_through_loader_test.goindex 79ba60fd00..f11c673063 100644--- a/backend/plugin/schema/pg/walk_through_loader_test.go+++ b/backend/plugin/schema/pg/walk_through_loader_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/pg/catalog""github.com/stretchr/testify/require"@@ -64,19 +65,19 @@ func TestClone_BasicIsolation(t *testing.T) {// TestClone_WalkThroughIntegration tests the full walk-through flow using Clone:// load catalog → clone → exec user DDL on clone → diff → apply.func TestClone_WalkThroughIntegration(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Position: 1},{Name: "name", Type: "text", Position: 2, Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "users_pkey", Expressions: []string{"id"}, Unique: true, Primary: true},},},@@ -133,9 +134,9 @@ func TestClone_WalkThroughIntegration(t *testing.T) {// TestClone_SearchPath tests Clone preserves search path and session user.func TestClone_SearchPath(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},{Name: "alice"},},@@ -175,19 +176,19 @@ func TestClone_SearchPath(t *testing.T) {// TestClone_WalkThroughFunction tests the actual WalkThroughWithContext function// using Clone (if enabled) produces correct FinalMetadata.func TestClone_WalkThroughFunction(t *testing.T) {- meta := &storepb.DatabaseSchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "test",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Position: 1},{Name: "name", Type: "text", Position: 2, Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "test_pkey", Expressions: []string{"id"}, Unique: true, Primary: true},},},@@ -217,25 +218,25 @@ func TestClone_WalkThroughFunction(t *testing.T) {// compositeWalkThroughMetadata has an adversarial name pair (aa_nested sorts// before its dependency zz_base) plus an enum-referencing composite and a// table using one, so a successful load proves dependency-ordered install.-func compositeWalkThroughMetadata() *storepb.DatabaseSchemaMetadata {- return &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+func compositeWalkThroughMetadata() *metadatapb.DatabaseSchemaMetadata {+ return &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- EnumTypes: []*storepb.EnumTypeMetadata{+ EnumTypes: []*metadatapb.EnumTypeMetadata{{Name: "status", Values: []string{"a", "b"}},},- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{// References zz_base only through an array suffix.Name: "aa_array_only",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "items", Type: "public.zz_base[]"},},},{Name: "aa_nested",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "home", Type: "public.zz_base"},{Name: "s", Type: "public.status"},},@@ -243,7 +244,7 @@ func compositeWalkThroughMetadata() *storepb.DatabaseSchemaMetadata {{Name: "zz_base",Comment: "base address type",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "street", Type: "text", Collation: `"C"`, Comment: "street line"},{Name: "city", Type: "character varying(50)"},},@@ -251,15 +252,15 @@ func compositeWalkThroughMetadata() *storepb.DatabaseSchemaMetadata {{Name: "ext_owned",SkipDump: true,- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "x", Type: "integer"},},},},- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Position: 1},{Name: "home", Type: "public.zz_base", Position: 2, Nullable: true},},@@ -289,14 +290,14 @@ func TestWalkThroughCompositeFallbackPreservesAttributeNames(t *testing.T) {// A domain-typed attribute cannot install (domains are not loader// objects), forcing the pseudo fallback — which must keep attribute// names so later DDL targeting them still resolves.- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "with_domain",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "p", Type: "public.pos_int"},{Name: "note", Type: "text"},},@@ -337,7 +338,7 @@ func TestWalkThroughCompositeFallbackPreservesAttributeNames(t *testing.T) {diff := catalog.Diff(cat, catAfter)require.False(t, diff.IsEmpty())newProto := applyDiffToMetadata(meta, cat, catAfter, diff)- var applied *storepb.CompositeTypeMetadata+ var applied *metadatapb.CompositeTypeMetadatafor _, composite := range newProto.Schemas[0].CompositeTypes {if composite.Name == "with_domain" {applied = composite@@ -354,14 +355,14 @@ func TestWalkThroughDropReaddAttributeReadsCatalogType(t *testing.T) {// Dropping and re-adding an attribute with the same name assigns a new// attnum; the rebuilt metadata must take the catalog's new type, not// carry the stale previous metadata.- meta := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ meta := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- CompositeTypes: []*storepb.CompositeTypeMetadata{+ CompositeTypes: []*metadatapb.CompositeTypeMetadata{{Name: "with_domain",- Attributes: []*storepb.CompositeTypeAttribute{+ Attributes: []*metadatapb.CompositeTypeAttribute{{Name: "p", Type: "public.pos_int", Comment: "old comment"},{Name: "note", Type: "text"},},@@ -388,7 +389,7 @@ func TestWalkThroughDropReaddAttributeReadsCatalogType(t *testing.T) {diff := catalog.Diff(cat, catAfter)require.False(t, diff.IsEmpty())newProto := applyDiffToMetadata(meta, cat, catAfter, diff)- var applied *storepb.CompositeTypeMetadata+ var applied *metadatapb.CompositeTypeMetadatafor _, composite := range newProto.Schemas[0].CompositeTypes {if composite.Name == "with_domain" {applied = composite@@ -396,7 +397,7 @@ func TestWalkThroughDropReaddAttributeReadsCatalogType(t *testing.T) {}require.NotNil(t, applied)require.Len(t, applied.Attributes, 2)- var p *storepb.CompositeTypeAttribute+ var p *metadatapb.CompositeTypeAttributefor _, attribute := range applied.Attributes {if attribute.Name == "p" {p = attribute@@ -441,7 +442,7 @@ func TestWalkThroughAppliesCompositeTypeChanges(t *testing.T) {publicSchema := newMeta.GetSchemaMetadata("public")require.NotNil(t, publicSchema)- composites := make(map[string]*storepb.CompositeTypeMetadata)+ composites := make(map[string]*metadatapb.CompositeTypeMetadata)for _, composite := range publicSchema.GetProto().CompositeTypes {composites[composite.Name] = composite}diff --git a/backend/plugin/schema/pg/walk_through_test.go b/backend/plugin/schema/pg/walk_through_test.goindex aa728096f7..58a25df9eb 100644--- a/backend/plugin/schema/pg/walk_through_test.go+++ b/backend/plugin/schema/pg/walk_through_test.go@@ -6,6 +6,7 @@ import ("path/filepath""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/google/go-cmp/cmp""github.com/stretchr/testify/require""google.golang.org/protobuf/proto"@@ -33,15 +34,15 @@ type testData struct {}func TestWalkThrough(t *testing.T) {- originDatabase := &storepb.DatabaseSchemaMetadata{+ originDatabase := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "test",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",@@ -57,11 +58,11 @@ func TestWalkThrough(t *testing.T) {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1",Definition: "SELECT id, name FROM test",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public",Table: "test",@@ -94,7 +95,7 @@ func TestWalkThrough(t *testing.T) {for i := range tests {test := &tests[i]// Make a deep copy to avoid mutation across tests- protoData, ok := proto.Clone(originDatabase).(*storepb.DatabaseSchemaMetadata)+ protoData, ok := proto.Clone(originDatabase).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)// Create DatabaseMetadata for walk-through@@ -118,29 +119,29 @@ func TestWalkThrough(t *testing.T) {continue}- want := &storepb.DatabaseSchemaMetadata{}+ want := &metadatapb.DatabaseSchemaMetadata{}err = common.ProtojsonUnmarshaler.Unmarshal([]byte(test.Want), want)require.NoError(t, err)result := state.GetProto()diff := cmp.Diff(want, result, protocmp.Transform(),- protocmp.SortRepeatedFields(&storepb.DatabaseSchemaMetadata{}, "schemas"),- protocmp.SortRepeatedFields(&storepb.SchemaMetadata{}, "tables", "views"),- protocmp.SortRepeatedFields(&storepb.TableMetadata{}, "indexes", "columns"),+ protocmp.SortRepeatedFields(&metadatapb.DatabaseSchemaMetadata{}, "schemas"),+ protocmp.SortRepeatedFields(&metadatapb.SchemaMetadata{}, "tables", "views"),+ protocmp.SortRepeatedFields(&metadatapb.TableMetadata{}, "indexes", "columns"),)require.Empty(t, diff)}}func TestWalkThroughANTLR(t *testing.T) {- originDatabase := &storepb.DatabaseSchemaMetadata{+ originDatabase := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "test",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",@@ -156,11 +157,11 @@ func TestWalkThroughANTLR(t *testing.T) {},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "v1",Definition: "SELECT id, name FROM test",- DependencyColumns: []*storepb.DependencyColumn{+ DependencyColumns: []*metadatapb.DependencyColumn{{Schema: "public",Table: "test",@@ -192,7 +193,7 @@ func TestWalkThroughANTLR(t *testing.T) {for i := range tests {test := &tests[i]// Make a deep copy to avoid mutation across tests- protoData, ok := proto.Clone(originDatabase).(*storepb.DatabaseSchemaMetadata)+ protoData, ok := proto.Clone(originDatabase).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)// Create DatabaseMetadata for walk-through@@ -221,14 +222,14 @@ func TestWalkThroughANTLR(t *testing.T) {continue}- want := &storepb.DatabaseSchemaMetadata{}+ want := &metadatapb.DatabaseSchemaMetadata{}err = common.ProtojsonUnmarshaler.Unmarshal([]byte(test.Want), want)require.NoError(t, err)result := state.GetProto()diff := cmp.Diff(want, result, protocmp.Transform(),- protocmp.SortRepeatedFields(&storepb.DatabaseSchemaMetadata{}, "schemas"),- protocmp.SortRepeatedFields(&storepb.SchemaMetadata{}, "tables", "views"),- protocmp.SortRepeatedFields(&storepb.TableMetadata{}, "indexes", "columns"),+ protocmp.SortRepeatedFields(&metadatapb.DatabaseSchemaMetadata{}, "schemas"),+ protocmp.SortRepeatedFields(&metadatapb.SchemaMetadata{}, "tables", "views"),+ protocmp.SortRepeatedFields(&metadatapb.TableMetadata{}, "indexes", "columns"),)require.Empty(t, diff)}@@ -332,21 +333,21 @@ func TestWalkThroughSearchPathState(t *testing.T) {}func newSearchPathTestState(searchPath string) *model.DatabaseMetadata {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "postgres",SearchPath: searchPath,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "alice"},{Name: "bob"},{Name: "app",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{newSearchPathTestTable("dup"),},},{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{newSearchPathTestTable("dup"),},},@@ -355,10 +356,10 @@ func newSearchPathTestState(searchPath string) *model.DatabaseMetadata {return model.NewDatabaseMetadata(metadata, nil, nil, storepb.Engine_POSTGRES, true)}-func newSearchPathTestTable(name string) *storepb.TableMetadata {- return &storepb.TableMetadata{+func newSearchPathTestTable(name string) *metadatapb.TableMetadata {+ return &metadatapb.TableMetadata{Name: name,- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "int",diff --git a/backend/plugin/schema/redshift/get_database_definition.go b/backend/plugin/schema/redshift/get_database_definition.goindex 078d233636..36587fc625 100644--- a/backend/plugin/schema/redshift/get_database_definition.go+++ b/backend/plugin/schema/redshift/get_database_definition.go@@ -5,6 +5,8 @@ import ("io""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -17,7 +19,7 @@ func init() {// GetTableDefinition renders one table exactly as the whole-database output// renders it, minus the section banner.-func GetTableDefinition(schemaName string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(schemaName string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var sb strings.Builderif err := writeTable(&sb, convertToTableState(0, schemaName, table)); err != nil {return "", err@@ -25,7 +27,7 @@ func GetTableDefinition(schemaName string, table *storepb.TableMetadata, _ []*streturn sb.String(), nil}-func GetViewDefinition(schemaName string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(schemaName string, view *metadatapb.ViewMetadata) (string, error) {var sb strings.Builderif err := writeView(&sb, convertToViewState(0, schemaName, view)); err != nil {return "", err@@ -33,7 +35,7 @@ func GetViewDefinition(schemaName string, view *storepb.ViewMetadata) (string, ereturn sb.String(), nil}-func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *metadatapb.DatabaseSchemaMetadata) (string, error) {toState := convertToDatabaseState(to)var sb strings.Builder@@ -51,7 +53,7 @@ func GetDatabaseDefinition(_ schema.GetDefinitionContext, to *storepb.DatabaseScreturn s, nil}-func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {+func writeTables(w io.StringWriter, to *metadatapb.DatabaseSchemaMetadata, state *databaseState) error {// Follow the order of the input schemas.for _, schema := range to.Schemas {schemaState, ok := state.schemas[schema.Name]@@ -77,7 +79,7 @@ func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *dreturn nil}-func writeViews(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {+func writeViews(w io.StringWriter, to *metadatapb.DatabaseSchemaMetadata, state *databaseState) error {// Follow the order of the input schemas.for _, schema := range to.Schemas {schemaState, ok := state.schemas[schema.Name]diff --git a/backend/plugin/schema/redshift/get_database_definition_test.go b/backend/plugin/schema/redshift/get_database_definition_test.goindex 2d6c1c3d32..046d1512c1 100644--- a/backend/plugin/schema/redshift/get_database_definition_test.go+++ b/backend/plugin/schema/redshift/get_database_definition_test.go@@ -4,6 +4,7 @@ import ("strings""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -19,10 +20,10 @@ func TestGetObjectDefinition(t *testing.T) {{name: "table with comments",get: func() (string, error) {- return GetTableDefinition("public", &storepb.TableMetadata{+ return GetTableDefinition("public", &metadatapb.TableMetadata{Name: "orders",Comment: "one row per order",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Comment: "surrogate key"},{Name: "total", Type: "numeric(10,2)", Nullable: true},{Name: "label", Type: "character varying(50)", Nullable: true, Comment: "display name"},@@ -42,7 +43,7 @@ COMMENT ON COLUMN "public"."orders"."label" IS 'display name';{name: "view with comment",get: func() (string, error) {- return GetViewDefinition("public", &storepb.ViewMetadata{+ return GetViewDefinition("public", &metadatapb.ViewMetadata{Name: "recent_orders",Definition: "SELECT id, total FROM orders",Comment: "last 30 days",@@ -57,9 +58,9 @@ COMMENT ON VIEW "public"."recent_orders" IS 'last 30 days';// the search path has to carry it or the DDL lands somewhere else.name: "table outside the default schema keeps its qualifier",get: func() (string, error) {- return GetTableDefinition("analytics", &storepb.TableMetadata{+ return GetTableDefinition("analytics", &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},}, nil)},want: `CREATE TABLE "analytics"."orders" (@@ -72,10 +73,10 @@ COMMENT ON VIEW "public"."recent_orders" IS 'last 30 days';// not replay.name: "comments with apostrophes stay valid",get: func() (string, error) {- return GetTableDefinition("public", &storepb.TableMetadata{+ return GetTableDefinition("public", &metadatapb.TableMetadata{Name: "orders",Comment: "owner's orders",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer", Comment: "don't drop"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Comment: "don't drop"}},}, nil)},want: `CREATE TABLE "public"."orders" (@@ -100,9 +101,9 @@ COMMENT ON COLUMN "public"."orders"."id" IS 'don''t drop';// COLUMN statements. They used to come from ranging over a map, so the dump// differed between runs for any table with more than one commented column.func TestColumnCommentOrderIsStable(t *testing.T) {- table := &storepb.TableMetadata{Name: "wide"}+ table := &metadatapb.TableMetadata{Name: "wide"}for _, name := range []string{"a", "b", "c", "d", "e", "f", "g", "h"} {- table.Columns = append(table.Columns, &storepb.ColumnMetadata{+ table.Columns = append(table.Columns, &metadatapb.ColumnMetadata{Name: name,Type: "integer",Nullable: true,@@ -134,16 +135,16 @@ func TestObjectDefinitionsRegisteredForRedshift(t *testing.T) {{name: "table",get: func() (string, error) {- return schema.GetTableDefinition(storepb.Engine_REDSHIFT, "public", &storepb.TableMetadata{+ return schema.GetTableDefinition(storepb.Engine_REDSHIFT, "public", &metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"}},}, nil)},},{name: "view",get: func() (string, error) {- return schema.GetViewDefinition(storepb.Engine_REDSHIFT, "public", &storepb.ViewMetadata{+ return schema.GetViewDefinition(storepb.Engine_REDSHIFT, "public", &metadatapb.ViewMetadata{Name: "v",Definition: "SELECT 1",})@@ -164,18 +165,18 @@ func TestObjectDefinitionsRegisteredForRedshift(t *testing.T) {// whole-database output still frames each object with its banner and renders// the same body the single-object entry points return.func TestGetDatabaseDefinitionKeepsSections(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{- Schemas: []*storepb.SchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "orders",Comment: "one row per order",- Columns: []*storepb.ColumnMetadata{{Name: "id", Type: "integer", Comment: "surrogate key"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer", Comment: "surrogate key"}},},},- Views: []*storepb.ViewMetadata{+ Views: []*metadatapb.ViewMetadata{{Name: "recent_orders", Definition: "SELECT id FROM orders"},},},@@ -210,13 +211,13 @@ CREATE OR REPLACE VIEW "public"."recent_orders" AS SELECT id FROM orders;// ReferencedSchema, so dropping it binds the constraint to whatever the search// path resolves instead of the table the metadata names.func TestForeignKeyKeepsReferencedSchema(t *testing.T) {- got, err := GetTableDefinition("analytics", &storepb.TableMetadata{+ got, err := GetTableDefinition("analytics", &metadatapb.TableMetadata{Name: "child",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "integer"},{Name: "parent_id", Type: "integer", Nullable: true},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "child_parent_fk",Columns: []string{"parent_id"},@@ -235,9 +236,9 @@ func TestForeignKeyKeepsReferencedSchema(t *testing.T) {// would corrupt: Redshift folds an unquoted identifier to lower case and rejects// one containing a space, and an embedded double quote has to be doubled.func TestIdentifiersNeedingQuotesSurvive(t *testing.T) {- got, err := GetTableDefinition("Sales Data", &storepb.TableMetadata{+ got, err := GetTableDefinition("Sales Data", &metadatapb.TableMetadata{Name: "MixedCase",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: `od"d`, Type: "integer", Comment: "quoted name"},},}, nil)@@ -254,16 +255,16 @@ COMMENT ON COLUMN "Sales Data"."MixedCase"."od""d" IS 'quoted name';// quoted, while getColumnList strips the quotes off foreign key columns, so one// must be written as-is and the other must be quoted.func TestIndexKeysAreVerbatimAndForeignKeyColumnsAreQuoted(t *testing.T) {- got, err := GetTableDefinition("public", &storepb.TableMetadata{+ got, err := GetTableDefinition("public", &metadatapb.TableMetadata{Name: "t",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "MixedCase", Type: "integer"},{Name: "parent_id", Type: "integer", Nullable: true},},- Indexes: []*storepb.IndexMetadata{+ Indexes: []*metadatapb.IndexMetadata{{Name: "t_pkey", Primary: true, Expressions: []string{`"MixedCase"`}},},- ForeignKeys: []*storepb.ForeignKeyMetadata{+ ForeignKeys: []*metadatapb.ForeignKeyMetadata{{Name: "t_parent_fk",Columns: []string{"parent_id"},diff --git a/backend/plugin/schema/redshift/state.go b/backend/plugin/schema/redshift/state.goindex e4525c71e0..23518f67f2 100644--- a/backend/plugin/schema/redshift/state.go+++ b/backend/plugin/schema/redshift/state.go@@ -6,7 +6,7 @@ import ("slices""strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")type databaseState struct {@@ -20,7 +20,7 @@ func newDatabaseState() *databaseState {}}-func convertToDatabaseState(database *storepb.DatabaseSchemaMetadata) *databaseState {+func convertToDatabaseState(database *metadatapb.DatabaseSchemaMetadata) *databaseState {state := newDatabaseState()state.name = database.Namefor _, schema := range database.Schemas {@@ -74,7 +74,7 @@ func newSchemaState() *schemaState {}}-func convertToSchemaState(schema *storepb.SchemaMetadata) *schemaState {+func convertToSchemaState(schema *metadatapb.SchemaMetadata) *schemaState {state := newSchemaState()state.name = schema.Namefor i, table := range schema.Tables {@@ -204,7 +204,7 @@ func sortedColumns(columns map[string]*columnState) []*columnState {return sorted}-func convertToTableState(id int, schemaName string, table *storepb.TableMetadata) *tableState {+func convertToTableState(id int, schemaName string, table *metadatapb.TableMetadata) *tableState {state := newTableState(id, table.Name)state.schema = schemaNamestate.comment = table.Comment@@ -229,7 +229,7 @@ type foreignKeyState struct {referencedColumns []string}-func convertToForeignKeyState(id int, foreignKey *storepb.ForeignKeyMetadata) *foreignKeyState {+func convertToForeignKeyState(id int, foreignKey *metadatapb.ForeignKeyMetadata) *foreignKeyState {return &foreignKeyState{id: id,name: foreignKey.Name,@@ -273,7 +273,7 @@ type indexState struct {tp string}-func convertToIndexState(id int, index *storepb.IndexMetadata) *indexState {+func convertToIndexState(id int, index *metadatapb.IndexMetadata) *indexState {return &indexState{id: id,name: index.Name,@@ -386,7 +386,7 @@ func (c *columnState) toString(buf *strings.Builder) error {return nil}-func convertToColumnState(id int, column *storepb.ColumnMetadata) *columnState {+func convertToColumnState(id int, column *metadatapb.ColumnMetadata) *columnState {result := &columnState{id: id,name: column.Name,@@ -429,7 +429,7 @@ type viewState struct {comment string}-func convertToViewState(id int, schemaName string, view *storepb.ViewMetadata) *viewState {+func convertToViewState(id int, schemaName string, view *metadatapb.ViewMetadata) *viewState {return &viewState{id: id,schema: schemaName,diff --git a/backend/plugin/schema/schema.go b/backend/plugin/schema/schema.goindex 3680ba9ecb..71c62d5c11 100644--- a/backend/plugin/schema/schema.go+++ b/backend/plugin/schema/schema.go@@ -5,6 +5,7 @@ import ("strings""sync"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -33,16 +34,16 @@ var (walkThroughsWithContext = make(map[storepb.Engine]walkThroughWithContext))-type getDatabaseDefinition func(GetDefinitionContext, *storepb.DatabaseSchemaMetadata) (string, error)-type getMultiFileDatabaseDefinition func(GetDefinitionContext, *storepb.DatabaseSchemaMetadata) (*MultiFileSchemaResult, error)-type getSchemaDefinition func(*storepb.SchemaMetadata) (string, error)-type getTableDefinition func(string, *storepb.TableMetadata, []*storepb.SequenceMetadata) (string, error)-type getViewDefinition func(string, *storepb.ViewMetadata) (string, error)-type getMaterializedViewDefinition func(string, *storepb.MaterializedViewMetadata) (string, error)-type getFunctionDefinition func(string, *storepb.FunctionMetadata) (string, error)-type getProcedureDefinition func(string, *storepb.ProcedureMetadata) (string, error)-type getSequenceDefinition func(string, *storepb.SequenceMetadata) (string, error)-type getDatabaseMetadata func(string) (*storepb.DatabaseSchemaMetadata, error)+type getDatabaseDefinition func(GetDefinitionContext, *metadatapb.DatabaseSchemaMetadata) (string, error)+type getMultiFileDatabaseDefinition func(GetDefinitionContext, *metadatapb.DatabaseSchemaMetadata) (*MultiFileSchemaResult, error)+type getSchemaDefinition func(*metadatapb.SchemaMetadata) (string, error)+type getTableDefinition func(string, *metadatapb.TableMetadata, []*metadatapb.SequenceMetadata) (string, error)+type getViewDefinition func(string, *metadatapb.ViewMetadata) (string, error)+type getMaterializedViewDefinition func(string, *metadatapb.MaterializedViewMetadata) (string, error)+type getFunctionDefinition func(string, *metadatapb.FunctionMetadata) (string, error)+type getProcedureDefinition func(string, *metadatapb.ProcedureMetadata) (string, error)+type getSequenceDefinition func(string, *metadatapb.SequenceMetadata) (string, error)+type getDatabaseMetadata func(string) (*metadatapb.DatabaseSchemaMetadata, error)type generateMigration func(*MetadataDiff) (string, error)type getSDLDiff func(currentSDLText, previousUserSDLText string, currentSchema *model.DatabaseMetadata) (*MetadataDiff, error)type sdlDropAdvices func(userSDLText string, currentSchema *model.DatabaseMetadata, engineVersion string) ([]*storepb.Advice, error)@@ -103,7 +104,7 @@ func RegisterGetSequenceDefinition(engine storepb.Engine, f getSequenceDefinitiogetSequenceDefinitions[engine] = f}-func GetSequenceDefinition(engine storepb.Engine, sequenceName string, sequence *storepb.SequenceMetadata) (string, error) {+func GetSequenceDefinition(engine storepb.Engine, sequenceName string, sequence *metadatapb.SequenceMetadata) (string, error) {f, ok := getSequenceDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -120,7 +121,7 @@ func RegisterGetFunctionDefinition(engine storepb.Engine, f getFunctionDefinitiogetFunctionDefinitions[engine] = f}-func GetFunctionDefinition(engine storepb.Engine, functionName string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(engine storepb.Engine, functionName string, function *metadatapb.FunctionMetadata) (string, error) {f, ok := getFunctionDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -137,7 +138,7 @@ func RegisterGetProcedureDefinition(engine storepb.Engine, f getProcedureDefinitgetProcedureDefinitions[engine] = f}-func GetProcedureDefinition(engine storepb.Engine, procedureName string, procedure *storepb.ProcedureMetadata) (string, error) {+func GetProcedureDefinition(engine storepb.Engine, procedureName string, procedure *metadatapb.ProcedureMetadata) (string, error) {f, ok := getProcedureDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -154,7 +155,7 @@ func RegisterGetMaterializedViewDefinition(engine storepb.Engine, f getMaterialigetMaterializedViewDefinitions[engine] = f}-func GetMaterializedViewDefinition(engine storepb.Engine, viewName string, view *storepb.MaterializedViewMetadata) (string, error) {+func GetMaterializedViewDefinition(engine storepb.Engine, viewName string, view *metadatapb.MaterializedViewMetadata) (string, error) {f, ok := getMaterializedViewDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -171,7 +172,7 @@ func RegisterGetViewDefinition(engine storepb.Engine, f getViewDefinition) {getViewDefinitions[engine] = f}-func GetViewDefinition(engine storepb.Engine, viewName string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(engine storepb.Engine, viewName string, view *metadatapb.ViewMetadata) (string, error) {f, ok := getViewDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -188,7 +189,7 @@ func RegisterGetTableDefinition(engine storepb.Engine, f getTableDefinition) {getTableDefinitions[engine] = f}-func GetTableDefinition(engine storepb.Engine, tableName string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(engine storepb.Engine, tableName string, table *metadatapb.TableMetadata, sequences []*metadatapb.SequenceMetadata) (string, error) {f, ok := getTableDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -205,7 +206,7 @@ func RegisterGetSchemaDefinition(engine storepb.Engine, f getSchemaDefinition) {getSchemaDefinitions[engine] = f}-func GetSchemaDefinition(engine storepb.Engine, schema *storepb.SchemaMetadata) (string, error) {+func GetSchemaDefinition(engine storepb.Engine, schema *metadatapb.SchemaMetadata) (string, error) {f, ok := getSchemaDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -222,7 +223,7 @@ func RegisterGetDatabaseDefinition(engine storepb.Engine, f getDatabaseDefinitiogetDatabaseDefinitions[engine] = f}-func GetDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {f, ok := getDatabaseDefinitions[engine]if !ok {return "", errors.Errorf("engine %s is not supported", engine)@@ -239,7 +240,7 @@ func RegisterGetDatabaseMetadata(engine storepb.Engine, f getDatabaseMetadata) {getDatabaseMetadataMap[engine] = f}-func GetDatabaseMetadata(engine storepb.Engine, schemaText string) (*storepb.DatabaseSchemaMetadata, error) {+func GetDatabaseMetadata(engine storepb.Engine, schemaText string) (*metadatapb.DatabaseSchemaMetadata, error) {f, ok := getDatabaseMetadataMap[engine]if !ok {return nil, errors.Errorf("engine %s is not supported", engine)@@ -505,7 +506,7 @@ func RegisterGetMultiFileDatabaseDefinition(engine storepb.Engine, f getMultiFilgetMultiFileDatabaseDefinitions[engine] = f}-func GetMultiFileDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (*MultiFileSchemaResult, error) {+func GetMultiFileDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (*MultiFileSchemaResult, error) {f, ok := getMultiFileDatabaseDefinitions[engine]if !ok {return nil, errors.Errorf("engine %s is not supported for multi-file database definition", engine)diff --git a/backend/plugin/schema/tidb/generate_migration.go b/backend/plugin/schema/tidb/generate_migration.goindex 38744493a0..510417a1e3 100644--- a/backend/plugin/schema/tidb/generate_migration.go+++ b/backend/plugin/schema/tidb/generate_migration.go@@ -4,6 +4,8 @@ import ("fmt""strings"+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -425,7 +427,7 @@ func writeDropColumn(buf *strings.Builder, table, column string) error {return nil}-func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string, table *storepb.TableMetadata) error {+func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string, table *metadatapb.TableMetadata) error {_, _ = buf.WriteString("CREATE TABLE IF NOT EXISTS `")_, _ = buf.WriteString(tableName)_, _ = buf.WriteString("` (\n")@@ -583,7 +585,7 @@ func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string,}// TiDB specific partition clause (similar to MySQL but with TiDB extensions)-func writePartitionClause(buf *strings.Builder, partitions []*storepb.TablePartitionMetadata) error {+func writePartitionClause(buf *strings.Builder, partitions []*metadatapb.TablePartitionMetadata) error {if len(partitions) == 0 {return nil}@@ -591,17 +593,17 @@ func writePartitionClause(buf *strings.Builder, partitions []*storepb.TableParti_, _ = buf.WriteString("\n/*T![auto_rand] PARTITION BY ")switch partitions[0].Type {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:_, _ = fmt.Fprintf(buf, "RANGE (%s)", partitions[0].Expression)- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:_, _ = fmt.Fprintf(buf, "RANGE COLUMNS (%s)", partitions[0].Expression)- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:_, _ = fmt.Fprintf(buf, "LIST (%s)", partitions[0].Expression)- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:_, _ = fmt.Fprintf(buf, "LIST COLUMNS (%s)", partitions[0].Expression)- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:_, _ = fmt.Fprintf(buf, "HASH (%s)", partitions[0].Expression)- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:_, _ = fmt.Fprintf(buf, "KEY (%s)", partitions[0].Expression)default:// Unsupported partition type@@ -620,13 +622,13 @@ func writePartitionClause(buf *strings.Builder, partitions []*storepb.TableParti_, _ = fmt.Fprintf(buf, "PARTITION %s", partition.Name)if partition.Value != "" {switch partitions[0].Type {- case storepb.TablePartitionMetadata_RANGE, storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE, metadatapb.TablePartitionMetadata_RANGE_COLUMNS:if partition.Value != "MAXVALUE" {_, _ = fmt.Fprintf(buf, " VALUES LESS THAN (%s)", partition.Value)} else {_, _ = fmt.Fprintf(buf, " VALUES LESS THAN %s", partition.Value)}- case storepb.TablePartitionMetadata_LIST, storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST, metadatapb.TablePartitionMetadata_LIST_COLUMNS:_, _ = fmt.Fprintf(buf, " VALUES IN (%s)", partition.Value)default:// No VALUES clause for other partition types like HASH/KEY@@ -640,7 +642,7 @@ func writePartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn nil}-func writeAddColumn(buf *strings.Builder, table string, column *storepb.ColumnMetadata) error {+func writeAddColumn(buf *strings.Builder, table string, column *metadatapb.ColumnMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD COLUMN `")@@ -689,7 +691,7 @@ func writeAddColumn(buf *strings.Builder, table string, column *storepb.ColumnMereturn nil}-func writeModifyColumn(buf *strings.Builder, table string, column *storepb.ColumnMetadata) error {+func writeModifyColumn(buf *strings.Builder, table string, column *metadatapb.ColumnMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` MODIFY COLUMN `")@@ -738,7 +740,7 @@ func writeModifyColumn(buf *strings.Builder, table string, column *storepb.Columreturn nil}-func writeCreateIndex(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeCreateIndex(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("CREATE ")// Handle special index typesif strings.ToUpper(index.Type) == "FULLTEXT" {@@ -787,7 +789,7 @@ func writeCreateIndex(buf *strings.Builder, table string, index *storepb.IndexMereturn nil}-func writeAddPrimaryKey(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeAddPrimaryKey(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD PRIMARY KEY (")@@ -805,7 +807,7 @@ func writeAddPrimaryKey(buf *strings.Builder, table string, index *storepb.Indexreturn nil}-func writeAddUniqueKey(buf *strings.Builder, table string, index *storepb.IndexMetadata) error {+func writeAddUniqueKey(buf *strings.Builder, table string, index *metadatapb.IndexMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD UNIQUE KEY `")@@ -825,7 +827,7 @@ func writeAddUniqueKey(buf *strings.Builder, table string, index *storepb.IndexMreturn nil}-func writeAddCheckConstraint(buf *strings.Builder, table string, check *storepb.CheckConstraintMetadata) error {+func writeAddCheckConstraint(buf *strings.Builder, table string, check *metadatapb.CheckConstraintMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD CONSTRAINT `")@@ -836,7 +838,7 @@ func writeAddCheckConstraint(buf *strings.Builder, table string, check *storepb.return nil}-func writeAddForeignKey(buf *strings.Builder, table string, fk *storepb.ForeignKeyMetadata) error {+func writeAddForeignKey(buf *strings.Builder, table string, fk *metadatapb.ForeignKeyMetadata) error {_, _ = buf.WriteString("ALTER TABLE `")_, _ = buf.WriteString(table)_, _ = buf.WriteString("` ADD CONSTRAINT `")@@ -880,7 +882,7 @@ func writeAddForeignKey(buf *strings.Builder, table string, fk *storepb.ForeignKreturn nil}-func writeCreateView(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeCreateView(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {_, _ = buf.WriteString("CREATE VIEW `")_, _ = buf.WriteString(viewName)_, _ = buf.WriteString("` AS ")@@ -893,7 +895,7 @@ func writeCreateView(buf *strings.Builder, viewName string, view *storepb.ViewMereturn nil}-func writeCreateOrReplaceView(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeCreateOrReplaceView(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {_, _ = buf.WriteString("CREATE OR REPLACE VIEW `")_, _ = buf.WriteString(viewName)_, _ = buf.WriteString("` AS ")@@ -975,7 +977,7 @@ func hasCreateOrAlterObjects(diff *schema.MetadataDiff) bool {return false}-func getDefaultExpression(column *storepb.ColumnMetadata) string {+func getDefaultExpression(column *metadatapb.ColumnMetadata) string {if column == nil {return ""}@@ -987,7 +989,7 @@ func getDefaultExpression(column *storepb.ColumnMetadata) string {return ""}-func hasDefaultValue(column *storepb.ColumnMetadata) bool {+func hasDefaultValue(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}@@ -1000,7 +1002,7 @@ func hasDefaultValue(column *storepb.ColumnMetadata) bool {return column.Default != ""}-func hasAutoIncrement(column *storepb.ColumnMetadata) bool {+func hasAutoIncrement(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}@@ -1009,14 +1011,14 @@ func hasAutoIncrement(column *storepb.ColumnMetadata) bool {return strings.EqualFold(column.GetDefault(), "AUTO_INCREMENT")}-func hasAutoRandom(column *storepb.ColumnMetadata) bool {+func hasAutoRandom(column *metadatapb.ColumnMetadata) bool {if column == nil {return false}return strings.HasPrefix(column.GetDefault(), "AUTO_RANDOM")}-func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *storepb.ViewMetadata) error {+func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *metadatapb.ViewMetadata) error {// Create a temporary view with SELECT 1 AS column_name structure// to satisfy other views that depend on this view_, _ = buf.WriteString("CREATE OR REPLACE VIEW `")@@ -1041,7 +1043,7 @@ func writeTemporaryViewForDrop(buf *strings.Builder, viewName string, view *storreturn nil}-func writeCreateTrigger(buf *strings.Builder, tableName string, trigger *storepb.TriggerMetadata) error {+func writeCreateTrigger(buf *strings.Builder, tableName string, trigger *metadatapb.TriggerMetadata) error {// Construct the complete trigger statement_, _ = buf.WriteString("CREATE TRIGGER `")_, _ = buf.WriteString(trigger.Name)@@ -1079,7 +1081,7 @@ func writeSequenceDiff(buf *strings.Builder, seqDiff *schema.SequenceDiff) errorreturn nil}-func writeCreateSequence(buf *strings.Builder, sequence *storepb.SequenceMetadata) error {+func writeCreateSequence(buf *strings.Builder, sequence *metadatapb.SequenceMetadata) error {_, _ = buf.WriteString("CREATE SEQUENCE `")_, _ = buf.WriteString(sequence.Name)_, _ = buf.WriteString("`")@@ -1125,7 +1127,7 @@ func writeCreateSequence(buf *strings.Builder, sequence *storepb.SequenceMetadatreturn nil}-func writeAlterSequence(buf *strings.Builder, sequenceName string, sequence *storepb.SequenceMetadata) error {+func writeAlterSequence(buf *strings.Builder, sequenceName string, sequence *metadatapb.SequenceMetadata) error {// TiDB does not support ALTER SEQUENCE, so we need to DROP and CREATEif err := writeDropSequence(buf, sequenceName); err != nil {return errdiff --git a/backend/plugin/schema/tidb/generate_migration_test.go b/backend/plugin/schema/tidb/generate_migration_test.goindex 5039a8c624..2b0a085d75 100644--- a/backend/plugin/schema/tidb/generate_migration_test.go+++ b/backend/plugin/schema/tidb/generate_migration_test.go@@ -4,6 +4,7 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3"@@ -72,7 +73,7 @@ func TestGenerateMigration(t *testing.T) {func parseSchema(t *testing.T, text string) *model.DatabaseMetadata {t.Helper()- metadata := &storepb.DatabaseSchemaMetadata{Schemas: []*storepb.SchemaMetadata{{}}}+ metadata := &metadatapb.DatabaseSchemaMetadata{Schemas: []*metadatapb.SchemaMetadata{{}}}if text != "" {parsed, err := GetDatabaseMetadata(text)require.NoError(t, err)diff --git a/backend/plugin/schema/tidb/get_database_definition.go b/backend/plugin/schema/tidb/get_database_definition.goindex c416a8ab44..35d3f0af47 100644--- a/backend/plugin/schema/tidb/get_database_definition.go+++ b/backend/plugin/schema/tidb/get_database_definition.go@@ -6,6 +6,7 @@ import ("strconv""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -60,7 +61,7 @@ func init() {schema.RegisterGetProcedureDefinition(storepb.Engine_TIDB, GetProcedureDefinition)}-func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {if len(metadata.Schemas) == 0 {return "", nil}@@ -150,7 +151,7 @@ func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.Dareturn buf.String(), nil}-func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.SequenceMetadata) (string, error) {+func GetTableDefinition(_ string, table *metadatapb.TableMetadata, _ []*metadatapb.SequenceMetadata) (string, error) {var buf strings.Builderif err := writeTable(&buf, table); err != nil {return "", err@@ -158,7 +159,7 @@ func GetTableDefinition(_ string, table *storepb.TableMetadata, _ []*storepb.Seqreturn buf.String(), nil}-func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {+func GetViewDefinition(_ string, view *metadatapb.ViewMetadata) (string, error) {var buf strings.Builderif err := writeView(&buf, view); err != nil {return "", err@@ -166,7 +167,7 @@ func GetViewDefinition(_ string, view *storepb.ViewMetadata) (string, error) {return buf.String(), nil}-func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (string, error) {+func GetFunctionDefinition(_ string, function *metadatapb.FunctionMetadata) (string, error) {var buf strings.Builderif err := writeFunction(&buf, function); err != nil {return "", err@@ -174,7 +175,7 @@ func GetFunctionDefinition(_ string, function *storepb.FunctionMetadata) (stringreturn buf.String(), nil}-func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (string, error) {+func GetProcedureDefinition(_ string, procedure *metadatapb.ProcedureMetadata) (string, error) {var buf strings.Builderif err := writeProcedure(&buf, procedure); err != nil {return "", err@@ -182,7 +183,7 @@ func GetProcedureDefinition(_ string, procedure *storepb.ProcedureMetadata) (strreturn buf.String(), nil}-func writeEvent(out io.Writer, event *storepb.EventMetadata) error {+func writeEvent(out io.Writer, event *metadatapb.EventMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -269,7 +270,7 @@ func writeEvent(out io.Writer, event *storepb.EventMetadata) error {return err}-func writeTrigger(out io.Writer, tableName string, trigger *storepb.TriggerMetadata) error {+func writeTrigger(out io.Writer, tableName string, trigger *metadatapb.TriggerMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -374,7 +375,7 @@ func writeTrigger(out io.Writer, tableName string, trigger *storepb.TriggerMetadreturn err}-func writeProcedure(out io.Writer, procedure *storepb.ProcedureMetadata) error {+func writeProcedure(out io.Writer, procedure *metadatapb.ProcedureMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -452,7 +453,7 @@ func writeProcedure(out io.Writer, procedure *storepb.ProcedureMetadata) error {return err}-func writeFunction(out io.Writer, function *storepb.FunctionMetadata) error {+func writeFunction(out io.Writer, function *metadatapb.FunctionMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -530,7 +531,7 @@ func writeFunction(out io.Writer, function *storepb.FunctionMetadata) error {return err}-func writeView(out io.Writer, view *storepb.ViewMetadata) error {+func writeView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -579,7 +580,7 @@ func writeView(out io.Writer, view *storepb.ViewMetadata) error {return err}-func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {+func writeTable(out *strings.Builder, table *metadatapb.TableMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -685,7 +686,7 @@ func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {}// Copy the logic from backend/plugin/schema/mysql/state.go.-func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartitionMetadata) error {+func printPartitionClause(buf *strings.Builder, partitions []*metadatapb.TablePartitionMetadata) error {if len(partitions) == 0 {return nil}@@ -695,35 +696,35 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn err}switch partitions[0].Type {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:if _, err := fmt.Fprintf(buf, "RANGE (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:if _, err := fmt.Fprintf(buf, "RANGE COLUMNS (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:if _, err := fmt.Fprintf(buf, "LIST (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:if _, err := fmt.Fprintf(buf, "LIST COLUMNS (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:if _, err := fmt.Fprintf(buf, "HASH (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:if _, err := fmt.Fprintf(buf, "KEY (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_HASH:+ case metadatapb.TablePartitionMetadata_LINEAR_HASH:if _, err := fmt.Fprintf(buf, "LINEAR HASH (%s)", partitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_LINEAR_KEY:if _, err := fmt.Fprintf(buf, "LINEAR KEY (%s)", partitions[0].Expression); err != nil {return err}@@ -750,19 +751,19 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn err}switch partitions[0].Subpartitions[0].Type {- case storepb.TablePartitionMetadata_HASH:+ case metadatapb.TablePartitionMetadata_HASH:if _, err := fmt.Fprintf(buf, "HASH (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_HASH:+ case metadatapb.TablePartitionMetadata_LINEAR_HASH:if _, err := fmt.Fprintf(buf, "LINEAR HASH (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_KEY:+ case metadatapb.TablePartitionMetadata_KEY:if _, err := fmt.Fprintf(buf, "KEY (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}- case storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_LINEAR_KEY:if _, err := fmt.Fprintf(buf, "LINEAR KEY (%s)", partitions[0].Subpartitions[0].Expression); err != nil {return err}@@ -857,17 +858,17 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TablePartireturn nil}-func getPrepositionByType(tp storepb.TablePartitionMetadata_Type) (string, error) {+func getPrepositionByType(tp metadatapb.TablePartitionMetadata_Type) (string, error) {switch tp {- case storepb.TablePartitionMetadata_RANGE:+ case metadatapb.TablePartitionMetadata_RANGE:return "LESS THAN", nil- case storepb.TablePartitionMetadata_RANGE_COLUMNS:+ case metadatapb.TablePartitionMetadata_RANGE_COLUMNS:return "LESS THAN", nil- case storepb.TablePartitionMetadata_LIST:+ case metadatapb.TablePartitionMetadata_LIST:return "IN", nil- case storepb.TablePartitionMetadata_LIST_COLUMNS:+ case metadatapb.TablePartitionMetadata_LIST_COLUMNS:return "IN", nil- case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_HASH, storepb.TablePartitionMetadata_LINEAR_KEY:+ case metadatapb.TablePartitionMetadata_HASH, metadatapb.TablePartitionMetadata_KEY, metadatapb.TablePartitionMetadata_LINEAR_HASH, metadatapb.TablePartitionMetadata_LINEAR_KEY:return "", nildefault:return "", errors.Errorf("unsupported partition type: %v", tp)@@ -907,26 +908,26 @@ func writePartitionOptions(buf io.StringWriter) error {return nil}-func getVersionSpecificComment(partitions []*storepb.TablePartitionMetadata) string {+func getVersionSpecificComment(partitions []*metadatapb.TablePartitionMetadata) string {if len(partitions) == 0 {return ""}partition := partitions[0]- if partition.Type == storepb.TablePartitionMetadata_RANGE_COLUMNS || partition.Type == storepb.TablePartitionMetadata_LIST_COLUMNS {+ if partition.Type == metadatapb.TablePartitionMetadata_RANGE_COLUMNS || partition.Type == metadatapb.TablePartitionMetadata_LIST_COLUMNS {// MySQL introduce columns partitioning in 5.5+return "\n/*!50500"}return "\n/*!50100"}-func printCheckClause(buf *strings.Builder, check *storepb.CheckConstraintMetadata) error {+func printCheckClause(buf *strings.Builder, check *metadatapb.CheckConstraintMetadata) error {if _, err := fmt.Fprintf(buf, ",\n CONSTRAINT `%s` CHECK %s", check.Name, check.Expression); err != nil {return err}return nil}-func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata) error {+func printForeignKeyClause(buf *strings.Builder, fk *metadatapb.ForeignKeyMetadata) error {if _, err := fmt.Fprintf(buf, ",\n CONSTRAINT `%s` FOREIGN KEY (", fk.Name); err != nil {return err}@@ -976,7 +977,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)return nil}-func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error {+func printIndexClause(buf *strings.Builder, index *metadatapb.IndexMetadata) error {if index.Primary {return nil}@@ -1067,7 +1068,7 @@ func printIndexKeyPart(buf *strings.Builder, expr string, length int64, descendireturn nil}-func printPrimaryKeyClause(buf *strings.Builder, table *storepb.TableMetadata) error {+func printPrimaryKeyClause(buf *strings.Builder, table *metadatapb.TableMetadata) error {for _, index := range table.GetIndexes() {if index.Primary {if _, err := fmt.Fprint(buf, ",\n PRIMARY KEY ("); err != nil {@@ -1104,15 +1105,15 @@ func printPrimaryKeyClause(buf *strings.Builder, table *storepb.TableMetadata) ereturn nil}-func isAutoIncrement(column *storepb.ColumnMetadata) bool {+func isAutoIncrement(column *metadatapb.ColumnMetadata) bool {return strings.EqualFold(column.GetDefault(), autoIncrementSymbol)}-func isAutoRandom(column *storepb.ColumnMetadata) bool {+func isAutoRandom(column *metadatapb.ColumnMetadata) bool {return strings.HasPrefix(column.GetDefault(), autoRandomSymbol)}-func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, table *storepb.TableMetadata) error {+func printColumnClause(buf *strings.Builder, column *metadatapb.ColumnMetadata, table *metadatapb.TableMetadata) error {if _, err := fmt.Fprintf(buf, " `%s` %s", column.Name, column.Type); err != nil {return err}@@ -1134,11 +1135,11 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tabreturn err}switch column.Generation.Type {- case storepb.GenerationMetadata_TYPE_STORED:+ case metadatapb.GenerationMetadata_TYPE_STORED:if _, err := fmt.Fprint(buf, "STORED"); err != nil {return err}- case storepb.GenerationMetadata_TYPE_VIRTUAL:+ case metadatapb.GenerationMetadata_TYPE_VIRTUAL:if _, err := fmt.Fprint(buf, "VIRTUAL"); err != nil {return err}@@ -1181,7 +1182,7 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tabreturn nil}-func printDefaultClause(buf *strings.Builder, column *storepb.ColumnMetadata) error {+func printDefaultClause(buf *strings.Builder, column *metadatapb.ColumnMetadata) error {// Check if column has any default valuehasDefault := column.Default != ""if !hasDefault {@@ -1233,7 +1234,7 @@ func typeSupportsDefaultValue(tp string) bool {}}-func writeInvalidTemporaryView(out io.Writer, view *storepb.ViewMetadata) error {+func writeInvalidTemporaryView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return err@@ -1263,7 +1264,7 @@ func writeInvalidTemporaryView(out io.Writer, view *storepb.ViewMetadata) errorreturn err}-func writeTemporaryView(out io.Writer, view *storepb.ViewMetadata) error {+func writeTemporaryView(out io.Writer, view *metadatapb.ViewMetadata) error {// Header.if _, err := io.WriteString(out, emptyCommentLine); err != nil {return errdiff --git a/backend/plugin/schema/tidb/get_database_definition_test.go b/backend/plugin/schema/tidb/get_database_definition_test.goindex ef9661ef34..adfbed2828 100644--- a/backend/plugin/schema/tidb/get_database_definition_test.go+++ b/backend/plugin/schema/tidb/get_database_definition_test.go@@ -4,12 +4,12 @@ import ("os""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""gopkg.in/yaml.v3""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/yamltest"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -38,7 +38,7 @@ func TestGetDatabaseDefinition(t *testing.T) {for i, tc := range tests {t.Run(tc.Description, func(t *testing.T) {- var metadata storepb.DatabaseSchemaMetadata+ var metadata metadatapb.DatabaseSchemaMetadatarequire.NoError(t, common.ProtojsonUnmarshaler.Unmarshal([]byte(tc.Metadata), &metadata))definition, err := GetDatabaseDefinition(schema.GetDefinitionContext{PrintHeader: true}, &metadata)diff --git a/backend/plugin/schema/tidb/get_database_metadata.go b/backend/plugin/schema/tidb/get_database_metadata.goindex 669ac98717..3a552714c5 100644--- a/backend/plugin/schema/tidb/get_database_metadata.go+++ b/backend/plugin/schema/tidb/get_database_metadata.go@@ -6,6 +6,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pingcap/tidb/pkg/parser""github.com/pingcap/tidb/pkg/parser/ast""github.com/pingcap/tidb/pkg/parser/mysql"@@ -24,7 +25,7 @@ func init() {}// GetDatabaseMetadata parses the database schema text and returns the metadata using TiDB's parser.-func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error) {+func GetDatabaseMetadata(schemaText string) (*metadatapb.DatabaseSchemaMetadata, error) {// Use TiDB's parser to parse the SQLp := parser.New()p.EnableWindowFunc(true)@@ -42,10 +43,10 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, er}extractor := &metadataExtractor{- schemas: make(map[string]*storepb.SchemaMetadata),- tables: make(map[tableKey]*storepb.TableMetadata),- views: make(map[viewKey]*storepb.ViewMetadata),- result: &storepb.DatabaseSchemaMetadata{+ schemas: make(map[string]*metadatapb.SchemaMetadata),+ tables: make(map[tableKey]*metadatapb.TableMetadata),+ views: make(map[viewKey]*metadatapb.ViewMetadata),+ result: &metadatapb.DatabaseSchemaMetadata{Name: "",},}@@ -59,31 +60,31 @@ func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, er}// Build the final metadata structure- defaultSchema := &storepb.SchemaMetadata{+ defaultSchema := &metadatapb.SchemaMetadata{Name: "",}// Add tables to schema- var tables []*storepb.TableMetadata+ var tables []*metadatapb.TableMetadatafor _, table := range extractor.tables {tables = append(tables, table)}- slices.SortFunc(tables, func(a, b *storepb.TableMetadata) int {+ slices.SortFunc(tables, func(a, b *metadatapb.TableMetadata) int {return strings.Compare(a.Name, b.Name)})defaultSchema.Tables = tables// Add views to schema- var views []*storepb.ViewMetadata+ var views []*metadatapb.ViewMetadatafor _, view := range extractor.views {views = append(views, view)}- slices.SortFunc(views, func(a, b *storepb.ViewMetadata) int {+ slices.SortFunc(views, func(a, b *metadatapb.ViewMetadata) int {return strings.Compare(a.Name, b.Name)})defaultSchema.Views = views- extractor.result.Schemas = []*storepb.SchemaMetadata{defaultSchema}+ extractor.result.Schemas = []*metadatapb.SchemaMetadata{defaultSchema}return extractor.result, nil}@@ -99,11 +100,11 @@ type viewKey struct {}type metadataExtractor struct {- schemas map[string]*storepb.SchemaMetadata- tables map[tableKey]*storepb.TableMetadata- views map[viewKey]*storepb.ViewMetadata+ schemas map[string]*metadatapb.SchemaMetadata+ tables map[tableKey]*metadatapb.TableMetadata+ views map[viewKey]*metadatapb.ViewMetadata- result *storepb.DatabaseSchemaMetadata+ result *metadatapb.DatabaseSchemaMetadata}func (m *metadataExtractor) processStatement(stmt ast.StmtNode) error {@@ -147,7 +148,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) errorschemaName = stmt.Table.Schema.O}- table := &storepb.TableMetadata{+ table := &metadatapb.TableMetadata{Name: tableName,Engine: "InnoDB", // Default for TiDBComment: "",@@ -155,7 +156,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) error// Process columnsfor i, col := range stmt.Cols {- column := &storepb.ColumnMetadata{+ column := &metadatapb.ColumnMetadata{Name: col.Name.Name.O,Position: int32(i + 1),Nullable: true, // Default, will be overridden by constraints@@ -212,7 +213,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) errorswitch constraint.Tp {case ast.ConstraintPrimaryKey:expressions, keyLengths, descending := m.getIndexColumnsInfo(constraint.Keys)- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: "PRIMARY",Primary: true,Unique: true,@@ -226,7 +227,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) errorcase ast.ConstraintKey, ast.ConstraintIndex:expressions, keyLengths, descending := m.getIndexColumnsInfo(constraint.Keys)- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: constraint.Name,Primary: false,Unique: false,@@ -240,7 +241,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) errorcase ast.ConstraintUniq, ast.ConstraintUniqKey, ast.ConstraintUniqIndex:expressions, keyLengths, descending := m.getIndexColumnsInfo(constraint.Keys)- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: constraint.Name,Primary: false,Unique: true,@@ -253,7 +254,7 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) errortable.Indexes = append(table.Indexes, index)case ast.ConstraintForeignKey:- fk := &storepb.ForeignKeyMetadata{+ fk := &metadatapb.ForeignKeyMetadata{Name: constraint.Name,Columns: m.getColumnNames(constraint.Keys),ReferencedTable: constraint.Refer.Table.Name.O,@@ -332,7 +333,7 @@ func (m *metadataExtractor) processCreateView(stmt *ast.CreateViewStmt) error {schemaName = stmt.ViewName.Schema.O}- view := &storepb.ViewMetadata{+ view := &metadatapb.ViewMetadata{Name: viewName,Definition: m.extractViewDefinition(stmt),Comment: "",@@ -591,7 +592,7 @@ func (*metadataExtractor) getReferenceAction(action ast.ReferOptionType) string}}-func (m *metadataExtractor) processTiDBTableComment(comment string, table *storepb.TableMetadata) {+func (m *metadataExtractor) processTiDBTableComment(comment string, table *metadatapb.TableMetadata) {// Process TiDB-specific table comment features like PK_AUTO_RANDOM_BITSpkAutoRandomBitsRegex := regexp.MustCompile(`PK_AUTO_RANDOM_BITS=(\d+)`)if matches := pkAutoRandomBitsRegex.FindStringSubmatch(comment); len(matches) > 1 {@@ -606,13 +607,13 @@ func (m *metadataExtractor) processTiDBTableComment(comment string, table *store}}-func (*metadataExtractor) processAutoRandom(_ *ast.CreateTableStmt, _ *storepb.TableMetadata) {+func (*metadataExtractor) processAutoRandom(_ *ast.CreateTableStmt, _ *metadatapb.TableMetadata) {// TiDB's AUTO_RANDOM is typically stored in table comments or special constraints// This is a simplified implementation - full AUTO_RANDOM support would require// parsing TiDB-specific syntax extensions}-func (*metadataExtractor) isPrimaryKeyColumn(column *storepb.ColumnMetadata, table *storepb.TableMetadata) bool {+func (*metadataExtractor) isPrimaryKeyColumn(column *metadatapb.ColumnMetadata, table *metadatapb.TableMetadata) bool {for _, index := range table.Indexes {if index.Primary {for _, expr := range index.Expressions {@@ -645,7 +646,7 @@ func (*metadataExtractor) extractCommentFromExpr(expr ast.ExprNode) string {return ""}-func (*metadataExtractor) processGeneratedColumn(option *ast.ColumnOption, column *storepb.ColumnMetadata) {+func (*metadataExtractor) processGeneratedColumn(option *ast.ColumnOption, column *metadatapb.ColumnMetadata) {if option.Expr != nil {// Extract the generation expressionvar generationExpr string@@ -684,7 +685,7 @@ func (*metadataExtractor) getIndexType(constraint *ast.Constraint) string {return indexType}-func (*metadataExtractor) processCheckConstraint(constraint *ast.Constraint, table *storepb.TableMetadata) {+func (*metadataExtractor) processCheckConstraint(constraint *ast.Constraint, table *metadatapb.TableMetadata) {// TiDB check constraints are handled differently// For now, skip processing as the AST structure may not have ExprInCheck// In a full implementation, we would need to check the constraint structure@@ -708,7 +709,7 @@ func (*metadataExtractor) extractViewDefinition(stmt *ast.CreateViewStmt) string}// processColumnLevelConstraints creates indexes for column-level PRIMARY KEY and UNIQUE constraints-func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStmt, table *storepb.TableMetadata) {+func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStmt, table *metadatapb.TableMetadata) {var primaryKeyColumns []stringvar uniqueConstraints []struct {columnName string@@ -748,7 +749,7 @@ func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStmkeyLengths[i] = -1 // No prefix length for column-level constraints}- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: "PRIMARY",Primary: true,Unique: true,@@ -763,7 +764,7 @@ func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStm// Create UNIQUE indexes for column-level unique constraintsfor _, unique := range uniqueConstraints {- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: unique.indexName,Primary: false,Unique: true,@@ -778,14 +779,14 @@ func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStm}// ensureForeignKeyIndexes creates indexes for all foreign key columns if they don't already exist-func (m *metadataExtractor) ensureForeignKeyIndexes(table *storepb.TableMetadata) {+func (m *metadataExtractor) ensureForeignKeyIndexes(table *metadatapb.TableMetadata) {for _, fk := range table.ForeignKeys {m.ensureForeignKeyIndex(fk, table)}}// ensureForeignKeyIndex creates an index for foreign key columns if one doesn't already exist-func (*metadataExtractor) ensureForeignKeyIndex(fk *storepb.ForeignKeyMetadata, table *storepb.TableMetadata) {+func (*metadataExtractor) ensureForeignKeyIndex(fk *metadatapb.ForeignKeyMetadata, table *metadatapb.TableMetadata) {// Check if an index already exists that covers the foreign key columnsfkColumns := fk.Columns@@ -819,7 +820,7 @@ func (*metadataExtractor) ensureForeignKeyIndex(fk *storepb.ForeignKeyMetadata,keyLengths[i] = -1 // No prefix length for FK indexes}- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: indexName,Primary: false,Unique: false,diff --git a/backend/plugin/schema/tidb/walk_through.go b/backend/plugin/schema/tidb/walk_through.goindex da1eac0728..f18bda8f27 100644--- a/backend/plugin/schema/tidb/walk_through.go+++ b/backend/plugin/schema/tidb/walk_through.go@@ -5,6 +5,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata"tidbast "github.com/pingcap/tidb/pkg/parser/ast""github.com/pingcap/tidb/pkg/parser/format""github.com/pingcap/tidb/pkg/parser/mysql"@@ -391,7 +392,7 @@ func tidbAlterTable(d *model.DatabaseMetadata, node *tidbast.AlterTableStmt) *st// Sort and renumber columns after adding// CreateColumn appends to end, but tidbReorderColumn sets position valuestableProto := table.GetProto()- slices.SortFunc(tableProto.Columns, func(a, b *storepb.ColumnMetadata) int {+ slices.SortFunc(tableProto.Columns, func(a, b *metadatapb.ColumnMetadata) int {if a.Position < b.Position {return -1} else if a.Position > b.Position {@@ -744,7 +745,7 @@ func tidbCompleteTableChangeColumn(t *model.TableMetadata, oldName string, newCo// CreateColumn appends to the end, but tidbReorderColumn sets position values,// so we need to sort the array to match the position valuestableProto := t.GetProto()- slices.SortFunc(tableProto.Columns, func(a, b *storepb.ColumnMetadata) int {+ slices.SortFunc(tableProto.Columns, func(a, b *metadatapb.ColumnMetadata) int {if a.Position < b.Position {return -1} else if a.Position > b.Position {@@ -888,7 +889,7 @@ func tidbCopyTable(d *model.DatabaseMetadata, node *tidbast.CreateTableStmt) *st// Copy columns and indexes from the target tablefor _, col := range targetTable.GetProto().GetColumns() {- colCopy, ok := proto.Clone(col).(*storepb.ColumnMetadata)+ colCopy, ok := proto.Clone(col).(*metadatapb.ColumnMetadata)if !ok {return &storepb.Advice{Status: storepb.Advice_ERROR,@@ -909,7 +910,7 @@ func tidbCopyTable(d *model.DatabaseMetadata, node *tidbast.CreateTableStmt) *st}}for _, idx := range targetTable.GetProto().Indexes {- idxCopy, ok := proto.Clone(idx).(*storepb.IndexMetadata)+ idxCopy, ok := proto.Clone(idx).(*metadatapb.IndexMetadata)if !ok {return &storepb.Advice{Status: storepb.Advice_ERROR,@@ -1180,7 +1181,7 @@ func tidbCreateColumnHelper(t *model.TableMetadata, column *tidbast.ColumnDef, p}}- col := &storepb.ColumnMetadata{+ col := &metadatapb.ColumnMetadata{Name: column.Name.Name.L,Position: int32(pos),Default: "",@@ -1334,7 +1335,7 @@ func tidbCreateIndexHelper(t *model.TableMetadata, name string, keyList []stringvisible := option == nil || option.Visibility != tidbast.IndexVisibilityInvisible- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: name,Expressions: keyList,Type: tp,@@ -1367,7 +1368,7 @@ func tidbCreatePrimaryKeyHelper(t *model.TableMetadata, keys []string, tp string}}- pk := &storepb.IndexMetadata{+ pk := &metadatapb.IndexMetadata{Name: PrimaryKeyName,Expressions: keys,Type: tp,diff --git a/backend/plugin/schema/tidb/walk_through_test.go b/backend/plugin/schema/tidb/walk_through_test.goindex 4ef01803e2..54a2d6f317 100644--- a/backend/plugin/schema/tidb/walk_through_test.go+++ b/backend/plugin/schema/tidb/walk_through_test.go@@ -6,6 +6,7 @@ import ("path/filepath""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/google/go-cmp/cmp""github.com/stretchr/testify/require""google.golang.org/protobuf/proto"@@ -28,7 +29,7 @@ type testData struct {}func TestWalkThrough(t *testing.T) {- originDatabase := &storepb.DatabaseSchemaMetadata{+ originDatabase := &metadatapb.DatabaseSchemaMetadata{Name: "test",}@@ -46,7 +47,7 @@ func TestWalkThrough(t *testing.T) {for _, test := range tests {// Make a deep copy to avoid mutation across tests- protoData, ok := proto.Clone(originDatabase).(*storepb.DatabaseSchemaMetadata)+ protoData, ok := proto.Clone(originDatabase).(*metadatapb.DatabaseSchemaMetadata)require.True(t, ok)// Create DatabaseMetadata for walk-through@@ -67,14 +68,14 @@ func TestWalkThrough(t *testing.T) {continue}- want := &storepb.DatabaseSchemaMetadata{}+ want := &metadatapb.DatabaseSchemaMetadata{}err := common.ProtojsonUnmarshaler.Unmarshal([]byte(test.Want), want)require.NoError(t, err)result := state.GetProto()diff := cmp.Diff(want, result, protocmp.Transform(),- protocmp.SortRepeatedFields(&storepb.DatabaseSchemaMetadata{}, "schemas"),- protocmp.SortRepeatedFields(&storepb.SchemaMetadata{}, "tables", "views"),- protocmp.SortRepeatedFields(&storepb.TableMetadata{}, "indexes", "columns"),+ protocmp.SortRepeatedFields(&metadatapb.DatabaseSchemaMetadata{}, "schemas"),+ protocmp.SortRepeatedFields(&metadatapb.SchemaMetadata{}, "tables", "views"),+ protocmp.SortRepeatedFields(&metadatapb.TableMetadata{}, "indexes", "columns"),)require.Empty(t, diff)}diff --git a/backend/plugin/schema/trino/get_database_definition.go b/backend/plugin/schema/trino/get_database_definition.goindex cead777489..b2d36679b1 100644--- a/backend/plugin/schema/trino/get_database_definition.go+++ b/backend/plugin/schema/trino/get_database_definition.go@@ -4,6 +4,7 @@package trinoimport (+ metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/trino/deparse"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -18,14 +19,14 @@ func init() {// schema. It converts the storepb metadata into the omni deparser's metadata// model and delegates to deparse.GetDatabaseDefinition, which emits one CREATE// TABLE statement per table in schema-then-table snapshot order.-func GetDatabaseDefinition(_ schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error) {+func GetDatabaseDefinition(_ schema.GetDefinitionContext, metadata *metadatapb.DatabaseSchemaMetadata) (string, error) {return deparse.GetDatabaseDefinition(convertDatabaseMetadata(metadata))}-// convertDatabaseMetadata maps storepb.DatabaseSchemaMetadata onto the omni+// convertDatabaseMetadata maps metadatapb.DatabaseSchemaMetadata onto the omni// deparse metadata model one-to-one, copying only the fields the Trino SDL dump// consumes (schemas, tables, and column Name/Type/Nullable).-func convertDatabaseMetadata(metadata *storepb.DatabaseSchemaMetadata) *deparse.DatabaseSchemaMetadata {+func convertDatabaseMetadata(metadata *metadatapb.DatabaseSchemaMetadata) *deparse.DatabaseSchemaMetadata {if metadata == nil {return nil}diff --git a/backend/plugin/schema/trino/get_database_definition_test.go b/backend/plugin/schema/trino/get_database_definition_test.goindex d903e6e1d5..bac50288ef 100644--- a/backend/plugin/schema/trino/get_database_definition_test.go+++ b/backend/plugin/schema/trino/get_database_definition_test.go@@ -3,10 +3,10 @@ package trinoimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"- storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/schema")@@ -15,16 +15,16 @@ func TestGetDatabaseDefinition(t *testing.T) {name stringcatalog stringschema string- table *storepb.TableMetadata+ table *metadatapb.TableMetadataexpected string}{{name: "Simple table",catalog: "testcatalog",schema: "testschema",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "testtable",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",Type: "bigint",@@ -48,9 +48,9 @@ func TestGetDatabaseDefinition(t *testing.T) {name: "Empty columns",catalog: "testcatalog",schema: "testschema",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "empty_table",- Columns: []*storepb.ColumnMetadata{},+ Columns: []*metadatapb.ColumnMetadata{},},expected: `CREATE TABLE IF NOT EXISTS "testschema"."empty_table" (@@ -62,9 +62,9 @@ func TestGetDatabaseDefinition(t *testing.T) {name: "Special characters in identifiers",catalog: "test-catalog",schema: "test_schema",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "test.table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id-field",Type: "bigint",@@ -82,12 +82,12 @@ func TestGetDatabaseDefinition(t *testing.T) {a := require.New(t)for _, tt := range tests {t.Run(tt.name, func(_ *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: tt.catalog,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: tt.schema,- Tables: []*storepb.TableMetadata{tt.table},+ Tables: []*metadatapb.TableMetadata{tt.table},},},}@@ -109,16 +109,16 @@ func TestWriteCreateTable(t *testing.T) {name stringcatalog stringschema string- table *storepb.TableMetadata+ table *metadatapb.TableMetadataexpected string}{{name: "Simple table",catalog: "catalog",schema: "schema",- table: &storepb.TableMetadata{+ table: &metadatapb.TableMetadata{Name: "table",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "col1",Type: "integer",@@ -136,12 +136,12 @@ func TestWriteCreateTable(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: tt.catalog,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: tt.schema,- Tables: []*storepb.TableMetadata{tt.table},+ Tables: []*metadatapb.TableMetadata{tt.table},},},}diff --git a/backend/plugin/schema/view_comparer.go b/backend/plugin/schema/view_comparer.goindex 7acced1b95..38c40260c5 100644--- a/backend/plugin/schema/view_comparer.go+++ b/backend/plugin/schema/view_comparer.go@@ -1,6 +1,8 @@package schemaimport (+ metadatapb "github.com/bytebase/omni/metadata"+storepb "github.com/bytebase/bytebase/backend/generated-go/store")@@ -59,17 +61,17 @@ type MaterializedViewChange struct {// ViewComparer provides engine-specific view comparison logic.type ViewComparer interface {// CompareView compares two views and returns the detected changes.- CompareView(oldView, newView *storepb.ViewMetadata) ([]ViewChange, error)+ CompareView(oldView, newView *metadatapb.ViewMetadata) ([]ViewChange, error)// CompareMaterializedView compares two materialized views and returns the detected changes.- CompareMaterializedView(oldMV, newMV *storepb.MaterializedViewMetadata) ([]MaterializedViewChange, error)+ CompareMaterializedView(oldMV, newMV *metadatapb.MaterializedViewMetadata) ([]MaterializedViewChange, error)}// DefaultViewComparer provides default view comparison logic that can be used by most engines.type DefaultViewComparer struct{}// CompareView compares two views using default logic.-func (*DefaultViewComparer) CompareView(oldView, newView *storepb.ViewMetadata) ([]ViewChange, error) {+func (*DefaultViewComparer) CompareView(oldView, newView *metadatapb.ViewMetadata) ([]ViewChange, error) {if oldView == nil || newView == nil {return nil, nil}@@ -98,7 +100,7 @@ func (*DefaultViewComparer) CompareView(oldView, newView *storepb.ViewMetadata)}// CompareMaterializedView compares two materialized views using default logic.-func (*DefaultViewComparer) CompareMaterializedView(oldMV, newMV *storepb.MaterializedViewMetadata) ([]MaterializedViewChange, error) {+func (*DefaultViewComparer) CompareMaterializedView(oldMV, newMV *metadatapb.MaterializedViewMetadata) ([]MaterializedViewChange, error) {if oldMV == nil || newMV == nil {return nil, nil}diff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.goindex 9d8e7a2b4f..3e039c1ca0 100644--- a/backend/runner/plancheck/statement_advise_executor.go+++ b/backend/runner/plancheck/statement_advise_executor.go@@ -4,6 +4,7 @@ import ("context""fmt"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""google.golang.org/protobuf/proto"@@ -122,7 +123,7 @@ func (e *StatementAdviseExecutor) runReview(originMetadata := model.NewDatabaseMetadata(dbMetadata.GetProto(), nil, nil, instance.Metadata.GetEngine(), store.IsObjectCaseSensitive(instance))// Clone metadata for final to avoid modifying the original- clonedMetadata, ok := proto.Clone(dbMetadata.GetProto()).(*storepb.DatabaseSchemaMetadata)+ clonedMetadata, ok := proto.Clone(dbMetadata.GetProto()).(*metadatapb.DatabaseSchemaMetadata)if !ok {return nil, common.Wrapf(errors.New("failed to clone database schema metadata"), common.Internal, "failed to create a catalog")}diff --git a/backend/runner/schemasync/pool_test.go b/backend/runner/schemasync/pool_test.goindex bb467592c2..98ec2829aa 100644--- a/backend/runner/schemasync/pool_test.go+++ b/backend/runner/schemasync/pool_test.go@@ -6,6 +6,7 @@ import ("testing""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require""github.com/bytebase/bytebase/backend/common"@@ -31,11 +32,11 @@ func (d *poolTestDriver) Open(context.Context, storepb.Engine, db.ConnectionConffunc (*poolTestDriver) Close(context.Context) error { return nil }-func (*poolTestDriver) SyncDBSchema(context.Context) (*storepb.DatabaseSchemaMetadata, error) {- return &storepb.DatabaseSchemaMetadata{Name: "app"}, nil+func (*poolTestDriver) SyncDBSchema(context.Context) (*metadatapb.DatabaseSchemaMetadata, error) {+ return &metadatapb.DatabaseSchemaMetadata{Name: "app"}, nil}-func (*poolTestDriver) Dump(context.Context, io.Writer, *storepb.DatabaseSchemaMetadata) error {+func (*poolTestDriver) Dump(context.Context, io.Writer, *metadatapb.DatabaseSchemaMetadata) error {return nil}diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.goindex 1e4d37d092..2e7374a0a2 100644--- a/backend/runner/schemasync/syncer.go+++ b/backend/runner/schemasync/syncer.go@@ -13,6 +13,7 @@ import ("sync/atomic""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""github.com/sourcegraph/conc/pool""google.golang.org/protobuf/encoding/protojson"@@ -449,7 +450,7 @@ func (s *Syncer) GetInstanceMeta(ctx context.Context, instance *store.InstanceMe}// SyncInstance syncs the schema for all databases in an instance.-func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessage) (updatedInstance *store.InstanceMessage, allDatabases []*storepb.DatabaseSchemaMetadata, newDatabases []*store.DatabaseMessage, retErr error) {+func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessage) (updatedInstance *store.InstanceMessage, allDatabases []*metadatapb.DatabaseSchemaMetadata, newDatabases []*store.DatabaseMessage, retErr error) {startedAt := time.Now()defer func() {panicValue := recover()@@ -488,7 +489,7 @@ func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessaif err != nil {return nil, nil, nil, errors.Wrapf(err, "failed to sync database for instance: %s. Failed to find database list", instance.ResourceID)}- var filteredDatabaseMetadatas []*storepb.DatabaseSchemaMetadata+ var filteredDatabaseMetadatas []*metadatapb.DatabaseSchemaMetadatavar databaseProjectID stringif instance.ProjectID != nil {databaseProjectID = *instance.ProjectID@@ -522,7 +523,7 @@ func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessa}for _, database := range databases {- idx := slices.IndexFunc(filteredDatabaseMetadatas, func(db *storepb.DatabaseSchemaMetadata) bool { return db.Name == database.DatabaseName })+ idx := slices.IndexFunc(filteredDatabaseMetadatas, func(db *metadatapb.DatabaseSchemaMetadata) bool { return db.Name == database.DatabaseName })if idx < 0 {if _, err := s.store.UpdateDatabase(ctx, &store.UpdateDatabaseMessage{InstanceID: instance.ResourceID,@@ -590,7 +591,7 @@ func (s *Syncer) doSyncDatabaseSchema(ctx context.Context, database *store.Datab// If the schema does not exist, then we create a new one.// This happens when creating a new database in the test.if dbMetadata == nil {- dbMetadata = model.NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{}, nil, &storepb.DatabaseConfig{}, instance.Metadata.GetEngine(), store.IsObjectCaseSensitive(instance))+ dbMetadata = model.NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{}, nil, &storepb.DatabaseConfig{}, instance.Metadata.GetEngine(), store.IsObjectCaseSensitive(instance))}dbConfig := dbMetadata.GetConfig()@@ -667,7 +668,7 @@ func (s *Syncer) SyncDatabaseSchema(ctx context.Context, database *store.Databasreturn err}-func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.InstanceMessage, dbMetadata *storepb.DatabaseSchemaMetadata) bool {+func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.InstanceMessage, dbMetadata *metadatapb.DatabaseSchemaMetadata) bool {if !common.EngineSupportPriorBackup(instance.Metadata.GetEngine()) {return false}diff --git a/backend/store/db_schema.go b/backend/store/db_schema.goindex 366354c06c..f04aedf816 100644--- a/backend/store/db_schema.go+++ b/backend/store/db_schema.go@@ -4,6 +4,7 @@ import ("context""database/sql"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -79,7 +80,7 @@ func (s *Store) UpsertDBSchema(ctx context.Context,instanceID,databaseName string,- dbMetadata *storepb.DatabaseSchemaMetadata,+ dbMetadata *metadatapb.DatabaseSchemaMetadata,dbConfig *storepb.DatabaseConfig,rawDump []byte,) error {@@ -172,7 +173,7 @@ func (s *Store) UpdateDBSchema(ctx context.Context, instanceID, databaseName str}func (s *Store) convertMetadataAndConfig(ctx context.Context, metadata, schema, config []byte, workspaceID string, instanceID string) (*model.DatabaseMetadata, error) {- var databaseSchema storepb.DatabaseSchemaMetadata+ var databaseSchema metadatapb.DatabaseSchemaMetadatavar databaseConfig storepb.DatabaseConfigif err := common.ProtojsonUnmarshaler.Unmarshal(metadata, &databaseSchema); err != nil {return nil, errdiff --git a/backend/store/model/database.go b/backend/store/model/database.goindex d09bc7081d..56cfa95b65 100644--- a/backend/store/model/database.go+++ b/backend/store/model/database.go@@ -4,6 +4,7 @@ import ("slices""strings"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -13,7 +14,7 @@ import (// This struct combines what were previously separate types: DatabaseMetadata, and DatabaseConfig.type DatabaseMetadata struct {// Proto representations for serialization- proto *storepb.DatabaseSchemaMetadata+ proto *metadatapb.DatabaseSchemaMetadataconfig *storepb.DatabaseConfigrawDump []byte@@ -24,7 +25,7 @@ type DatabaseMetadata struct {// Metadata fields (formerly in DatabaseMetadata)searchPath []PGSearchPathIteminternal map[string]*SchemaMetadata- linkedDatabase map[string]*storepb.LinkedDatabaseMetadata+ linkedDatabase map[string]*metadatapb.LinkedDatabaseMetadata}// SchemaMetadata is the unified metadata for a schema, combining proto metadata and catalog config.@@ -38,13 +39,13 @@ type SchemaMetadata struct {// partition shadow a root table and hand callers the wrong table's proto.internalPartitionTables map[string]*TableMetadatainternalExternalTable map[string]*ExternalTableMetadata- internalViews map[string]*storepb.ViewMetadata- internalMaterializedView map[string]*storepb.MaterializedViewMetadata- internalProcedures map[string]*storepb.ProcedureMetadata- internalSequences map[string]*storepb.SequenceMetadata- internalPackages map[string]*storepb.PackageMetadata+ internalViews map[string]*metadatapb.ViewMetadata+ internalMaterializedView map[string]*metadatapb.MaterializedViewMetadata+ internalProcedures map[string]*metadatapb.ProcedureMetadata+ internalSequences map[string]*metadatapb.SequenceMetadata+ internalPackages map[string]*metadatapb.PackageMetadata- proto *storepb.SchemaMetadata+ proto *metadatapb.SchemaMetadataconfig *storepb.SchemaCatalog}@@ -57,25 +58,25 @@ type TableMetadata struct {internalColumn map[string]*ColumnMetadatainternalIndexes map[string]*IndexMetadata- proto *storepb.TableMetadata+ proto *metadatapb.TableMetadataconfig *storepb.TableCatalog}// ExternalTableMetadata is the metadata for a external table.type ExternalTableMetadata struct {isDetailCaseSensitive bool- internal map[string]*storepb.ColumnMetadata- proto *storepb.ExternalTableMetadata+ internal map[string]*metadatapb.ColumnMetadata+ proto *metadatapb.ExternalTableMetadata}type IndexMetadata struct {- tableProto *storepb.TableMetadata- proto *storepb.IndexMetadata+ tableProto *metadatapb.TableMetadata+ proto *metadatapb.IndexMetadata}// ColumnMetadata is the unified metadata for a column, combining proto metadata and catalog config.type ColumnMetadata struct {- proto *storepb.ColumnMetadata+ proto *metadatapb.ColumnMetadataconfig *storepb.ColumnCatalog}@@ -89,7 +90,7 @@ func normalizeNameByCaseSensitivity(name string, caseSensitive bool) string {}func NewDatabaseMetadata(- metadata *storepb.DatabaseSchemaMetadata,+ metadata *metadatapb.DatabaseSchemaMetadata,schema []byte,config *storepb.DatabaseConfig,engine storepb.Engine,@@ -104,7 +105,7 @@ func NewDatabaseMetadata(isDetailCaseSensitive: isDetailCaseSensitive,searchPath: ParsePGConfiguredSearchPath(metadata.SearchPath),internal: make(map[string]*SchemaMetadata),- linkedDatabase: make(map[string]*storepb.LinkedDatabaseMetadata),+ linkedDatabase: make(map[string]*metadatapb.LinkedDatabaseMetadata),}// Build a map of schema catalogs for quick lookup@@ -134,11 +135,11 @@ func NewDatabaseMetadata(internalTables: make(map[string]*TableMetadata),internalPartitionTables: make(map[string]*TableMetadata),internalExternalTable: make(map[string]*ExternalTableMetadata),- internalViews: make(map[string]*storepb.ViewMetadata),- internalMaterializedView: make(map[string]*storepb.MaterializedViewMetadata),- internalProcedures: make(map[string]*storepb.ProcedureMetadata),- internalPackages: make(map[string]*storepb.PackageMetadata),- internalSequences: make(map[string]*storepb.SequenceMetadata),+ internalViews: make(map[string]*metadatapb.ViewMetadata),+ internalMaterializedView: make(map[string]*metadatapb.MaterializedViewMetadata),+ internalProcedures: make(map[string]*metadatapb.ProcedureMetadata),+ internalPackages: make(map[string]*metadatapb.PackageMetadata),+ internalSequences: make(map[string]*metadatapb.SequenceMetadata),proto: s,config: schemaCatalog,}@@ -157,7 +158,7 @@ func NewDatabaseMetadata(for _, externalTable := range s.ExternalTables {externalTableMetadata := &ExternalTableMetadata{isDetailCaseSensitive: isDetailCaseSensitive,- internal: make(map[string]*storepb.ColumnMetadata),+ internal: make(map[string]*metadatapb.ColumnMetadata),proto: externalTable,}for _, column := range externalTable.Columns {@@ -199,7 +200,7 @@ func NewDatabaseMetadata(return dbMetadata}-func (d *DatabaseMetadata) GetProto() *storepb.DatabaseSchemaMetadata {+func (d *DatabaseMetadata) GetProto() *metadatapb.DatabaseSchemaMetadata {return d.proto}@@ -270,7 +271,7 @@ func (d *DatabaseMetadata) ListSchemaNames() []string {return result}-func (d *DatabaseMetadata) GetLinkedDatabase(name string) *storepb.LinkedDatabaseMetadata {+func (d *DatabaseMetadata) GetLinkedDatabase(name string) *metadatapb.LinkedDatabaseMetadata {nameID := normalizeNameByCaseSensitivity(name, d.isObjectCaseSensitive)return d.linkedDatabase[nameID]}@@ -281,10 +282,10 @@ func (d *DatabaseMetadata) GetIsObjectCaseSensitive() bool {func (d *DatabaseMetadata) CreateSchema(schemaName string) *SchemaMetadata {// Create new schema proto- newSchemaProto := &storepb.SchemaMetadata{+ newSchemaProto := &metadatapb.SchemaMetadata{Name: schemaName,- Tables: []*storepb.TableMetadata{},- Views: []*storepb.ViewMetadata{},+ Tables: []*metadatapb.TableMetadata{},+ Views: []*metadatapb.ViewMetadata{},}// Add to proto's schema list@@ -297,11 +298,11 @@ func (d *DatabaseMetadata) CreateSchema(schemaName string) *SchemaMetadata {internalTables: make(map[string]*TableMetadata),internalPartitionTables: make(map[string]*TableMetadata),internalExternalTable: make(map[string]*ExternalTableMetadata),- internalViews: make(map[string]*storepb.ViewMetadata),- internalMaterializedView: make(map[string]*storepb.MaterializedViewMetadata),- internalProcedures: make(map[string]*storepb.ProcedureMetadata),- internalPackages: make(map[string]*storepb.PackageMetadata),- internalSequences: make(map[string]*storepb.SequenceMetadata),+ internalViews: make(map[string]*metadatapb.ViewMetadata),+ internalMaterializedView: make(map[string]*metadatapb.MaterializedViewMetadata),+ internalProcedures: make(map[string]*metadatapb.ProcedureMetadata),+ internalPackages: make(map[string]*metadatapb.PackageMetadata),+ internalSequences: make(map[string]*metadatapb.SequenceMetadata),proto: newSchemaProto,}@@ -323,7 +324,7 @@ func (d *DatabaseMetadata) DropSchema(schemaName string) error {delete(d.internal, schemaID)// Remove from proto's schema list- newSchemas := make([]*storepb.SchemaMetadata, 0, len(d.proto.Schemas)-1)+ newSchemas := make([]*metadatapb.SchemaMetadata, 0, len(d.proto.Schemas)-1)for _, schema := range d.proto.Schemas {if d.isObjectCaseSensitive {if schema.Name != schemaName {@@ -385,7 +386,7 @@ func (s *SchemaMetadata) GetIndex(name string) *IndexMetadata {// Return a wrapper IndexMetadata for the materialized view indexreturn &IndexMetadata{proto: idx,- tableProto: &storepb.TableMetadata{Name: mv.Name},+ tableProto: &metadatapb.TableMetadata{Name: mv.Name},}}}@@ -394,23 +395,23 @@ func (s *SchemaMetadata) GetIndex(name string) *IndexMetadata {}// GetView gets the view by name.-func (s *SchemaMetadata) GetView(name string) *storepb.ViewMetadata {+func (s *SchemaMetadata) GetView(name string) *metadatapb.ViewMetadata {nameID := normalizeNameByCaseSensitivity(name, s.isObjectCaseSensitive)return s.internalViews[nameID]}-func (s *SchemaMetadata) GetProcedure(name string) *storepb.ProcedureMetadata {+func (s *SchemaMetadata) GetProcedure(name string) *metadatapb.ProcedureMetadata {nameID := normalizeNameByCaseSensitivity(name, s.isDetailCaseSensitive)return s.internalProcedures[nameID]}-func (s *SchemaMetadata) GetPackage(name string) *storepb.PackageMetadata {+func (s *SchemaMetadata) GetPackage(name string) *metadatapb.PackageMetadata {nameID := normalizeNameByCaseSensitivity(name, s.isDetailCaseSensitive)return s.internalPackages[nameID]}// GetMaterializedView gets the materialized view by name.-func (s *SchemaMetadata) GetMaterializedView(name string) *storepb.MaterializedViewMetadata {+func (s *SchemaMetadata) GetMaterializedView(name string) *metadatapb.MaterializedViewMetadata {nameID := normalizeNameByCaseSensitivity(name, s.isObjectCaseSensitive)return s.internalMaterializedView[nameID]}@@ -424,7 +425,7 @@ func (s *SchemaMetadata) GetExternalTable(name string) *ExternalTableMetadata {// GetFunction gets the function by name.// Note: For overloaded functions, this returns the first match by name only.// Use signature-based lookup for precise matching.-func (s *SchemaMetadata) GetFunction(name string) *storepb.FunctionMetadata {+func (s *SchemaMetadata) GetFunction(name string) *metadatapb.FunctionMetadata {for _, function := range s.proto.GetFunctions() {if s.isDetailCaseSensitive {if function.Name == name {@@ -440,13 +441,13 @@ func (s *SchemaMetadata) GetFunction(name string) *storepb.FunctionMetadata {}// GetSequence gets the sequence by name.-func (s *SchemaMetadata) GetSequence(name string) *storepb.SequenceMetadata {+func (s *SchemaMetadata) GetSequence(name string) *metadatapb.SequenceMetadata {nameID := normalizeNameByCaseSensitivity(name, s.isDetailCaseSensitive)return s.internalSequences[nameID]}-func (s *SchemaMetadata) GetSequencesByOwnerTable(name string) []*storepb.SequenceMetadata {- var result []*storepb.SequenceMetadata+func (s *SchemaMetadata) GetSequencesByOwnerTable(name string) []*metadatapb.SequenceMetadata {+ var result []*metadatapb.SequenceMetadatafor _, sequence := range s.internalSequences {if s.isObjectCaseSensitive {if sequence.OwnerTable == name {@@ -462,7 +463,7 @@ func (s *SchemaMetadata) GetSequencesByOwnerTable(name string) []*storepb.Sequen}// GetProto gets the proto of SchemaMetadata.-func (s *SchemaMetadata) GetProto() *storepb.SchemaMetadata {+func (s *SchemaMetadata) GetProto() *metadatapb.SchemaMetadata {return s.proto}@@ -549,10 +550,10 @@ func (s *SchemaMetadata) CreateTable(tableName string) (*TableMetadata, error) {}// Create new table proto- newTableProto := &storepb.TableMetadata{+ newTableProto := &metadatapb.TableMetadata{Name: tableName,- Columns: []*storepb.ColumnMetadata{},- Indexes: []*storepb.IndexMetadata{},+ Columns: []*metadatapb.ColumnMetadata{},+ Indexes: []*metadatapb.IndexMetadata{},}// Add to proto's table list@@ -586,7 +587,7 @@ func (s *SchemaMetadata) DropTable(tableName string) error {delete(s.internalTables, tableID)// Remove from proto's table list- newTables := make([]*storepb.TableMetadata, 0, len(s.proto.Tables)-1)+ newTables := make([]*metadatapb.TableMetadata, 0, len(s.proto.Tables)-1)for _, table := range s.proto.Tables {if s.isObjectCaseSensitive {if table.Name != tableName {@@ -637,14 +638,14 @@ func (s *SchemaMetadata) RenameTable(oldName string, newName string) error {// CreateView creates a new view in the schema.// Returns an error if the view already exists.-func (s *SchemaMetadata) CreateView(viewName string, definition string, dependencyColumns []*storepb.DependencyColumn) (*storepb.ViewMetadata, error) {+func (s *SchemaMetadata) CreateView(viewName string, definition string, dependencyColumns []*metadatapb.DependencyColumn) (*metadatapb.ViewMetadata, error) {// Check if view already existsif s.GetView(viewName) != nil {return nil, errors.Errorf("view %q already exists in schema %q", viewName, s.proto.Name)}// Create new view proto- newViewProto := &storepb.ViewMetadata{+ newViewProto := &metadatapb.ViewMetadata{Name: viewName,Definition: definition,DependencyColumns: dependencyColumns,@@ -673,7 +674,7 @@ func (s *SchemaMetadata) DropView(viewName string) error {delete(s.internalViews, viewID)// Remove from proto's view list- newViews := make([]*storepb.ViewMetadata, 0, len(s.proto.Views)-1)+ newViews := make([]*metadatapb.ViewMetadata, 0, len(s.proto.Views)-1)for _, view := range s.proto.Views {if s.isObjectCaseSensitive {if view.Name != viewName {@@ -724,14 +725,14 @@ func (s *SchemaMetadata) RenameView(oldName string, newName string) error {// CreateMaterializedView creates a new materialized view in the schema.// Returns an error if the materialized view already exists.-func (s *SchemaMetadata) CreateMaterializedView(viewName string, definition string) (*storepb.MaterializedViewMetadata, error) {+func (s *SchemaMetadata) CreateMaterializedView(viewName string, definition string) (*metadatapb.MaterializedViewMetadata, error) {// Check if materialized view already existsif s.GetMaterializedView(viewName) != nil {return nil, errors.Errorf("materialized view %q already exists in schema %q", viewName, s.proto.Name)}// Create new materialized view proto- newViewProto := &storepb.MaterializedViewMetadata{+ newViewProto := &metadatapb.MaterializedViewMetadata{Name: viewName,Definition: definition,}@@ -759,7 +760,7 @@ func (s *SchemaMetadata) DropMaterializedView(viewName string) error {delete(s.internalMaterializedView, viewID)// Remove from proto's materialized view list- newViews := make([]*storepb.MaterializedViewMetadata, 0, len(s.proto.MaterializedViews)-1)+ newViews := make([]*metadatapb.MaterializedViewMetadata, 0, len(s.proto.MaterializedViews)-1)for _, view := range s.proto.MaterializedViews {if s.isObjectCaseSensitive {if view.Name != viewName {@@ -784,7 +785,7 @@ func (s *SchemaMetadata) DropMaterializedViewIndex(viewName, indexName string) e}// Remove from indexes- newIndexes := make([]*storepb.IndexMetadata, 0, len(mv.Indexes))+ newIndexes := make([]*metadatapb.IndexMetadata, 0, len(mv.Indexes))found := falsefor _, idx := range mv.Indexes {if s.isObjectCaseSensitive {@@ -850,7 +851,7 @@ func (s *SchemaMetadata) GetDependentViews(tableName string, columnName string)return dependentViews}-func buildTablesMetadata(table *storepb.TableMetadata, tableCatalog *storepb.TableCatalog, isDetailCaseSensitive bool) ([]*TableMetadata, []string) {+func buildTablesMetadata(table *metadatapb.TableMetadata, tableCatalog *storepb.TableCatalog, isDetailCaseSensitive bool) ([]*TableMetadata, []string) {if table == nil {return nil, nil}@@ -896,7 +897,7 @@ func buildTablesMetadata(table *storepb.TableMetadata, tableCatalog *storepb.Tabreturn result, name}-func buildIndexesMetadata(table *storepb.TableMetadata) []*IndexMetadata {+func buildIndexesMetadata(table *metadatapb.TableMetadata) []*IndexMetadata {if table == nil {return nil}@@ -915,7 +916,7 @@ func buildIndexesMetadata(table *storepb.TableMetadata) []*IndexMetadata {// buildTablesMetadataRecursive builds the partition tables recursively,// returns the table metadata and the partition names, the length of them must be the same.-func buildTablesMetadataRecursive(originalColumn []*storepb.ColumnMetadata, columnCatalogMap map[string]*storepb.ColumnCatalog, partitions []*storepb.TablePartitionMetadata, root *TableMetadata, proto *storepb.TableMetadata, isDetailCaseSensitive bool) ([]*TableMetadata, []string) {+func buildTablesMetadataRecursive(originalColumn []*metadatapb.ColumnMetadata, columnCatalogMap map[string]*storepb.ColumnCatalog, partitions []*metadatapb.TablePartitionMetadata, root *TableMetadata, proto *metadatapb.TableMetadata, isDetailCaseSensitive bool) ([]*TableMetadata, []string) {if partitions == nil {return nil, nil}@@ -992,7 +993,7 @@ func (t *TableMetadata) GetPrimaryKey() *IndexMetadata {return nil}-func (t *TableMetadata) GetProto() *storepb.TableMetadata {+func (t *TableMetadata) GetProto() *metadatapb.TableMetadata {return t.proto}@@ -1002,7 +1003,7 @@ func (t *TableMetadata) GetCatalog() *storepb.TableCatalog {// CreateColumn creates a new column in the table.// Returns an error if the column already exists.-func (t *TableMetadata) CreateColumn(columnProto *storepb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog) error {+func (t *TableMetadata) CreateColumn(columnProto *metadatapb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog) error {// Check if column already existsif t.GetColumn(columnProto.Name) != nil {return errors.Errorf("column %q already exists in table %q", columnProto.Name, t.proto.Name)@@ -1039,7 +1040,7 @@ func (t *TableMetadata) dropColumnInternal(columnName string, renumberPositionsdelete(t.internalColumn, columnID)// Remove from proto's column list- newColumns := make([]*storepb.ColumnMetadata, 0, len(t.proto.Columns)-1)+ newColumns := make([]*metadatapb.ColumnMetadata, 0, len(t.proto.Columns)-1)for _, column := range t.proto.Columns {if t.isDetailCaseSensitive {if column.Name != columnName {@@ -1091,7 +1092,7 @@ func (t *TableMetadata) dropColumnInternal(columnName string, renumberPositions}// Remove empty indexes from proto- newIndexes := make([]*storepb.IndexMetadata, 0)+ newIndexes := make([]*metadatapb.IndexMetadata, 0)for _, index := range t.proto.Indexes {if len(index.Expressions) > 0 {newIndexes = append(newIndexes, index)@@ -1126,7 +1127,7 @@ func (t *TableMetadata) DropColumnWithoutUpdatingIndexes(columnName string) errodelete(t.internalColumn, columnID)// Remove from proto's column list- newColumns := make([]*storepb.ColumnMetadata, 0, len(t.proto.Columns)-1)+ newColumns := make([]*metadatapb.ColumnMetadata, 0, len(t.proto.Columns)-1)for _, column := range t.proto.Columns {if t.isDetailCaseSensitive {if column.Name != columnName {@@ -1197,25 +1198,25 @@ func (t *TableMetadata) RenameColumn(oldName string, newName string) error {return nil}-func (t *ExternalTableMetadata) GetProto() *storepb.ExternalTableMetadata {+func (t *ExternalTableMetadata) GetProto() *metadatapb.ExternalTableMetadata {return t.proto}// GetColumn gets the column by name.-func (t *ExternalTableMetadata) GetColumn(name string) *storepb.ColumnMetadata {+func (t *ExternalTableMetadata) GetColumn(name string) *metadatapb.ColumnMetadata {nameID := normalizeNameByCaseSensitivity(name, t.isDetailCaseSensitive)return t.internal[nameID]}-func (i *IndexMetadata) GetProto() *storepb.IndexMetadata {+func (i *IndexMetadata) GetProto() *metadatapb.IndexMetadata {return i.proto}-func (i *IndexMetadata) GetTableProto() *storepb.TableMetadata {+func (i *IndexMetadata) GetTableProto() *metadatapb.TableMetadata {return i.tableProto}-func (c *ColumnMetadata) GetProto() *storepb.ColumnMetadata {+func (c *ColumnMetadata) GetProto() *metadatapb.ColumnMetadata {return c.proto}@@ -1225,7 +1226,7 @@ func (c *ColumnMetadata) GetCatalog() *storepb.ColumnCatalog {// CreateIndex creates a new index in the table.// Returns an error if the index already exists.-func (t *TableMetadata) CreateIndex(indexProto *storepb.IndexMetadata) error {+func (t *TableMetadata) CreateIndex(indexProto *metadatapb.IndexMetadata) error {// Check if index already existsif t.GetIndex(indexProto.Name) != nil {return errors.Errorf("index %q already exists in table %q", indexProto.Name, t.proto.Name)@@ -1257,7 +1258,7 @@ func (t *TableMetadata) DropIndex(indexName string) error {delete(t.internalIndexes, indexID)// Remove from proto's index list- newIndexes := make([]*storepb.IndexMetadata, 0, len(t.proto.Indexes)-1)+ newIndexes := make([]*metadatapb.IndexMetadata, 0, len(t.proto.Indexes)-1)for _, index := range t.proto.Indexes {if t.isDetailCaseSensitive {if index.Name != indexName {diff --git a/backend/store/model/database_test.go b/backend/store/model/database_test.goindex 56d3054c53..53e7f26978 100644--- a/backend/store/model/database_test.go+++ b/backend/store/model/database_test.go@@ -4,6 +4,7 @@ import ("sort""testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -11,22 +12,22 @@ import (func TestBuildTablesMetadata(t *testing.T) {testCases := []struct {- input *storepb.TableMetadata+ input *metadatapb.TableMetadatawantNames []string- wantColumns []*storepb.ColumnMetadata+ wantColumns []*metadatapb.ColumnMetadata}{// No partitions.{- input: &storepb.TableMetadata{+ input: &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",},},},wantNames: []string{"orders"},- wantColumns: []*storepb.ColumnMetadata{+ wantColumns: []*metadatapb.ColumnMetadata{{Name: "id",},@@ -34,17 +35,17 @@ func TestBuildTablesMetadata(t *testing.T) {},// Nested partitions.{- input: &storepb.TableMetadata{+ input: &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id",},},- Partitions: []*storepb.TablePartitionMetadata{+ Partitions: []*metadatapb.TablePartitionMetadata{{Name: "orders_0_100",- Subpartitions: []*storepb.TablePartitionMetadata{+ Subpartitions: []*metadatapb.TablePartitionMetadata{{Name: "orders_0_50",},@@ -55,7 +56,7 @@ func TestBuildTablesMetadata(t *testing.T) {},{Name: "orders_100_200",- Subpartitions: []*storepb.TablePartitionMetadata{+ Subpartitions: []*metadatapb.TablePartitionMetadata{{Name: "orders_100_150",},@@ -67,7 +68,7 @@ func TestBuildTablesMetadata(t *testing.T) {},},wantNames: []string{"orders", "orders_0_100", "orders_0_50", "orders_50_100", "orders_100_200", "orders_100_150", "orders_150_200"},- wantColumns: []*storepb.ColumnMetadata{+ wantColumns: []*metadatapb.ColumnMetadata{{Name: "id",},@@ -99,13 +100,13 @@ func TestPartitionTable_CreateIndex(t *testing.T) {a := require.New(t)// Create a table with partitions- tableProto := &storepb.TableMetadata{+ tableProto := &metadatapb.TableMetadata{Name: "orders",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"},{Name: "created_at"},},- Partitions: []*storepb.TablePartitionMetadata{+ Partitions: []*metadatapb.TablePartitionMetadata{{Name: "orders_2024"},{Name: "orders_2025"},},@@ -117,7 +118,7 @@ func TestPartitionTable_CreateIndex(t *testing.T) {// Verify that CreateIndex works on partition tables (was causing nil map panic)for i, table := range tables {- index := &storepb.IndexMetadata{+ index := &metadatapb.IndexMetadata{Name: "idx_" + names[i] + "_created_at",Expressions: []string{"created_at"},Type: "btree",@@ -129,9 +130,9 @@ func TestPartitionTable_CreateIndex(t *testing.T) {}func TestSchemaMetadata_CreateTable(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}@@ -153,12 +154,12 @@ func TestSchemaMetadata_CreateTable(t *testing.T) {}func TestSchemaMetadata_CreateTable_AlreadyExists(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users"},},},@@ -176,12 +177,12 @@ func TestSchemaMetadata_CreateTable_AlreadyExists(t *testing.T) {}func TestSchemaMetadata_DropTable(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users"},{Name: "products"},},@@ -207,9 +208,9 @@ func TestSchemaMetadata_DropTable(t *testing.T) {}func TestSchemaMetadata_DropTable_NotExists(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}@@ -225,15 +226,15 @@ func TestSchemaMetadata_DropTable_NotExists(t *testing.T) {}func TestTableMetadata_CreateColumn(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},},@@ -247,7 +248,7 @@ func TestTableMetadata_CreateColumn(t *testing.T) {tableMeta := schemaMeta.GetTable("users")// Create a new column- columnProto := &storepb.ColumnMetadata{+ columnProto := &metadatapb.ColumnMetadata{Name: "email",Type: "varchar",Nullable: true,@@ -264,15 +265,15 @@ func TestTableMetadata_CreateColumn(t *testing.T) {}func TestTableMetadata_CreateColumn_AlreadyExists(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},},},@@ -286,7 +287,7 @@ func TestTableMetadata_CreateColumn_AlreadyExists(t *testing.T) {tableMeta := schemaMeta.GetTable("users")// Try to create column that already exists- columnProto := &storepb.ColumnMetadata{+ columnProto := &metadatapb.ColumnMetadata{Name: "id",Type: "bigint",}@@ -297,15 +298,15 @@ func TestTableMetadata_CreateColumn_AlreadyExists(t *testing.T) {}func TestTableMetadata_DropColumn(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users",- Columns: []*storepb.ColumnMetadata{+ Columns: []*metadatapb.ColumnMetadata{{Name: "id", Type: "int"},{Name: "email", Type: "varchar"},{Name: "name", Type: "varchar"},@@ -335,12 +336,12 @@ func TestTableMetadata_DropColumn(t *testing.T) {}func TestTableMetadata_DropColumn_NotExists(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public",- Tables: []*storepb.TableMetadata{+ Tables: []*metadatapb.TableMetadata{{Name: "users"},},},@@ -364,29 +365,29 @@ func TestListTableNames_ExcludesPartitions(t *testing.T) {// A range-partitioned table whose last partition is itself subpartitioned. Every// partition and subpartition is registered in internalTables under its own name but// carries the parent's proto, so listing them once yielded "sales" six times.- sales := &storepb.TableMetadata{+ sales := &metadatapb.TableMetadata{Name: "sales",- Columns: []*storepb.ColumnMetadata{{Name: "dt"}},- Partitions: []*storepb.TablePartitionMetadata{- {Name: "p0", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},- {Name: "p1", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},+ Columns: []*metadatapb.ColumnMetadata{{Name: "dt"}},+ Partitions: []*metadatapb.TablePartitionMetadata{+ {Name: "p0", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},+ {Name: "p1", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},{- Name: "p2", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt",- Subpartitions: []*storepb.TablePartitionMetadata{- {Name: "p2s0", Type: storepb.TablePartitionMetadata_HASH, Expression: "dt"},- {Name: "p2s1", Type: storepb.TablePartitionMetadata_HASH, Expression: "dt"},+ Name: "p2", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt",+ Subpartitions: []*metadatapb.TablePartitionMetadata{+ {Name: "p2s0", Type: metadatapb.TablePartitionMetadata_HASH, Expression: "dt"},+ {Name: "p2s1", Type: metadatapb.TablePartitionMetadata_HASH, Expression: "dt"},},},},}- customers := &storepb.TableMetadata{+ customers := &metadatapb.TableMetadata{Name: "customers",- Columns: []*storepb.ColumnMetadata{{Name: "id"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "id"}},}- dbMetadata := NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{sales, customers}}},+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{sales, customers}}},}, nil, &storepb.DatabaseConfig{}, storepb.Engine_MYSQL, true)schemaMetadata := dbMetadata.GetSchemaMetadata("")@@ -406,15 +407,15 @@ func TestListTableNames_ExcludesPartitions(t *testing.T) {func TestListTableNames_PartitionSharingTableName(t *testing.T) {a := require.New(t)- dbMetadata := NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{{Name: "sales",- Columns: []*storepb.ColumnMetadata{{Name: "dt"}},- Partitions: []*storepb.TablePartitionMetadata{- {Name: "sales", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},- {Name: "p1", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},+ Columns: []*metadatapb.ColumnMetadata{{Name: "dt"}},+ Partitions: []*metadatapb.TablePartitionMetadata{+ {Name: "sales", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},+ {Name: "p1", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},},},}}},@@ -430,19 +431,19 @@ func TestListTableNames_PartitionSharingTableName(t *testing.T) {func TestGetTable_PartitionAliasDoesNotShadowRootTable(t *testing.T) {a := require.New(t)- dbMetadata := NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{{Name: "archive",- Columns: []*storepb.ColumnMetadata{{Name: "archive_col"}},+ Columns: []*metadatapb.ColumnMetadata{{Name: "archive_col"}},},{Name: "events",- Columns: []*storepb.ColumnMetadata{{Name: "events_col"}},- Partitions: []*storepb.TablePartitionMetadata{- {Name: "archive", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},- {Name: "recent", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},+ Columns: []*metadatapb.ColumnMetadata{{Name: "events_col"}},+ Partitions: []*metadatapb.TablePartitionMetadata{+ {Name: "archive", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},+ {Name: "recent", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},},},}}},@@ -467,14 +468,14 @@ func TestGetTable_PartitionAliasDoesNotShadowRootTable(t *testing.T) {func TestTableMutationsIgnorePartitionAliases(t *testing.T) {a := require.New(t)- dbMetadata := NewDatabaseMetadata(&storepb.DatabaseSchemaMetadata{+ dbMetadata := NewDatabaseMetadata(&metadatapb.DatabaseSchemaMetadata{Name: "db",- Schemas: []*storepb.SchemaMetadata{{Name: "", Tables: []*storepb.TableMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "", Tables: []*metadatapb.TableMetadata{{Name: "events",- Columns: []*storepb.ColumnMetadata{{Name: "events_col"}},- Partitions: []*storepb.TablePartitionMetadata{- {Name: "archive", Type: storepb.TablePartitionMetadata_RANGE, Expression: "dt"},+ Columns: []*metadatapb.ColumnMetadata{{Name: "events_col"}},+ Partitions: []*metadatapb.TablePartitionMetadata{+ {Name: "archive", Type: metadatapb.TablePartitionMetadata_RANGE, Expression: "dt"},},},}}},diff --git a/backend/store/model/pg_search_path_test.go b/backend/store/model/pg_search_path_test.goindex 62dc68b0d0..53ff38ba48 100644--- a/backend/store/model/pg_search_path_test.go+++ b/backend/store/model/pg_search_path_test.go@@ -3,6 +3,7 @@ package modelimport ("testing"+ metadatapb "github.com/bytebase/omni/metadata""github.com/stretchr/testify/require"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -41,10 +42,10 @@ func TestResolvePGSearchPath(t *testing.T) {}func TestDatabaseMetadataSearchPathHelpers(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",SearchPath: `"$user", public, MissingSchema, "CamelCase"`,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "alice"},{Name: "public"},{Name: "CamelCase"},@@ -64,10 +65,10 @@ func TestDatabaseMetadataSearchPathHelpers(t *testing.T) {}func TestDatabaseMetadataSearchPathHelpersSkipMissingCurrentUserSchema(t *testing.T) {- metadata := &storepb.DatabaseSchemaMetadata{+ metadata := &metadatapb.DatabaseSchemaMetadata{Name: "testdb",SearchPath: `"$user", public, MissingSchema`,- Schemas: []*storepb.SchemaMetadata{+ Schemas: []*metadatapb.SchemaMetadata{{Name: "public"},},}diff --git a/backend/store/model/pg_searcher.go b/backend/store/model/pg_searcher.goindex 2cda6271bd..f4e1c8305d 100644--- a/backend/store/model/pg_searcher.go+++ b/backend/store/model/pg_searcher.go@@ -3,7 +3,7 @@ package modelimport ("strings"- storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ metadatapb "github.com/bytebase/omni/metadata")// DatabaseSearcher provides a fluent interface for searching database objects with a specific search path.@@ -67,7 +67,7 @@ func (s *DatabaseSearcher) SearchIndex(name string) (string, *IndexMetadata) {// SearchView searches for a view in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (s *DatabaseSearcher) SearchView(name string) (string, *storepb.ViewMetadata) {+func (s *DatabaseSearcher) SearchView(name string) (string, *metadatapb.ViewMetadata) {for _, schemaName := range s.searchPath {schema := s.db.GetSchemaMetadata(schemaName)if schema == nil {@@ -99,7 +99,7 @@ func (s *DatabaseSearcher) SearchExternalTable(name string) (string, *ExternalTa// SearchSequence searches for a sequence in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (s *DatabaseSearcher) SearchSequence(name string) (string, *storepb.SequenceMetadata) {+func (s *DatabaseSearcher) SearchSequence(name string) (string, *metadatapb.SequenceMetadata) {for _, schemaName := range s.searchPath {schema := s.db.GetSchemaMetadata(schemaName)if schema == nil {@@ -115,7 +115,7 @@ func (s *DatabaseSearcher) SearchSequence(name string) (string, *storepb.Sequenc// SearchMaterializedView searches for a materialized view in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (s *DatabaseSearcher) SearchMaterializedView(name string) (string, *storepb.MaterializedViewMetadata) {+func (s *DatabaseSearcher) SearchMaterializedView(name string) (string, *metadatapb.MaterializedViewMetadata) {for _, schemaName := range s.searchPath {schema := s.db.GetSchemaMetadata(schemaName)if schema == nil {@@ -131,9 +131,9 @@ func (s *DatabaseSearcher) SearchMaterializedView(name string) (string, *storepb// SearchFunctions searches for functions in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (s *DatabaseSearcher) SearchFunctions(name string) ([]string, []*storepb.FunctionMetadata) {+func (s *DatabaseSearcher) SearchFunctions(name string) ([]string, []*metadatapb.FunctionMetadata) {var schemas []string- var funcs []*storepb.FunctionMetadata+ var funcs []*metadatapb.FunctionMetadatafor _, schemaName := range s.searchPath {schema := s.db.GetSchemaMetadata(schemaName)if schema == nil {@@ -190,7 +190,7 @@ func (d *DatabaseMetadata) SearchIndex(searchPath []string, name string) (string// SearchView searches for a view in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (d *DatabaseMetadata) SearchView(searchPath []string, name string) (string, *storepb.ViewMetadata) {+func (d *DatabaseMetadata) SearchView(searchPath []string, name string) (string, *metadatapb.ViewMetadata) {for _, schemaName := range searchPath {schema := d.GetSchemaMetadata(schemaName)if schema == nil {@@ -222,7 +222,7 @@ func (d *DatabaseMetadata) SearchExternalTable(searchPath []string, name string)// SearchSequence searches for a sequence in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (d *DatabaseMetadata) SearchSequence(searchPath []string, name string) (string, *storepb.SequenceMetadata) {+func (d *DatabaseMetadata) SearchSequence(searchPath []string, name string) (string, *metadatapb.SequenceMetadata) {for _, schemaName := range searchPath {schema := d.GetSchemaMetadata(schemaName)if schema == nil {@@ -238,7 +238,7 @@ func (d *DatabaseMetadata) SearchSequence(searchPath []string, name string) (str// SearchMaterializedView searches for a materialized view in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (d *DatabaseMetadata) SearchMaterializedView(searchPath []string, name string) (string, *storepb.MaterializedViewMetadata) {+func (d *DatabaseMetadata) SearchMaterializedView(searchPath []string, name string) (string, *metadatapb.MaterializedViewMetadata) {for _, schemaName := range searchPath {schema := d.GetSchemaMetadata(schemaName)if schema == nil {@@ -254,9 +254,9 @@ func (d *DatabaseMetadata) SearchMaterializedView(searchPath []string, name stri// SearchFunctions searches for functions in the search path.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (d *DatabaseMetadata) SearchFunctions(searchPath []string, name string) ([]string, []*storepb.FunctionMetadata) {+func (d *DatabaseMetadata) SearchFunctions(searchPath []string, name string) ([]string, []*metadatapb.FunctionMetadata) {var schemas []string- var funcs []*storepb.FunctionMetadata+ var funcs []*metadatapb.FunctionMetadatafor _, schemaName := range searchPath {schema := d.GetSchemaMetadata(schemaName)if schema == nil {diff --git a/backend/store/sync_history.go b/backend/store/sync_history.goindex ae72c7ae03..6c1b6dd7fd 100644--- a/backend/store/sync_history.go+++ b/backend/store/sync_history.go@@ -6,12 +6,12 @@ import ("strings""time"+ metadatapb "github.com/bytebase/omni/metadata""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/qb"- storepb "github.com/bytebase/bytebase/backend/generated-go/store")type SyncHistory struct {@@ -19,7 +19,7 @@ type SyncHistory struct {InstanceID stringDatabaseName stringSchema string- Metadata *storepb.DatabaseSchemaMetadata+ Metadata *metadatapb.DatabaseSchemaMetadataCreatedAt time.Time}@@ -43,7 +43,7 @@ func (s *Store) GetSyncHistory(ctx context.Context, resourceID string) (*SyncHis}h := SyncHistory{- Metadata: &storepb.DatabaseSchemaMetadata{},+ Metadata: &metadatapb.DatabaseSchemaMetadata{},}var m []byte@@ -68,7 +68,7 @@ func (s *Store) GetSyncHistory(ctx context.Context, resourceID string) (*SyncHisreturn &h, nil}-func (s *Store) CreateSyncHistory(ctx context.Context, instanceID, databaseName string, metadata *storepb.DatabaseSchemaMetadata, schema string) (string, error) {+func (s *Store) CreateSyncHistory(ctx context.Context, instanceID, databaseName string, metadata *metadatapb.DatabaseSchemaMetadata, schema string) (string, error) {// Sanitize schema to prevent storing invalid UTF-8 bytes from external databases.schema = strings.ToValidUTF8(schema, "")diff --git a/docs/adding-new-object-to-sdl-mode.md b/docs/adding-new-object-to-sdl-mode.mdindex 09eca8d7cf..870cf94664 100644--- a/docs/adding-new-object-to-sdl-mode.md+++ b/docs/adding-new-object-to-sdl-mode.md@@ -564,7 +564,7 @@ This is where dependency ordering happens. **Both metadata mode and AST-only mod// For tables with foreign keys depending on other tablesfor tableID, tableDiff := range tableMap {if tableDiff.Action == schema.MetadataDiffActionCreate {- var foreignKeys []*storepb.ForeignKeyMetadata+ var foreignKeys []*metadatapb.ForeignKeyMetadataif tableDiff.NewTable != nil {// Metadata mode: use ForeignKeys from metadata@@ -586,7 +586,7 @@ This is where dependency ordering happens. **Both metadata mode and AST-only mod// For views depending on tables/viewsfor viewID, viewDiff := range viewMap {- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnif viewDiff.NewView != nil {// Metadata mode: use metadata@@ -608,7 +608,7 @@ This is where dependency ordering happens. **Both metadata mode and AST-only mod// ✅ For materialized views depending on tables/views// ⚠️ THIS IS THE MOST CRITICAL PART - both metadata and AST mode required!for mvID, mvDiff := range materializedViewMap {- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnif mvDiff.NewMaterializedView != nil {// Metadata mode: use metadata@@ -651,9 +651,9 @@ This function extracts dependencies from AST nodes in SDL mode:```go// getMaterializedViewDependenciesFromAST extracts table/view dependencies from a materialized view's AST node-func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *storepb.DatabaseSchemaMetadata) []*storepb.DependencyColumn {+func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *metadatapb.DatabaseSchemaMetadata) []*metadatapb.DependencyColumn {if astNode == nil {- return []*storepb.DependencyColumn{}+ return []*metadatapb.DependencyColumn{}}var selectStatement string@@ -678,7 +678,7 @@ func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *s}if selectStatement == "" {- return []*storepb.DependencyColumn{}+ return []*metadatapb.DependencyColumn{}}queryStatement := strings.TrimSpace(selectStatement)@@ -690,11 +690,11 @@ func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *sSkipMetadataValidation: true, // Important: we don't have full metadata in SDL mode})if err != nil {- return []*storepb.DependencyColumn{}+ return []*metadatapb.DependencyColumn{}}// Build dependency list- dependencyMap := make(map[string]*storepb.DependencyColumn)+ dependencyMap := make(map[string]*metadatapb.DependencyColumn)for _, resource := range accessTables {// Skip system catalogsif resource.Schema == "pg_catalog" || resource.Schema == "information_schema" {@@ -708,7 +708,7 @@ func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *skey := fmt.Sprintf("%s.%s", resourceSchema, resource.Table)if _, exists := dependencyMap[key]; !exists {- dependencyMap[key] = &storepb.DependencyColumn{+ dependencyMap[key] = &metadatapb.DependencyColumn{Schema: resourceSchema,Table: resource.Table,Column: "*", // Table-level dependencies@@ -716,7 +716,7 @@ func getMaterializedViewDependenciesFromAST(astNode any, schemaName string, _ *s}}- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnfor _, dep := range dependencyMap {dependencies = append(dependencies, dep)}@@ -908,7 +908,7 @@ func dropObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) {```go// For views depending on tables/viewsfor viewID, viewDiff := range viewMap {- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnif viewDiff.OldView != nil {// Metadata mode: use metadata@@ -931,7 +931,7 @@ func dropObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) {// ✅ For materialized views depending on tables/views// ⚠️ CRITICAL: Must support both metadata and AST mode for DROP too!for mvID, mvDiff := range materializedViewMap {- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnif mvDiff.OldMaterializedView != nil {// Metadata mode: use metadata@@ -967,7 +967,7 @@ func dropObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) {// For tables with foreign keysfor tableID, tableDiff := range tableMap {- var foreignKeys []*storepb.ForeignKeyMetadata+ var foreignKeys []*metadatapb.ForeignKeyMetadataif tableDiff.OldTable != nil {// Metadata mode: use ForeignKeys from metadata@@ -1253,7 +1253,7 @@ func GetMultiFileDatabaseDefinition(dbSchema *model.DatabaseSchema, schemaVersio```go// writeMaterializedViewSDL writes the SDL (simple) version// No indexes, no comments, no WITH NO DATA - just the core CREATE statement-func writeMaterializedViewSDL(out io.Writer, schemaName string, mv *storepb.MaterializedViewMetadata) error {+func writeMaterializedViewSDL(out io.Writer, schemaName string, mv *metadatapb.MaterializedViewMetadata) error {if _, err := io.WriteString(out, `CREATE MATERIALIZED VIEW "`); err != nil {return err}@@ -1295,7 +1295,7 @@ func writeMaterializedViewSDL(out io.Writer, schemaName string, mv *storepb.Mate```go// nolint:unused-func writeMaterializedViewCommentSDL(out io.Writer, schemaName string, mv *storepb.MaterializedViewMetadata) error {+func writeMaterializedViewCommentSDL(out io.Writer, schemaName string, mv *metadatapb.MaterializedViewMetadata) error {if len(mv.Comment) == 0 {return nil}@@ -1883,7 +1883,7 @@ for mvID, mvDiff := range materializedViewMap {**✅ Correct** (supports both modes):```gofor mvID, mvDiff := range materializedViewMap {- var dependencies []*storepb.DependencyColumn+ var dependencies []*metadatapb.DependencyColumnif mvDiff.NewMaterializedView != nil {dependencies = mvDiff.NewMaterializedView.DependencyColumnsdiff --git a/docs/adr/0001-per-concept-type-metadata.md b/docs/adr/0001-per-concept-type-metadata.mdindex 6b3fa0c7d8..9a67bd24f8 100644--- a/docs/adr/0001-per-concept-type-metadata.md+++ b/docs/adr/0001-per-concept-type-metadata.md@@ -1,6 +1,6 @@# Per-concept type metadata messages, not a unified UDT message-`SchemaMetadata` (proto/store/store/database.proto) models named user-defined types as narrow per-concept messages — `EnumTypeMetadata`, `CompositeTypeMetadata`, and in the future `ObjectTypeMetadata` (Oracle), `TableTypeMetadata` (SQL Server), `DomainMetadata` (PostgreSQL) — each named by the owning engine family's official term. We rejected a unified `UserDefinedTypeMetadata`.+`SchemaMetadata` (`proto/omni/metadata/database.proto` in [omni](https://github.com/bytebase/omni)) models named user-defined types as narrow per-concept messages — `EnumTypeMetadata`, `CompositeTypeMetadata`, and in the future `ObjectTypeMetadata` (Oracle), `TableTypeMetadata` (SQL Server), `DomainMetadata` (PostgreSQL) — each named by the owning engine family's official term. We rejected a unified `UserDefinedTypeMetadata`.Metadata is persisted as protojson in JSONB (snapshots, changelogs, releases) and unmarshaled with `DiscardUnknown`, so field names and message shapes are frozen forever once shipped: a later rename silently orphans historical data with no error. The choice therefore minimizes the probability of ever wanting to restructure.diff --git a/go.mod b/go.modindex ed995db15c..79421ce3e3 100644--- a/go.mod+++ b/go.mod@@ -34,7 +34,7 @@ require (github.com/bmatcuk/doublestar/v4 v4.10.0github.com/bytebase/gomongo v0.0.0-20260730033313-67ba6e249735github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0- github.com/bytebase/omni v0.0.0-20260828034652-044f516d401c+ github.com/bytebase/omni v0.0.0-20260911085056-71713ba5c090github.com/caarlos0/env/v11 v11.4.1github.com/cenkalti/backoff/v7 v7.0.0github.com/cockroachdb/cockroachdb-parser v0.25.2diff --git a/go.sum b/go.sumindex 29b2737534..5d42a50795 100644--- a/go.sum+++ b/go.sum@@ -252,8 +252,8 @@ github.com/bytebase/gomongo v0.0.0-20260730033313-67ba6e249735 h1:v8y6mXeHmYVsdMgithub.com/bytebase/gomongo v0.0.0-20260730033313-67ba6e249735/go.mod h1:vTHjcvfn8Pmf65WjnV1ytTCYyC7xNhFjrniv4YWvtA8=github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0 h1:bJ8NSf2K+pccl5m/wuu97fiYjDwpJH6IzURAq/3XA2U=github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0/go.mod h1:BEWMfiZtqshdmulKJcIsWb45MUaEvDO4CROcgi8dfFg=-github.com/bytebase/omni v0.0.0-20260828034652-044f516d401c h1:Plc8vW5rGPaqRXyn+oNt72HmLMaY7E6HWkFmeS7QmA0=-github.com/bytebase/omni v0.0.0-20260828034652-044f516d401c/go.mod h1:Gp5RN3FM07f9/FFOTZCeu8duTAIMeuinkjjBCrs2Dw4=+github.com/bytebase/omni v0.0.0-20260911085056-71713ba5c090 h1:0EZ0/nFVpkwDBp88Zb6nJAUmHAeP570s5dkOegvElxQ=+github.com/bytebase/omni v0.0.0-20260911085056-71713ba5c090/go.mod h1:9XZE1hqtvr09Oc+DdLu1/yCb8MDcoy/EPdA4AONDHlE=github.com/bytebase/pgx/v5 v5.0.0-20250212161523-96ff8aed8767 h1:YuR5G3LcxpO5ScSTA+Kdirxg9RW4TRc/v1t7N2Hfmbw=github.com/bytebase/pgx/v5 v5.0.0-20250212161523-96ff8aed8767/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=github.com/bytebase/pkcs8 v0.0.0-20240612095628-fcd0a7484c94 h1:6PNsuNmSqCuR8Z616uQLzDIvujWCFsKzeVc3ECmVubk=diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex 129d7a0d08..b71b06f927 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -50,64 +50,21 @@- [ChangelogPayload](#bytebase-store-ChangelogPayload)- [store/database.proto](#store_database-proto)- - [BoundingBox](#bytebase-store-BoundingBox)- - [CheckConstraintMetadata](#bytebase-store-CheckConstraintMetadata)- [ColumnCatalog](#bytebase-store-ColumnCatalog)- [ColumnCatalog.LabelsEntry](#bytebase-store-ColumnCatalog-LabelsEntry)- - [ColumnMetadata](#bytebase-store-ColumnMetadata)- - [CompositeTypeAttribute](#bytebase-store-CompositeTypeAttribute)- - [CompositeTypeMetadata](#bytebase-store-CompositeTypeMetadata)- [DatabaseConfig](#bytebase-store-DatabaseConfig)- [DatabaseMetadata](#bytebase-store-DatabaseMetadata)- [DatabaseMetadata.LabelsEntry](#bytebase-store-DatabaseMetadata-LabelsEntry)- - [DatabaseSchemaMetadata](#bytebase-store-DatabaseSchemaMetadata)- - [DependencyColumn](#bytebase-store-DependencyColumn)- - [DependencyTable](#bytebase-store-DependencyTable)- - [DimensionalConfig](#bytebase-store-DimensionalConfig)- - [EnumTypeMetadata](#bytebase-store-EnumTypeMetadata)- - [EventMetadata](#bytebase-store-EventMetadata)- - [EventTriggerMetadata](#bytebase-store-EventTriggerMetadata)- - [ExcludeConstraintMetadata](#bytebase-store-ExcludeConstraintMetadata)- - [ExtensionMetadata](#bytebase-store-ExtensionMetadata)- - [ExternalTableMetadata](#bytebase-store-ExternalTableMetadata)- - [ForeignKeyMetadata](#bytebase-store-ForeignKeyMetadata)- - [FunctionMetadata](#bytebase-store-FunctionMetadata)- - [GenerationMetadata](#bytebase-store-GenerationMetadata)- - [GridLevel](#bytebase-store-GridLevel)- - [IndexMetadata](#bytebase-store-IndexMetadata)- [InstanceRoleMetadata](#bytebase-store-InstanceRoleMetadata)- - [LinkedDatabaseMetadata](#bytebase-store-LinkedDatabaseMetadata)- - [MaterializedViewMetadata](#bytebase-store-MaterializedViewMetadata)- [ObjectSchema](#bytebase-store-ObjectSchema)- [ObjectSchema.ArrayKind](#bytebase-store-ObjectSchema-ArrayKind)- [ObjectSchema.StructKind](#bytebase-store-ObjectSchema-StructKind)- [ObjectSchema.StructKind.PropertiesEntry](#bytebase-store-ObjectSchema-StructKind-PropertiesEntry)- - [PackageMetadata](#bytebase-store-PackageMetadata)- - [ProcedureMetadata](#bytebase-store-ProcedureMetadata)- - [RuleMetadata](#bytebase-store-RuleMetadata)- [SchemaCatalog](#bytebase-store-SchemaCatalog)- - [SchemaMetadata](#bytebase-store-SchemaMetadata)- - [SequenceMetadata](#bytebase-store-SequenceMetadata)- - [SpatialIndexConfig](#bytebase-store-SpatialIndexConfig)- - [SpatialIndexConfig.EngineSpecificEntry](#bytebase-store-SpatialIndexConfig-EngineSpecificEntry)- - [StorageConfig](#bytebase-store-StorageConfig)- - [StreamMetadata](#bytebase-store-StreamMetadata)- [TableCatalog](#bytebase-store-TableCatalog)- - [TableMetadata](#bytebase-store-TableMetadata)- - [TablePartitionMetadata](#bytebase-store-TablePartitionMetadata)- - [TaskMetadata](#bytebase-store-TaskMetadata)- - [TessellationConfig](#bytebase-store-TessellationConfig)- - [TriggerMetadata](#bytebase-store-TriggerMetadata)- - [ViewMetadata](#bytebase-store-ViewMetadata)- - [ColumnMetadata.IdentityGeneration](#bytebase-store-ColumnMetadata-IdentityGeneration)- - [GenerationMetadata.Type](#bytebase-store-GenerationMetadata-Type)- [ObjectSchema.Type](#bytebase-store-ObjectSchema-Type)- - [StreamMetadata.Mode](#bytebase-store-StreamMetadata-Mode)- - [StreamMetadata.Type](#bytebase-store-StreamMetadata-Type)- [SyncStatus](#bytebase-store-SyncStatus)- - [TablePartitionMetadata.Type](#bytebase-store-TablePartitionMetadata-Type)- - [TaskMetadata.State](#bytebase-store-TaskMetadata-State)- [store/group.proto](#store_group-proto)- [GroupMember](#bytebase-store-GroupMember)@@ -1025,40 +982,6 @@ It also reads last_attempt_at differently: for this kind the column is the windo-<a name="bytebase-store-BoundingBox"></a>--### BoundingBox-BoundingBox defines the bounding box for spatial indexes.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| xmin | [double](#double) | | |-| ymin | [double](#double) | | |-| xmax | [double](#double) | | |-| ymax | [double](#double) | | |-------<a name="bytebase-store-CheckConstraintMetadata"></a>--### CheckConstraintMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the check constraint. |-| expression | [string](#string) | | The expression is the expression of a check constraint. |------<a name="bytebase-store-ColumnCatalog"></a>### ColumnCatalog@@ -1094,82 +1017,6 @@ BoundingBox defines the bounding box for spatial indexes.-<a name="bytebase-store-ColumnMetadata"></a>--### ColumnMetadata-ColumnMetadata is the metadata for columns.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the column. |-| position | [int32](#int32) | | The position is the position in columns. |-| default | [string](#string) | | The default value of the column. |-| default_on_null | [bool](#bool) | | Oracle specific metadata. The default_on_null is the default on null of a column. |-| on_update | [string](#string) | | The on_update is the on update action of a column. For MySQL like databases, it's only supported for TIMESTAMP columns with CURRENT_TIMESTAMP as on update value. |-| nullable | [bool](#bool) | | The nullable is the nullable of a column. |-| type | [string](#string) | | The type is the type of a column. |-| character_set | [string](#string) | | The character_set is the character_set of a column. |-| collation | [string](#string) | | The collation is the collation of a column. |-| comment | [string](#string) | | The comment is the comment of a column. |-| generation | [GenerationMetadata](#bytebase-store-GenerationMetadata) | | The generation is for generated columns. |-| is_identity | [bool](#bool) | | |-| identity_generation | [ColumnMetadata.IdentityGeneration](#bytebase-store-ColumnMetadata-IdentityGeneration) | | The identity_generation is for identity columns, PG only. |-| identity_seed | [int64](#int64) | | The identity_seed is for identity columns, MSSQL only. |-| identity_increment | [int64](#int64) | | The identity_increment is for identity columns, MSSQL only. |-| default_constraint_name | [string](#string) | | The default_constraint_name is the name of the default constraint, MSSQL only. In MSSQL, default values are implemented as named constraints. When modifying or dropping a column's default value, you must reference the constraint by name. This field stores the actual constraint name from the database.--Example: A column definition like: CREATE TABLE employees ( status NVARCHAR(20) DEFAULT 'active' )--Will create a constraint with an auto-generated name like 'DF__employees__statu__3B75D760' or a user-defined name if specified: ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'active' FOR status--To modify the default, you must first drop the existing constraint by name: ALTER TABLE employees DROP CONSTRAINT DF__employees__statu__3B75D760 ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'inactive' FOR status--This field is populated when syncing from the database. When empty (e.g., when parsing from SQL files), the system cannot automatically drop the constraint. |-| srid | [uint32](#uint32) | optional | The spatial reference system identifier of a spatial column, MySQL 8.0 only. Unset means the column declares no SRID; presence carries the explicit SRID, including the valid SRID 0. SRS_IDs are unsigned 32-bit (custom SRSs may exceed int32). Captured from information_schema.COLUMNS.SRS_ID and rendered as the `/*!80003 SRID n */` column attribute. |-| is_invisible | [bool](#bool) | | Whether the column is invisible (hidden from SELECT *), MySQL 8.0.23+ only. Captured from information_schema.COLUMNS.EXTRA containing INVISIBLE and rendered as the `/*!80023 INVISIBLE */` column attribute. |-------<a name="bytebase-store-CompositeTypeAttribute"></a>--### CompositeTypeAttribute----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the attribute. |-| type | [string](#string) | | The attribute type. User-defined types are always schema-qualified. |-| collation | [string](#string) | | The non-default collation of the attribute as an emit-ready SQL identifier reference (quoted as needed, schema-qualified when outside pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. |-| comment | [string](#string) | | |-------<a name="bytebase-store-CompositeTypeMetadata"></a>--### CompositeTypeMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the composite type. |-| attributes | [CompositeTypeAttribute](#bytebase-store-CompositeTypeAttribute) | repeated | The ordered attributes of the composite type. |-| comment | [string](#string) | | |-| skip_dump | [bool](#bool) | | |------<a name="bytebase-store-DatabaseConfig"></a>### DatabaseConfig@@ -1223,309 +1070,6 @@ DatabaseMetadata is the metadata for databases.-<a name="bytebase-store-DatabaseSchemaMetadata"></a>--### DatabaseSchemaMetadata-DatabaseSchemaMetadata is the schema metadata for databases.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | |-| schemas | [SchemaMetadata](#bytebase-store-SchemaMetadata) | repeated | The list of schemas in a database. |-| character_set | [string](#string) | | The character set of the database. |-| collation | [string](#string) | | The collation of the database. |-| extensions | [ExtensionMetadata](#bytebase-store-ExtensionMetadata) | repeated | The list of extensions in a database. |-| datashare | [bool](#bool) | | The database belongs to a datashare. |-| service_name | [string](#string) | | The service name of the database. It's an Oracle-specific concept. |-| linked_databases | [LinkedDatabaseMetadata](#bytebase-store-LinkedDatabaseMetadata) | repeated | |-| owner | [string](#string) | | |-| search_path | [string](#string) | | The search_path is the search path of a PostgreSQL database. |-| event_triggers | [EventTriggerMetadata](#bytebase-store-EventTriggerMetadata) | repeated | The list of event triggers in a database (PostgreSQL specific). Event triggers are database-level objects, not schema-scoped. |-------<a name="bytebase-store-DependencyColumn"></a>--### DependencyColumn-DependencyColumn is the metadata for dependency columns.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| schema | [string](#string) | | The schema is the schema of a reference column. |-| table | [string](#string) | | The table is the table of a reference column. |-| column | [string](#string) | | The column is the name of a reference column. |-------<a name="bytebase-store-DependencyTable"></a>--### DependencyTable----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| schema | [string](#string) | | The schema is the schema of a reference table. |-| table | [string](#string) | | The table is the name of a reference table. |-------<a name="bytebase-store-DimensionalConfig"></a>--### DimensionalConfig-DimensionalConfig defines dimensional and constraint parameters for spatial indexes.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| dimensions | [int32](#int32) | | Number of dimensions (2-4, default 2) |-| data_type | [string](#string) | | Spatial data type Examples: GEOMETRY, GEOGRAPHY, POINT, POLYGON, etc. |-| operator_class | [string](#string) | | PostgreSQL operator class Examples: gist_geometry_ops_2d, gist_geometry_ops_nd, etc. |-| layer_gtype | [string](#string) | | Oracle geometry type constraint Examples: POINT, LINE, POLYGON, COLLECTION |-| parallel_build | [bool](#bool) | | Parallel index creation |-------<a name="bytebase-store-EnumTypeMetadata"></a>--### EnumTypeMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the enum type. |-| values | [string](#string) | repeated | The enum values of the type. |-| comment | [string](#string) | | |-| skip_dump | [bool](#bool) | | |-------<a name="bytebase-store-EventMetadata"></a>--### EventMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the event. |-| definition | [string](#string) | | The schedule of the event. |-| time_zone | [string](#string) | | The time zone of the event. |-| sql_mode | [string](#string) | | |-| character_set_client | [string](#string) | | |-| collation_connection | [string](#string) | | |-| comment | [string](#string) | | |-------<a name="bytebase-store-EventTriggerMetadata"></a>--### EventTriggerMetadata-EventTriggerMetadata is the metadata for PostgreSQL event triggers.-Event triggers are database-level objects that fire on DDL events.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the event trigger. |-| event | [string](#string) | | The event type: DDL_COMMAND_START, DDL_COMMAND_END, SQL_DROP, TABLE_REWRITE. |-| tags | [string](#string) | repeated | The tags filter (e.g., ['CREATE TABLE', 'DROP TABLE']). |-| function_schema | [string](#string) | | The schema of the function to execute. |-| function_name | [string](#string) | | The name of the function to execute. |-| enabled | [bool](#bool) | | Whether the trigger is enabled. |-| definition | [string](#string) | | The full CREATE EVENT TRIGGER definition from pg_get_event_trigger_def(). SDL output should prefer using this field. |-| comment | [string](#string) | | The comment on the event trigger. |-| skip_dump | [bool](#bool) | | Skip dump flag (for extension-owned triggers). |-------<a name="bytebase-store-ExcludeConstraintMetadata"></a>--### ExcludeConstraintMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the EXCLUDE constraint. |-| expression | [string](#string) | | The expression is the full EXCLUDE constraint definition including "EXCLUDE" keyword. Example: "EXCLUDE USING gist (room_id WITH =, during WITH &&)" |-------<a name="bytebase-store-ExtensionMetadata"></a>--### ExtensionMetadata-ExtensionMetadata is the metadata for extensions.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the extension. |-| schema | [string](#string) | | The schema where the extension is installed. However, the extension usage is not limited to the schema. |-| version | [string](#string) | | The version is the version of an extension. |-| description | [string](#string) | | The description is the description of an extension. |-------<a name="bytebase-store-ExternalTableMetadata"></a>--### ExternalTableMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the external table. |-| external_server_name | [string](#string) | | The external_server_name is the name of the external server. |-| external_database_name | [string](#string) | | The external_database_name is the name of the external database. |-| columns | [ColumnMetadata](#bytebase-store-ColumnMetadata) | repeated | The columns is the ordered list of columns in a foreign table. |-------<a name="bytebase-store-ForeignKeyMetadata"></a>--### ForeignKeyMetadata-ForeignKeyMetadata is the metadata for foreign keys.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the foreign key. |-| columns | [string](#string) | repeated | The columns are the ordered referencing columns of a foreign key. |-| referenced_schema | [string](#string) | | The referenced_schema is the referenced schema name of a foreign key. It is an empty string for databases without such concept such as MySQL. |-| referenced_table | [string](#string) | | The referenced_table is the referenced table name of a foreign key. |-| referenced_columns | [string](#string) | repeated | The referenced_columns are the ordered referenced columns of a foreign key. |-| on_delete | [string](#string) | | The on_delete is the on delete action of a foreign key. |-| on_update | [string](#string) | | The on_update is the on update action of a foreign key. |-| match_type | [string](#string) | | The match_type is the match type of a foreign key. The match_type is the PostgreSQL specific field. It's empty string for other databases. |-------<a name="bytebase-store-FunctionMetadata"></a>--### FunctionMetadata-FunctionMetadata is the metadata for functions.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the function. |-| definition | [string](#string) | | The definition is the definition of a function. |-| signature | [string](#string) | | The signature is the name with the number and type of input arguments the function takes. |-| character_set_client | [string](#string) | | MySQL specific metadata. |-| collation_connection | [string](#string) | | |-| database_collation | [string](#string) | | |-| sql_mode | [string](#string) | | |-| comment | [string](#string) | | |-| dependency_tables | [DependencyTable](#bytebase-store-DependencyTable) | repeated | The dependency_tables is the list of dependency tables of a function. For PostgreSQL, it's the list of tables that the function depends on the return type definition. |-| skip_dump | [bool](#bool) | | |-------<a name="bytebase-store-GenerationMetadata"></a>--### GenerationMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| type | [GenerationMetadata.Type](#bytebase-store-GenerationMetadata-Type) | | |-| expression | [string](#string) | | |-------<a name="bytebase-store-GridLevel"></a>--### GridLevel-GridLevel defines a grid level for spatial tessellation.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| level | [int32](#int32) | | 1-4 for SQL Server |-| density | [string](#string) | | LOW, MEDIUM, HIGH |-------<a name="bytebase-store-IndexMetadata"></a>--### IndexMetadata-IndexMetadata is the metadata for indexes.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the index. |-| expressions | [string](#string) | repeated | The expressions are the ordered columns or expressions of an index.--For PostgreSQL, the canonical shape for each entry matches pg_get_indexdef(oid, col, true) — the tightest `index_elem` grammar form: - column key: bare identifier e.g. "id", `"Name"` - function-call key: bare func_expr_windowless e.g. "lower(name)" - expression key: parenthesized a_expr e.g. "(payload ->> 'k'::text)" The DDL emitter writes entries verbatim into the CREATE INDEX key list. |-| key_length | [int64](#int64) | repeated | The ordered list of key lengths for the index. If the key length is not specified, it is -1. |-| descending | [bool](#bool) | repeated | The ordered list of descending flags for the index columns. |-| type | [string](#string) | | The type is the type of an index. |-| unique | [bool](#bool) | | The unique is whether the index is unique. |-| primary | [bool](#bool) | | The primary is whether the index is a primary key index. |-| visible | [bool](#bool) | | The visible is whether the index is visible. |-| comment | [string](#string) | | The comment is the comment of an index. |-| definition | [string](#string) | | The definition of an index. |-| parent_index_schema | [string](#string) | | The schema name of the parent index. |-| parent_index_name | [string](#string) | | The index name of the parent index. |-| granularity | [int64](#int64) | | The number of granules in the block. It's a ClickHouse specific field. |-| is_constraint | [bool](#bool) | | It's a PostgreSQL specific field. The unique constraint and unique index are not the same thing in PostgreSQL. |-| spatial_config | [SpatialIndexConfig](#bytebase-store-SpatialIndexConfig) | | Spatial index specific configuration |-| opclass_names | [string](#string) | repeated | https://www.postgresql.org/docs/current/catalog-pg-opclass.html Name of the operator class for each column. (PostgreSQL specific). |-| opclass_defaults | [bool](#bool) | repeated | True if the operator class is the default. (PostgreSQL specific). |------<a name="bytebase-store-InstanceRoleMetadata"></a>### InstanceRoleMetadata@@ -1542,44 +1086,6 @@ InstanceRoleMetadata is the message for instance role.-<a name="bytebase-store-LinkedDatabaseMetadata"></a>--### LinkedDatabaseMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | |-| username | [string](#string) | | |-| host | [string](#string) | | |-------<a name="bytebase-store-MaterializedViewMetadata"></a>--### MaterializedViewMetadata-MaterializedViewMetadata is the metadata for materialized views.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the materialized view. |-| definition | [string](#string) | | The definition is the definition of a view. |-| comment | [string](#string) | | The comment is the comment of a view. |-| dependency_columns | [DependencyColumn](#bytebase-store-DependencyColumn) | repeated | The list of dependency columns of the view. |-| triggers | [TriggerMetadata](#bytebase-store-TriggerMetadata) | repeated | The ordered list of columns in the materialized view. |-| indexes | [IndexMetadata](#bytebase-store-IndexMetadata) | repeated | The list of indexes in the materialized view. |-| skip_dump | [bool](#bool) | | |------<a name="bytebase-store-ObjectSchema"></a>### ObjectSchema@@ -1644,66 +1150,6 @@ MaterializedViewMetadata is the metadata for materialized views.-<a name="bytebase-store-PackageMetadata"></a>--### PackageMetadata-PackageMetadata is the metadata for packages.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the package. |-| definition | [string](#string) | | The definition is the definition of a package. |-------<a name="bytebase-store-ProcedureMetadata"></a>--### ProcedureMetadata-ProcedureMetadata is the metadata for procedures.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the procedure. |-| definition | [string](#string) | | The definition is the definition of a procedure. |-| signature | [string](#string) | | The signature is the name with the number and type of input arguments the function takes. |-| character_set_client | [string](#string) | | MySQL specific metadata. |-| collation_connection | [string](#string) | | |-| database_collation | [string](#string) | | |-| sql_mode | [string](#string) | | |-| comment | [string](#string) | | |-| skip_dump | [bool](#bool) | | |-------<a name="bytebase-store-RuleMetadata"></a>--### RuleMetadata-RuleMetadata is the metadata for PostgreSQL rules.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the rule. |-| event | [string](#string) | | The event type of the rule: SELECT, INSERT, UPDATE, or DELETE. |-| condition | [string](#string) | | The WHERE condition of the rule (optional). |-| action | [string](#string) | | The command(s) to execute when the rule fires. |-| is_instead | [bool](#bool) | | The is_instead indicates whether this is an INSTEAD rule. |-| is_enabled | [bool](#bool) | | The is_enabled indicates whether the rule is enabled. |-| definition | [string](#string) | | The full CREATE RULE statement. |------<a name="bytebase-store-SchemaCatalog"></a>### SchemaCatalog@@ -1720,152 +1166,6 @@ RuleMetadata is the metadata for PostgreSQL rules.-<a name="bytebase-store-SchemaMetadata"></a>--### SchemaMetadata-SchemaMetadata is the metadata for schemas.-This is the concept of schema in Postgres, but it's a no-op for MySQL.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The schema name. It is an empty string for databases without such concept such as MySQL. |-| tables | [TableMetadata](#bytebase-store-TableMetadata) | repeated | The list of tables in a schema. |-| external_tables | [ExternalTableMetadata](#bytebase-store-ExternalTableMetadata) | repeated | The list of external tables in a schema. |-| views | [ViewMetadata](#bytebase-store-ViewMetadata) | repeated | The list of views in a schema. |-| functions | [FunctionMetadata](#bytebase-store-FunctionMetadata) | repeated | The list of functions in a schema. |-| procedures | [ProcedureMetadata](#bytebase-store-ProcedureMetadata) | repeated | The list of procedures in a schema. |-| streams | [StreamMetadata](#bytebase-store-StreamMetadata) | repeated | The list of streams in a schema, currently only used for Snowflake. |-| tasks | [TaskMetadata](#bytebase-store-TaskMetadata) | repeated | The list of tasks in a schema, currently only used for Snowflake. |-| materialized_views | [MaterializedViewMetadata](#bytebase-store-MaterializedViewMetadata) | repeated | The list of materialized views in a schema. |-| sequences | [SequenceMetadata](#bytebase-store-SequenceMetadata) | repeated | The list of sequences in a schema. |-| packages | [PackageMetadata](#bytebase-store-PackageMetadata) | repeated | The list of packages in a schema. |-| owner | [string](#string) | | |-| comment | [string](#string) | | |-| events | [EventMetadata](#bytebase-store-EventMetadata) | repeated | |-| enum_types | [EnumTypeMetadata](#bytebase-store-EnumTypeMetadata) | repeated | |-| skip_dump | [bool](#bool) | | |-| composite_types | [CompositeTypeMetadata](#bytebase-store-CompositeTypeMetadata) | repeated | The list of user-defined composite types in a schema (PostgreSQL family, CREATE TYPE ... AS). Excludes table/view row types and derived types. |-------<a name="bytebase-store-SequenceMetadata"></a>--### SequenceMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of a sequence. |-| data_type | [string](#string) | | The data type of a sequence. |-| start | [string](#string) | | The start value of a sequence. |-| min_value | [string](#string) | | The minimum value of a sequence. |-| max_value | [string](#string) | | The maximum value of a sequence. |-| increment | [string](#string) | | The increment value of a sequence. |-| cycle | [bool](#bool) | | Whether the sequence cycles. |-| cache_size | [string](#string) | | Cache size of a sequence. |-| last_value | [string](#string) | | The last value of a sequence. |-| owner_table | [string](#string) | | The table that owns the sequence. |-| owner_column | [string](#string) | | The column that owns the sequence. |-| comment | [string](#string) | | |-| skip_dump | [bool](#bool) | | |-------<a name="bytebase-store-SpatialIndexConfig"></a>--### SpatialIndexConfig-SpatialIndexConfig is the configuration for spatial indexes across different database engines.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| method | [string](#string) | | Index method/type (database-specific) Examples: "SPATIAL" (MySQL/SQL Server), "GIST"/"SPGIST" (PostgreSQL), "MDSYS.SPATIAL_INDEX_V2" (Oracle) |-| tessellation | [TessellationConfig](#bytebase-store-TessellationConfig) | | Tessellation configuration (primarily SQL Server) |-| storage | [StorageConfig](#bytebase-store-StorageConfig) | | Storage and performance parameters |-| dimensional | [DimensionalConfig](#bytebase-store-DimensionalConfig) | | Dimensional and constraint parameters |-| engine_specific | [SpatialIndexConfig.EngineSpecificEntry](#bytebase-store-SpatialIndexConfig-EngineSpecificEntry) | repeated | Database-specific parameters (stored as key-value pairs for extensibility) |-------<a name="bytebase-store-SpatialIndexConfig-EngineSpecificEntry"></a>--### SpatialIndexConfig.EngineSpecificEntry----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| key | [string](#string) | | |-| value | [string](#string) | | |-------<a name="bytebase-store-StorageConfig"></a>--### StorageConfig-StorageConfig defines storage and performance parameters for spatial indexes.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| fillfactor | [int32](#int32) | | PostgreSQL parameters--10-100 |-| buffering | [string](#string) | | auto, on, off |-| tablespace | [string](#string) | | Oracle parameters |-| work_tablespace | [string](#string) | | |-| sdo_level | [int32](#int32) | | |-| commit_interval | [int32](#int32) | | |-| pad_index | [bool](#bool) | | SQL Server parameters |-| sort_in_tempdb | [string](#string) | | ON, OFF |-| drop_existing | [bool](#bool) | | |-| online | [bool](#bool) | | |-| allow_row_locks | [bool](#bool) | | |-| allow_page_locks | [bool](#bool) | | |-| maxdop | [int32](#int32) | | |-| data_compression | [string](#string) | | NONE, ROW, PAGE |-------<a name="bytebase-store-StreamMetadata"></a>--### StreamMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the stream. |-| table_name | [string](#string) | | The table_name is the name of the table/view that the stream is created on. |-| owner | [string](#string) | | The owner of the stream. |-| comment | [string](#string) | | The comment of the stream. |-| type | [StreamMetadata.Type](#bytebase-store-StreamMetadata-Type) | | The type of the stream. |-| stale | [bool](#bool) | | Indicates whether the stream was last read before the `stale_after` time. |-| mode | [StreamMetadata.Mode](#bytebase-store-StreamMetadata-Mode) | | The mode of the stream. |-| definition | [string](#string) | | The definition of the stream. |------<a name="bytebase-store-TableCatalog"></a>### TableCatalog@@ -1883,182 +1183,9 @@ StorageConfig defines storage and performance parameters for spatial indexes.--<a name="bytebase-store-TableMetadata"></a>--### TableMetadata-TableMetadata is the metadata for tables.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the table. |-| columns | [ColumnMetadata](#bytebase-store-ColumnMetadata) | repeated | The columns is the ordered list of columns in a table. |-| indexes | [IndexMetadata](#bytebase-store-IndexMetadata) | repeated | The indexes is the list of indexes in a table. |-| engine | [string](#string) | | The engine is the engine of a table. |-| collation | [string](#string) | | The collation is the collation of a table. |-| charset | [string](#string) | | The character set of the table. |-| row_count | [int64](#int64) | | The row_count is the estimated number of rows of a table. |-| data_size | [int64](#int64) | | The data_size is the estimated data size of a table. |-| index_size | [int64](#int64) | | The index_size is the estimated index size of a table. |-| data_free | [int64](#int64) | | The data_free is the estimated free data size of a table. |-| create_options | [string](#string) | | The create_options is the create option of a table. |-| comment | [string](#string) | | The comment is the comment of a table. |-| foreign_keys | [ForeignKeyMetadata](#bytebase-store-ForeignKeyMetadata) | repeated | The foreign_keys is the list of foreign keys in a table. |-| partitions | [TablePartitionMetadata](#bytebase-store-TablePartitionMetadata) | repeated | The partitions is the list of partitions in a table. |-| check_constraints | [CheckConstraintMetadata](#bytebase-store-CheckConstraintMetadata) | repeated | The check_constraints is the list of check constraints in a table. |-| owner | [string](#string) | | |-| sorting_keys | [string](#string) | repeated | The sorting_keys is a tuple of column names or arbitrary expressions. ClickHouse specific field. Reference: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#order_by |-| triggers | [TriggerMetadata](#bytebase-store-TriggerMetadata) | repeated | |-| skip_dump | [bool](#bool) | | |-| rules | [RuleMetadata](#bytebase-store-RuleMetadata) | repeated | The rules is the list of rules in a table (PostgreSQL specific). |-| sharding_info | [string](#string) | | https://docs.pingcap.com/tidb/stable/information-schema-tables/ |-| primary_key_type | [string](#string) | | https://docs.pingcap.com/tidb/stable/clustered-indexes/#clustered-indexes CLUSTERED or NONCLUSTERED. |-| exclude_constraints | [ExcludeConstraintMetadata](#bytebase-store-ExcludeConstraintMetadata) | repeated | The exclude_constraints is the list of EXCLUDE constraints in a table (PostgreSQL specific). |-------<a name="bytebase-store-TablePartitionMetadata"></a>--### TablePartitionMetadata-TablePartitionMetadata is the metadata for table partitions.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the table partition. |-| type | [TablePartitionMetadata.Type](#bytebase-store-TablePartitionMetadata-Type) | | The type of a table partition. |-| expression | [string](#string) | | The expression is the expression of a table partition. For PostgreSQL, the expression is the text of {FOR VALUES partition_bound_spec}, see https://www.postgresql.org/docs/current/sql-createtable.html. For MySQL, the expression is the `expr` or `column_list` of the following syntax. PARTITION BY { [LINEAR] HASH(expr) | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list) | RANGE{(expr) | COLUMNS(column_list)} | LIST{(expr) | COLUMNS(column_list)} }. |-| value | [string](#string) | | The value is the value of a table partition. For MySQL, the value is for RANGE and LIST partition types, - For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. - For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values. - For others, it's an empty string. |-| use_default | [string](#string) | | The use_default is whether the users use the default partition, it stores the different value for different database engines. For MySQL, it's [INT] type, 0 means not use default partition, otherwise, it's equals to number in syntax [SUB]PARTITION {number}. |-| subpartitions | [TablePartitionMetadata](#bytebase-store-TablePartitionMetadata) | repeated | The subpartitions is the list of subpartitions in a table partition. |-| indexes | [IndexMetadata](#bytebase-store-IndexMetadata) | repeated | |-| check_constraints | [CheckConstraintMetadata](#bytebase-store-CheckConstraintMetadata) | repeated | |-| exclude_constraints | [ExcludeConstraintMetadata](#bytebase-store-ExcludeConstraintMetadata) | repeated | |-------<a name="bytebase-store-TaskMetadata"></a>--### TaskMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the task. |-| id | [string](#string) | | The Snowflake-generated ID of the task. Example: 01ad32a0-1bb6-5e93-0000-000000000001. |-| owner | [string](#string) | | The owner of the task. |-| comment | [string](#string) | | The comment of the task. |-| warehouse | [string](#string) | | The warehouse of the task. |-| schedule | [string](#string) | | The schedule interval of the task. |-| predecessors | [string](#string) | repeated | The predecessor tasks of the task. |-| state | [TaskMetadata.State](#bytebase-store-TaskMetadata-State) | | The state of the task. |-| condition | [string](#string) | | The condition of the task. |-| definition | [string](#string) | | The definition of the task. |-------<a name="bytebase-store-TessellationConfig"></a>--### TessellationConfig-TessellationConfig defines tessellation parameters for spatial indexes.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| scheme | [string](#string) | | Tessellation scheme Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID |-| bounding_box | [BoundingBox](#bytebase-store-BoundingBox) | | Bounding box for GEOMETRY indexes (SQL Server) |-| grid_levels | [GridLevel](#bytebase-store-GridLevel) | repeated | Grid level configuration (SQL Server) |-| cells_per_object | [int32](#int32) | | Cells per object (SQL Server) |-------<a name="bytebase-store-TriggerMetadata"></a>--### TriggerMetadata----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the trigger. |-| event | [string](#string) | | The event that triggers this action, such as INSERT, UPDATE, DELETE, or TRUNCATE. |-| timing | [string](#string) | | The timing of when the trigger fires, such as BEFORE or AFTER. |-| body | [string](#string) | | The body of the trigger. |-| sql_mode | [string](#string) | | |-| character_set_client | [string](#string) | | |-| collation_connection | [string](#string) | | |-| comment | [string](#string) | | |-| skip_dump | [bool](#bool) | | |-------<a name="bytebase-store-ViewMetadata"></a>--### ViewMetadata-ViewMetadata is the metadata for views.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the view. |-| definition | [string](#string) | | The definition is the definition of a view. |-| comment | [string](#string) | | The comment is the comment of a view. |-| dependency_columns | [DependencyColumn](#bytebase-store-DependencyColumn) | repeated | The list of dependency columns of a view. |-| columns | [ColumnMetadata](#bytebase-store-ColumnMetadata) | repeated | The ordered list of columns in the view. |-| triggers | [TriggerMetadata](#bytebase-store-TriggerMetadata) | repeated | The list of triggers in the view. |-| skip_dump | [bool](#bool) | | |-| rules | [RuleMetadata](#bytebase-store-RuleMetadata) | repeated | The rules is the list of rules in a view (PostgreSQL specific). |------<a name="bytebase-store-ColumnMetadata-IdentityGeneration"></a>--### ColumnMetadata.IdentityGeneration---| Name | Number | Description |-| ---- | ------ | ----------- |-| IDENTITY_GENERATION_UNSPECIFIED | 0 | |-| ALWAYS | 1 | |-| BY_DEFAULT | 2 | |----<a name="bytebase-store-GenerationMetadata-Type"></a>--### GenerationMetadata.Type---| Name | Number | Description |-| ---- | ------ | ----------- |-| TYPE_UNSPECIFIED | 0 | |-| TYPE_VIRTUAL | 1 | |-| TYPE_STORED | 2 | |---<a name="bytebase-store-ObjectSchema-Type"></a>### ObjectSchema.Type@@ -2075,32 +1202,6 @@ ViewMetadata is the metadata for views.-<a name="bytebase-store-StreamMetadata-Mode"></a>--### StreamMetadata.Mode---| Name | Number | Description |-| ---- | ------ | ----------- |-| MODE_UNSPECIFIED | 0 | |-| MODE_DEFAULT | 1 | |-| MODE_APPEND_ONLY | 2 | |-| MODE_INSERT_ONLY | 3 | |----<a name="bytebase-store-StreamMetadata-Type"></a>--### StreamMetadata.Type---| Name | Number | Description |-| ---- | ------ | ----------- |-| TYPE_UNSPECIFIED | 0 | |-| TYPE_DELTA | 1 | |---<a name="bytebase-store-SyncStatus"></a>### SyncStatus@@ -2113,44 +1214,6 @@ SyncStatus is the status of the database sync operation.| SYNC_STATUS_FAILED | 2 | |--<a name="bytebase-store-TablePartitionMetadata-Type"></a>--### TablePartitionMetadata.Type-The type is the type of a table partition. Some database engines may not-support all types. Only available for the following database engines now:-MySQL: RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, LINEAR HASH, KEY,-LINEAR_KEY-(https://dev.mysql.com/doc/refman/8.0/en/partitioning-types.html) TiDB:-RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, KEY PostgreSQL: RANGE,-LIST, HASH (https://www.postgresql.org/docs/current/ddl-partitioning.html)--| Name | Number | Description |-| ---- | ------ | ----------- |-| TYPE_UNSPECIFIED | 0 | |-| RANGE | 1 | |-| RANGE_COLUMNS | 2 | |-| LIST | 3 | |-| LIST_COLUMNS | 4 | |-| HASH | 5 | |-| LINEAR_HASH | 6 | |-| KEY | 7 | |-| LINEAR_KEY | 8 | |----<a name="bytebase-store-TaskMetadata-State"></a>--### TaskMetadata.State---| Name | Number | Description |-| ---- | ------ | ----------- |-| STATE_UNSPECIFIED | 0 | |-| STATE_STARTED | 1 | |-| STATE_SUSPENDED | 2 | |--diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex bfdd79a6d4..27b147ff9d 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -363,14 +363,6 @@<a href="#store%2fdatabase.proto">store/database.proto</a><ul>- <li>- <a href="#bytebase.store.BoundingBox"><span class="badge">M</span>BoundingBox</a>- </li>-- <li>- <a href="#bytebase.store.CheckConstraintMetadata"><span class="badge">M</span>CheckConstraintMetadata</a>- </li>-<li><a href="#bytebase.store.ColumnCatalog"><span class="badge">M</span>ColumnCatalog</a></li>@@ -379,18 +371,6 @@<a href="#bytebase.store.ColumnCatalog.LabelsEntry"><span class="badge">M</span>ColumnCatalog.LabelsEntry</a></li>- <li>- <a href="#bytebase.store.ColumnMetadata"><span class="badge">M</span>ColumnMetadata</a>- </li>-- <li>- <a href="#bytebase.store.CompositeTypeAttribute"><span class="badge">M</span>CompositeTypeAttribute</a>- </li>-- <li>- <a href="#bytebase.store.CompositeTypeMetadata"><span class="badge">M</span>CompositeTypeMetadata</a>- </li>-<li><a href="#bytebase.store.DatabaseConfig"><span class="badge">M</span>DatabaseConfig</a></li>@@ -403,78 +383,10 @@<a href="#bytebase.store.DatabaseMetadata.LabelsEntry"><span class="badge">M</span>DatabaseMetadata.LabelsEntry</a></li>- <li>- <a href="#bytebase.store.DatabaseSchemaMetadata"><span class="badge">M</span>DatabaseSchemaMetadata</a>- </li>-- <li>- <a href="#bytebase.store.DependencyColumn"><span class="badge">M</span>DependencyColumn</a>- </li>-- <li>- <a href="#bytebase.store.DependencyTable"><span class="badge">M</span>DependencyTable</a>- </li>-- <li>- <a href="#bytebase.store.DimensionalConfig"><span class="badge">M</span>DimensionalConfig</a>- </li>-- <li>- <a href="#bytebase.store.EnumTypeMetadata"><span class="badge">M</span>EnumTypeMetadata</a>- </li>-- <li>- <a href="#bytebase.store.EventMetadata"><span class="badge">M</span>EventMetadata</a>- </li>-- <li>- <a href="#bytebase.store.EventTriggerMetadata"><span class="badge">M</span>EventTriggerMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ExcludeConstraintMetadata"><span class="badge">M</span>ExcludeConstraintMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ExtensionMetadata"><span class="badge">M</span>ExtensionMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ExternalTableMetadata"><span class="badge">M</span>ExternalTableMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ForeignKeyMetadata"><span class="badge">M</span>ForeignKeyMetadata</a>- </li>-- <li>- <a href="#bytebase.store.FunctionMetadata"><span class="badge">M</span>FunctionMetadata</a>- </li>-- <li>- <a href="#bytebase.store.GenerationMetadata"><span class="badge">M</span>GenerationMetadata</a>- </li>-- <li>- <a href="#bytebase.store.GridLevel"><span class="badge">M</span>GridLevel</a>- </li>-- <li>- <a href="#bytebase.store.IndexMetadata"><span class="badge">M</span>IndexMetadata</a>- </li>-<li><a href="#bytebase.store.InstanceRoleMetadata"><span class="badge">M</span>InstanceRoleMetadata</a></li>- <li>- <a href="#bytebase.store.LinkedDatabaseMetadata"><span class="badge">M</span>LinkedDatabaseMetadata</a>- </li>-- <li>- <a href="#bytebase.store.MaterializedViewMetadata"><span class="badge">M</span>MaterializedViewMetadata</a>- </li>-<li><a href="#bytebase.store.ObjectSchema"><span class="badge">M</span>ObjectSchema</a></li>@@ -491,107 +403,23 @@<a href="#bytebase.store.ObjectSchema.StructKind.PropertiesEntry"><span class="badge">M</span>ObjectSchema.StructKind.PropertiesEntry</a></li>- <li>- <a href="#bytebase.store.PackageMetadata"><span class="badge">M</span>PackageMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ProcedureMetadata"><span class="badge">M</span>ProcedureMetadata</a>- </li>-- <li>- <a href="#bytebase.store.RuleMetadata"><span class="badge">M</span>RuleMetadata</a>- </li>-<li><a href="#bytebase.store.SchemaCatalog"><span class="badge">M</span>SchemaCatalog</a></li>- <li>- <a href="#bytebase.store.SchemaMetadata"><span class="badge">M</span>SchemaMetadata</a>- </li>-- <li>- <a href="#bytebase.store.SequenceMetadata"><span class="badge">M</span>SequenceMetadata</a>- </li>-- <li>- <a href="#bytebase.store.SpatialIndexConfig"><span class="badge">M</span>SpatialIndexConfig</a>- </li>-- <li>- <a href="#bytebase.store.SpatialIndexConfig.EngineSpecificEntry"><span class="badge">M</span>SpatialIndexConfig.EngineSpecificEntry</a>- </li>-- <li>- <a href="#bytebase.store.StorageConfig"><span class="badge">M</span>StorageConfig</a>- </li>-- <li>- <a href="#bytebase.store.StreamMetadata"><span class="badge">M</span>StreamMetadata</a>- </li>-<li><a href="#bytebase.store.TableCatalog"><span class="badge">M</span>TableCatalog</a></li>- <li>- <a href="#bytebase.store.TableMetadata"><span class="badge">M</span>TableMetadata</a>- </li>-- <li>- <a href="#bytebase.store.TablePartitionMetadata"><span class="badge">M</span>TablePartitionMetadata</a>- </li>-- <li>- <a href="#bytebase.store.TaskMetadata"><span class="badge">M</span>TaskMetadata</a>- </li>-- <li>- <a href="#bytebase.store.TessellationConfig"><span class="badge">M</span>TessellationConfig</a>- </li>-- <li>- <a href="#bytebase.store.TriggerMetadata"><span class="badge">M</span>TriggerMetadata</a>- </li>-- <li>- <a href="#bytebase.store.ViewMetadata"><span class="badge">M</span>ViewMetadata</a>- </li>--- <li>- <a href="#bytebase.store.ColumnMetadata.IdentityGeneration"><span class="badge">E</span>ColumnMetadata.IdentityGeneration</a>- </li>-- <li>- <a href="#bytebase.store.GenerationMetadata.Type"><span class="badge">E</span>GenerationMetadata.Type</a>- </li><li><a href="#bytebase.store.ObjectSchema.Type"><span class="badge">E</span>ObjectSchema.Type</a></li>- <li>- <a href="#bytebase.store.StreamMetadata.Mode"><span class="badge">E</span>StreamMetadata.Mode</a>- </li>-- <li>- <a href="#bytebase.store.StreamMetadata.Type"><span class="badge">E</span>StreamMetadata.Type</a>- </li>-<li><a href="#bytebase.store.SyncStatus"><span class="badge">E</span>SyncStatus</a></li>- <li>- <a href="#bytebase.store.TablePartitionMetadata.Type"><span class="badge">E</span>TablePartitionMetadata.Type</a>- </li>-- <li>- <a href="#bytebase.store.TaskMetadata.State"><span class="badge">E</span>TaskMetadata.State</a>- </li>-</ul>@@ -3319,8 +3147,8 @@ wrong for a volume budget, where a steady trickle would never reset and<p></p>- <h3 id="bytebase.store.BoundingBox">BoundingBox</h3>- <p>BoundingBox defines the bounding box for spatial indexes.</p>+ <h3 id="bytebase.store.ColumnCatalog">ColumnCatalog</h3>+ <p></p><table class="field-table">@@ -3330,30 +3158,37 @@ wrong for a volume budget, where a steady trickle would never reset and<tbody><tr>- <td>xmin</td>- <td><a href="#double">double</a></td>+ <td>name</td>+ <td><a href="#string">string</a></td><td></td>- <td><p> </p></td>+ <td><p>The name of the column. </p></td></tr><tr>- <td>ymin</td>- <td><a href="#double">double</a></td>+ <td>semantic_type</td>+ <td><a href="#string">string</a></td><td></td><td><p> </p></td></tr><tr>- <td>xmax</td>- <td><a href="#double">double</a></td>+ <td>labels</td>+ <td><a href="#bytebase.store.ColumnCatalog.LabelsEntry">ColumnCatalog.LabelsEntry</a></td>+ <td>repeated</td>+ <td><p>The user labels for a column. </p></td>+ </tr>++ <tr>+ <td>classification</td>+ <td><a href="#string">string</a></td><td></td><td><p> </p></td></tr><tr>- <td>ymax</td>- <td><a href="#double">double</a></td>- <td></td>+ <td>object_schema</td>+ <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>+ <td>optional</td><td><p> </p></td></tr>@@ -3364,7 +3199,7 @@ wrong for a volume budget, where a steady trickle would never reset and- <h3 id="bytebase.store.CheckConstraintMetadata">CheckConstraintMetadata</h3>+ <h3 id="bytebase.store.ColumnCatalog.LabelsEntry">ColumnCatalog.LabelsEntry</h3><p></p>@@ -3375,17 +3210,17 @@ wrong for a volume budget, where a steady trickle would never reset and<tbody><tr>- <td>name</td>+ <td>key</td><td><a href="#string">string</a></td><td></td>- <td><p>The name of the check constraint. </p></td>+ <td><p> </p></td></tr><tr>- <td>expression</td>+ <td>value</td><td><a href="#string">string</a></td><td></td>- <td><p>The expression is the expression of a check constraint. </p></td>+ <td><p> </p></td></tr></tbody>@@ -3395,7 +3230,7 @@ wrong for a volume budget, where a steady trickle would never reset and- <h3 id="bytebase.store.ColumnCatalog">ColumnCatalog</h3>+ <h3 id="bytebase.store.DatabaseConfig">DatabaseConfig</h3><p></p>@@ -3409,37 +3244,83 @@ wrong for a volume budget, where a steady trickle would never reset and<td>name</td><td><a href="#string">string</a></td><td></td>- <td><p>The name of the column. </p></td>+ <td><p> </p></td></tr><tr>- <td>semantic_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>+ <td>schemas</td>+ <td><a href="#bytebase.store.SchemaCatalog">SchemaCatalog</a></td>+ <td>repeated</td>+ <td><p>The schema_configs is the list of configs for schemas in a database. </p></td></tr>+ </tbody>+ </table>++++++ <h3 id="bytebase.store.DatabaseMetadata">DatabaseMetadata</h3>+ <p>DatabaseMetadata is the metadata for databases.</p>+++ <table class="field-table">+ <thead>+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>+ </thead>+ <tbody>+<tr><td>labels</td>- <td><a href="#bytebase.store.ColumnCatalog.LabelsEntry">ColumnCatalog.LabelsEntry</a></td>+ <td><a href="#bytebase.store.DatabaseMetadata.LabelsEntry">DatabaseMetadata.LabelsEntry</a></td><td>repeated</td>- <td><p>The user labels for a column. </p></td>+ <td><p> </p></td></tr><tr>- <td>classification</td>- <td><a href="#string">string</a></td>+ <td>last_sync_time</td>+ <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td><td></td><td><p> </p></td></tr><tr>- <td>object_schema</td>- <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>- <td>optional</td>+ <td>backup_available</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>++ <tr>+ <td>datashare</td>+ <td><a href="#bool">bool</a></td>+ <td></td><td><p> </p></td></tr>+ <tr>+ <td>release</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The release that was last applied to this database.+Format: projects/{project}/releases/{release_id} </p></td>+ </tr>++ <tr>+ <td>sync_status</td>+ <td><a href="#bytebase.store.SyncStatus">SyncStatus</a></td>+ <td></td>+ <td><p>The sync status of the database. </p></td>+ </tr>++ <tr>+ <td>sync_error</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The error message if sync failed. </p></td>+ </tr>+</tbody></table>@@ -3447,7 +3328,7 @@ wrong for a volume budget, where a steady trickle would never reset and- <h3 id="bytebase.store.ColumnCatalog.LabelsEntry">ColumnCatalog.LabelsEntry</h3>+ <h3 id="bytebase.store.DatabaseMetadata.LabelsEntry">DatabaseMetadata.LabelsEntry</h3><p></p>@@ -3478,8 +3359,8 @@ wrong for a volume budget, where a steady trickle would never reset and- <h3 id="bytebase.store.ColumnMetadata">ColumnMetadata</h3>- <p>ColumnMetadata is the metadata for columns.</p>+ <h3 id="bytebase.store.InstanceRoleMetadata">InstanceRoleMetadata</h3>+ <p>InstanceRoleMetadata is the message for instance role.</p><table class="field-table">@@ -3492,154 +3373,15 @@ wrong for a volume budget, where a steady trickle would never reset and<td>name</td><td><a href="#string">string</a></td><td></td>- <td><p>The name of the column. </p></td>- </tr>-- <tr>- <td>position</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p>The position is the position in columns. </p></td>- </tr>-- <tr>- <td>default</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The default value of the column. </p></td>- </tr>-- <tr>- <td>default_on_null</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Oracle specific metadata.-The default_on_null is the default on null of a column. </p></td>+ <td><p>The role name. It's unique within the instance. </p></td></tr><tr>- <td>on_update</td>+ <td>grant</td><td><a href="#string">string</a></td><td></td>- <td><p>The on_update is the on update action of a column.-For MySQL like databases, it's only supported for TIMESTAMP columns with-CURRENT_TIMESTAMP as on update value. </p></td>- </tr>-- <tr>- <td>nullable</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The nullable is the nullable of a column. </p></td>- </tr>-- <tr>- <td>type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The type is the type of a column. </p></td>- </tr>-- <tr>- <td>character_set</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The character_set is the character_set of a column. </p></td>- </tr>-- <tr>- <td>collation</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The collation is the collation of a column. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment is the comment of a column. </p></td>- </tr>-- <tr>- <td>generation</td>- <td><a href="#bytebase.store.GenerationMetadata">GenerationMetadata</a></td>- <td></td>- <td><p>The generation is for generated columns. </p></td>- </tr>-- <tr>- <td>is_identity</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>identity_generation</td>- <td><a href="#bytebase.store.ColumnMetadata.IdentityGeneration">ColumnMetadata.IdentityGeneration</a></td>- <td></td>- <td><p>The identity_generation is for identity columns, PG only. </p></td>- </tr>-- <tr>- <td>identity_seed</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The identity_seed is for identity columns, MSSQL only. </p></td>- </tr>-- <tr>- <td>identity_increment</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The identity_increment is for identity columns, MSSQL only. </p></td>- </tr>-- <tr>- <td>default_constraint_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The default_constraint_name is the name of the default constraint, MSSQL only.-In MSSQL, default values are implemented as named constraints. When modifying or-dropping a column's default value, you must reference the constraint by name.-This field stores the actual constraint name from the database.--Example: A column definition like:- CREATE TABLE employees (- status NVARCHAR(20) DEFAULT 'active'- )--Will create a constraint with an auto-generated name like 'DF__employees__statu__3B75D760'-or a user-defined name if specified:- ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'active' FOR status--To modify the default, you must first drop the existing constraint by name:- ALTER TABLE employees DROP CONSTRAINT DF__employees__statu__3B75D760- ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'inactive' FOR status--This field is populated when syncing from the database. When empty (e.g., when parsing-from SQL files), the system cannot automatically drop the constraint. </p></td>- </tr>-- <tr>- <td>srid</td>- <td><a href="#uint32">uint32</a></td>- <td>optional</td>- <td><p>The spatial reference system identifier of a spatial column, MySQL 8.0 only.-Unset means the column declares no SRID; presence carries the explicit SRID,-including the valid SRID 0. SRS_IDs are unsigned 32-bit (custom SRSs may exceed-int32). Captured from information_schema.COLUMNS.SRS_ID and rendered as the-`/*!80003 SRID n */` column attribute. </p></td>- </tr>-- <tr>- <td>is_invisible</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Whether the column is invisible (hidden from SELECT *), MySQL 8.0.23+ only.-Captured from information_schema.COLUMNS.EXTRA containing INVISIBLE and-rendered as the `/*!80023 INVISIBLE */` column attribute. </p></td>+ <td><p>The grant display string on the instance. It's generated by database+engine. </p></td></tr></tbody>@@ -3649,7 +3391,7 @@ rendered as the `/*!80023 INVISIBLE */` column attribute. </p></td>- <h3 id="bytebase.store.CompositeTypeAttribute">CompositeTypeAttribute</h3>+ <h3 id="bytebase.store.ObjectSchema">ObjectSchema</h3><p></p>@@ -3660,30 +3402,28 @@ rendered as the `/*!80023 INVISIBLE */` column attribute. </p></td><tbody><tr>- <td>name</td>- <td><a href="#string">string</a></td>+ <td>type</td>+ <td><a href="#bytebase.store.ObjectSchema.Type">ObjectSchema.Type</a></td><td></td>- <td><p>The name of the attribute. </p></td>+ <td><p> </p></td></tr><tr>- <td>type</td>- <td><a href="#string">string</a></td>+ <td>struct_kind</td>+ <td><a href="#bytebase.store.ObjectSchema.StructKind">ObjectSchema.StructKind</a></td><td></td>- <td><p>The attribute type. User-defined types are always schema-qualified. </p></td>+ <td><p> </p></td></tr><tr>- <td>collation</td>- <td><a href="#string">string</a></td>+ <td>array_kind</td>+ <td><a href="#bytebase.store.ObjectSchema.ArrayKind">ObjectSchema.ArrayKind</a></td><td></td>- <td><p>The non-default collation of the attribute as an emit-ready SQL-identifier reference (quoted as needed, schema-qualified when outside-pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td>+ <td><p> </p></td></tr><tr>- <td>comment</td>+ <td>semantic_type</td><td><a href="#string">string</a></td><td></td><td><p> </p></td>@@ -3696,7 +3436,7 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td>- <h3 id="bytebase.store.CompositeTypeMetadata">CompositeTypeMetadata</h3>+ <h3 id="bytebase.store.ObjectSchema.ArrayKind">ObjectSchema.ArrayKind</h3><p></p>@@ -3707,29 +3447,8 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td><tbody><tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the composite type. </p></td>- </tr>-- <tr>- <td>attributes</td>- <td><a href="#bytebase.store.CompositeTypeAttribute">CompositeTypeAttribute</a></td>- <td>repeated</td>- <td><p>The ordered attributes of the composite type. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>+ <td>kind</td>+ <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td><td></td><td><p> </p></td></tr>@@ -3741,7 +3460,7 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td>- <h3 id="bytebase.store.DatabaseConfig">DatabaseConfig</h3>+ <h3 id="bytebase.store.ObjectSchema.StructKind">ObjectSchema.StructKind</h3><p></p>@@ -3752,17 +3471,10 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td><tbody><tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>schemas</td>- <td><a href="#bytebase.store.SchemaCatalog">SchemaCatalog</a></td>+ <td>properties</td>+ <td><a href="#bytebase.store.ObjectSchema.StructKind.PropertiesEntry">ObjectSchema.StructKind.PropertiesEntry</a></td><td>repeated</td>- <td><p>The schema_configs is the list of configs for schemas in a database. </p></td>+ <td><p> </p></td></tr></tbody>@@ -3772,8 +3484,8 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td>- <h3 id="bytebase.store.DatabaseMetadata">DatabaseMetadata</h3>- <p>DatabaseMetadata is the metadata for databases.</p>+ <h3 id="bytebase.store.ObjectSchema.StructKind.PropertiesEntry">ObjectSchema.StructKind.PropertiesEntry</h3>+ <p></p><table class="field-table">@@ -3783,55 +3495,19 @@ pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`. </p></td><tbody><tr>- <td>labels</td>- <td><a href="#bytebase.store.DatabaseMetadata.LabelsEntry">DatabaseMetadata.LabelsEntry</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>last_sync_time</td>- <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>backup_available</td>- <td><a href="#bool">bool</a></td>+ <td>key</td>+ <td><a href="#string">string</a></td><td></td><td><p> </p></td></tr><tr>- <td>datashare</td>- <td><a href="#bool">bool</a></td>+ <td>value</td>+ <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td><td></td><td><p> </p></td></tr>- <tr>- <td>release</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The release that was last applied to this database.-Format: projects/{project}/releases/{release_id} </p></td>- </tr>-- <tr>- <td>sync_status</td>- <td><a href="#bytebase.store.SyncStatus">SyncStatus</a></td>- <td></td>- <td><p>The sync status of the database. </p></td>- </tr>-- <tr>- <td>sync_error</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The error message if sync failed. </p></td>- </tr>-</tbody></table>@@ -3839,7 +3515,7 @@ Format: projects/{project}/releases/{release_id} </p></td>- <h3 id="bytebase.store.DatabaseMetadata.LabelsEntry">DatabaseMetadata.LabelsEntry</h3>+ <h3 id="bytebase.store.SchemaCatalog">SchemaCatalog</h3><p></p>@@ -3850,17 +3526,18 @@ Format: projects/{project}/releases/{release_id} </p></td><tbody><tr>- <td>key</td>+ <td>name</td><td><a href="#string">string</a></td><td></td>- <td><p> </p></td>+ <td><p>The schema name.+It is an empty string for databases without such concept such as MySQL. </p></td></tr><tr>- <td>value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>+ <td>tables</td>+ <td><a href="#bytebase.store.TableCatalog">TableCatalog</a></td>+ <td>repeated</td>+ <td><p>The table_configs is the list of configs for tables in a schema. </p></td></tr></tbody>@@ -3870,8 +3547,8 @@ Format: projects/{project}/releases/{release_id} </p></td>- <h3 id="bytebase.store.DatabaseSchemaMetadata">DatabaseSchemaMetadata</h3>- <p>DatabaseSchemaMetadata is the schema metadata for databases.</p>+ <h3 id="bytebase.store.TableCatalog">TableCatalog</h3>+ <p></p><table class="field-table">@@ -3884,80 +3561,30 @@ Format: projects/{project}/releases/{release_id} </p></td><td>name</td><td><a href="#string">string</a></td><td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>schemas</td>- <td><a href="#bytebase.store.SchemaMetadata">SchemaMetadata</a></td>- <td>repeated</td>- <td><p>The list of schemas in a database. </p></td>- </tr>-- <tr>- <td>character_set</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The character set of the database. </p></td>- </tr>-- <tr>- <td>collation</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The collation of the database. </p></td>+ <td><p>The name of the table. </p></td></tr><tr>- <td>extensions</td>- <td><a href="#bytebase.store.ExtensionMetadata">ExtensionMetadata</a></td>+ <td>columns</td>+ <td><a href="#bytebase.store.ColumnCatalog">ColumnCatalog</a></td><td>repeated</td>- <td><p>The list of extensions in a database. </p></td>- </tr>-- <tr>- <td>datashare</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The database belongs to a datashare. </p></td>- </tr>-- <tr>- <td>service_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The service name of the database. It's an Oracle-specific concept. </p></td>+ <td><p>The column_configs is the ordered list of configs for columns in a table. </p></td></tr><tr>- <td>linked_databases</td>- <td><a href="#bytebase.store.LinkedDatabaseMetadata">LinkedDatabaseMetadata</a></td>- <td>repeated</td>+ <td>object_schema</td>+ <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>+ <td>optional</td><td><p> </p></td></tr><tr>- <td>owner</td>+ <td>classification</td><td><a href="#string">string</a></td><td></td><td><p> </p></td></tr>- <tr>- <td>search_path</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The search_path is the search path of a PostgreSQL database. </p></td>- </tr>-- <tr>- <td>event_triggers</td>- <td><a href="#bytebase.store.EventTriggerMetadata">EventTriggerMetadata</a></td>- <td>repeated</td>- <td><p>The list of event triggers in a database (PostgreSQL specific).-Event triggers are database-level objects, not schema-scoped. </p></td>- </tr>-</tbody></table>@@ -3965,2478 +3592,7 @@ Event triggers are database-level objects, not schema-scoped. </p></td>- <h3 id="bytebase.store.DependencyColumn">DependencyColumn</h3>- <p>DependencyColumn is the metadata for dependency columns.</p>-- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema is the schema of a reference column. </p></td>- </tr>-- <tr>- <td>table</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The table is the table of a reference column. </p></td>- </tr>-- <tr>- <td>column</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The column is the name of a reference column. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.DependencyTable">DependencyTable</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema is the schema of a reference table. </p></td>- </tr>-- <tr>- <td>table</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The table is the name of a reference table. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.DimensionalConfig">DimensionalConfig</h3>- <p>DimensionalConfig defines dimensional and constraint parameters for spatial indexes.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>dimensions</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p>Number of dimensions (2-4, default 2) </p></td>- </tr>-- <tr>- <td>data_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Spatial data type-Examples: GEOMETRY, GEOGRAPHY, POINT, POLYGON, etc. </p></td>- </tr>-- <tr>- <td>operator_class</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>PostgreSQL operator class-Examples: gist_geometry_ops_2d, gist_geometry_ops_nd, etc. </p></td>- </tr>-- <tr>- <td>layer_gtype</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Oracle geometry type constraint-Examples: POINT, LINE, POLYGON, COLLECTION </p></td>- </tr>-- <tr>- <td>parallel_build</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Parallel index creation </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.EnumTypeMetadata">EnumTypeMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the enum type. </p></td>- </tr>-- <tr>- <td>values</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The enum values of the type. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.EventMetadata">EventMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the event. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schedule of the event. </p></td>- </tr>-- <tr>- <td>time_zone</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The time zone of the event. </p></td>- </tr>-- <tr>- <td>sql_mode</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>character_set_client</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>collation_connection</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.EventTriggerMetadata">EventTriggerMetadata</h3>- <p>EventTriggerMetadata is the metadata for PostgreSQL event triggers.</p><p>Event triggers are database-level objects that fire on DDL events.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the event trigger. </p></td>- </tr>-- <tr>- <td>event</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The event type: DDL_COMMAND_START, DDL_COMMAND_END, SQL_DROP, TABLE_REWRITE. </p></td>- </tr>-- <tr>- <td>tags</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The tags filter (e.g., ['CREATE TABLE', 'DROP TABLE']). </p></td>- </tr>-- <tr>- <td>function_schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema of the function to execute. </p></td>- </tr>-- <tr>- <td>function_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the function to execute. </p></td>- </tr>-- <tr>- <td>enabled</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Whether the trigger is enabled. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The full CREATE EVENT TRIGGER definition from pg_get_event_trigger_def().-SDL output should prefer using this field. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment on the event trigger. </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Skip dump flag (for extension-owned triggers). </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ExcludeConstraintMetadata">ExcludeConstraintMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the EXCLUDE constraint. </p></td>- </tr>-- <tr>- <td>expression</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The expression is the full EXCLUDE constraint definition including "EXCLUDE" keyword.-Example: "EXCLUDE USING gist (room_id WITH =, during WITH &&)" </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ExtensionMetadata">ExtensionMetadata</h3>- <p>ExtensionMetadata is the metadata for extensions.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the extension. </p></td>- </tr>-- <tr>- <td>schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema where the extension is installed. However, the extension usage-is not limited to the schema. </p></td>- </tr>-- <tr>- <td>version</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The version is the version of an extension. </p></td>- </tr>-- <tr>- <td>description</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The description is the description of an extension. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ExternalTableMetadata">ExternalTableMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the external table. </p></td>- </tr>-- <tr>- <td>external_server_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The external_server_name is the name of the external server. </p></td>- </tr>-- <tr>- <td>external_database_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The external_database_name is the name of the external database. </p></td>- </tr>-- <tr>- <td>columns</td>- <td><a href="#bytebase.store.ColumnMetadata">ColumnMetadata</a></td>- <td>repeated</td>- <td><p>The columns is the ordered list of columns in a foreign table. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ForeignKeyMetadata">ForeignKeyMetadata</h3>- <p>ForeignKeyMetadata is the metadata for foreign keys.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the foreign key. </p></td>- </tr>-- <tr>- <td>columns</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The columns are the ordered referencing columns of a foreign key. </p></td>- </tr>-- <tr>- <td>referenced_schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The referenced_schema is the referenced schema name of a foreign key.-It is an empty string for databases without such concept such as MySQL. </p></td>- </tr>-- <tr>- <td>referenced_table</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The referenced_table is the referenced table name of a foreign key. </p></td>- </tr>-- <tr>- <td>referenced_columns</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The referenced_columns are the ordered referenced columns of a foreign key. </p></td>- </tr>-- <tr>- <td>on_delete</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The on_delete is the on delete action of a foreign key. </p></td>- </tr>-- <tr>- <td>on_update</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The on_update is the on update action of a foreign key. </p></td>- </tr>-- <tr>- <td>match_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The match_type is the match type of a foreign key.-The match_type is the PostgreSQL specific field.-It's empty string for other databases. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.FunctionMetadata">FunctionMetadata</h3>- <p>FunctionMetadata is the metadata for functions.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the function. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition is the definition of a function. </p></td>- </tr>-- <tr>- <td>signature</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The signature is the name with the number and type of input arguments the-function takes. </p></td>- </tr>-- <tr>- <td>character_set_client</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>MySQL specific metadata. </p></td>- </tr>-- <tr>- <td>collation_connection</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>database_collation</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>sql_mode</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>dependency_tables</td>- <td><a href="#bytebase.store.DependencyTable">DependencyTable</a></td>- <td>repeated</td>- <td><p>The dependency_tables is the list of dependency tables of a function.-For PostgreSQL, it's the list of tables that the function depends on the return type definition. </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.GenerationMetadata">GenerationMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>type</td>- <td><a href="#bytebase.store.GenerationMetadata.Type">GenerationMetadata.Type</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>expression</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.GridLevel">GridLevel</h3>- <p>GridLevel defines a grid level for spatial tessellation.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>level</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p>1-4 for SQL Server </p></td>- </tr>-- <tr>- <td>density</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>LOW, MEDIUM, HIGH </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.IndexMetadata">IndexMetadata</h3>- <p>IndexMetadata is the metadata for indexes.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the index. </p></td>- </tr>-- <tr>- <td>expressions</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The expressions are the ordered columns or expressions of an index.--For PostgreSQL, the canonical shape for each entry matches-pg_get_indexdef(oid, col, true) — the tightest `index_elem` grammar form:- - column key: bare identifier e.g. "id", `"Name"`- - function-call key: bare func_expr_windowless e.g. "lower(name)"- - expression key: parenthesized a_expr e.g. "(payload ->> 'k'::text)"-The DDL emitter writes entries verbatim into the CREATE INDEX key list. </p></td>- </tr>-- <tr>- <td>key_length</td>- <td><a href="#int64">int64</a></td>- <td>repeated</td>- <td><p>The ordered list of key lengths for the index.-If the key length is not specified, it is -1. </p></td>- </tr>-- <tr>- <td>descending</td>- <td><a href="#bool">bool</a></td>- <td>repeated</td>- <td><p>The ordered list of descending flags for the index columns. </p></td>- </tr>-- <tr>- <td>type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The type is the type of an index. </p></td>- </tr>-- <tr>- <td>unique</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The unique is whether the index is unique. </p></td>- </tr>-- <tr>- <td>primary</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The primary is whether the index is a primary key index. </p></td>- </tr>-- <tr>- <td>visible</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The visible is whether the index is visible. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment is the comment of an index. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition of an index. </p></td>- </tr>-- <tr>- <td>parent_index_schema</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema name of the parent index. </p></td>- </tr>-- <tr>- <td>parent_index_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The index name of the parent index. </p></td>- </tr>-- <tr>- <td>granularity</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The number of granules in the block. It's a ClickHouse specific field. </p></td>- </tr>-- <tr>- <td>is_constraint</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>It's a PostgreSQL specific field.-The unique constraint and unique index are not the same thing in PostgreSQL. </p></td>- </tr>-- <tr>- <td>spatial_config</td>- <td><a href="#bytebase.store.SpatialIndexConfig">SpatialIndexConfig</a></td>- <td></td>- <td><p>Spatial index specific configuration </p></td>- </tr>-- <tr>- <td>opclass_names</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>https://www.postgresql.org/docs/current/catalog-pg-opclass.html-Name of the operator class for each column. (PostgreSQL specific). </p></td>- </tr>-- <tr>- <td>opclass_defaults</td>- <td><a href="#bool">bool</a></td>- <td>repeated</td>- <td><p>True if the operator class is the default. (PostgreSQL specific). </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.InstanceRoleMetadata">InstanceRoleMetadata</h3>- <p>InstanceRoleMetadata is the message for instance role.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The role name. It's unique within the instance. </p></td>- </tr>-- <tr>- <td>grant</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The grant display string on the instance. It's generated by database-engine. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.LinkedDatabaseMetadata">LinkedDatabaseMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>username</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>host</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.MaterializedViewMetadata">MaterializedViewMetadata</h3>- <p>MaterializedViewMetadata is the metadata for materialized views.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the materialized view. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition is the definition of a view. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment is the comment of a view. </p></td>- </tr>-- <tr>- <td>dependency_columns</td>- <td><a href="#bytebase.store.DependencyColumn">DependencyColumn</a></td>- <td>repeated</td>- <td><p>The list of dependency columns of the view. </p></td>- </tr>-- <tr>- <td>triggers</td>- <td><a href="#bytebase.store.TriggerMetadata">TriggerMetadata</a></td>- <td>repeated</td>- <td><p>The ordered list of columns in the materialized view. </p></td>- </tr>-- <tr>- <td>indexes</td>- <td><a href="#bytebase.store.IndexMetadata">IndexMetadata</a></td>- <td>repeated</td>- <td><p>The list of indexes in the materialized view. </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ObjectSchema">ObjectSchema</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>type</td>- <td><a href="#bytebase.store.ObjectSchema.Type">ObjectSchema.Type</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>struct_kind</td>- <td><a href="#bytebase.store.ObjectSchema.StructKind">ObjectSchema.StructKind</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>array_kind</td>- <td><a href="#bytebase.store.ObjectSchema.ArrayKind">ObjectSchema.ArrayKind</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>semantic_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ObjectSchema.ArrayKind">ObjectSchema.ArrayKind</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>kind</td>- <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ObjectSchema.StructKind">ObjectSchema.StructKind</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>properties</td>- <td><a href="#bytebase.store.ObjectSchema.StructKind.PropertiesEntry">ObjectSchema.StructKind.PropertiesEntry</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ObjectSchema.StructKind.PropertiesEntry">ObjectSchema.StructKind.PropertiesEntry</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>key</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>value</td>- <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.PackageMetadata">PackageMetadata</h3>- <p>PackageMetadata is the metadata for packages.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the package. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition is the definition of a package. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ProcedureMetadata">ProcedureMetadata</h3>- <p>ProcedureMetadata is the metadata for procedures.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the procedure. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition is the definition of a procedure. </p></td>- </tr>-- <tr>- <td>signature</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The signature is the name with the number and type of input arguments the-function takes. </p></td>- </tr>-- <tr>- <td>character_set_client</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>MySQL specific metadata. </p></td>- </tr>-- <tr>- <td>collation_connection</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>database_collation</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>sql_mode</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.RuleMetadata">RuleMetadata</h3>- <p>RuleMetadata is the metadata for PostgreSQL rules.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the rule. </p></td>- </tr>-- <tr>- <td>event</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The event type of the rule: SELECT, INSERT, UPDATE, or DELETE. </p></td>- </tr>-- <tr>- <td>condition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The WHERE condition of the rule (optional). </p></td>- </tr>-- <tr>- <td>action</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The command(s) to execute when the rule fires. </p></td>- </tr>-- <tr>- <td>is_instead</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The is_instead indicates whether this is an INSTEAD rule. </p></td>- </tr>-- <tr>- <td>is_enabled</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>The is_enabled indicates whether the rule is enabled. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The full CREATE RULE statement. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.SchemaCatalog">SchemaCatalog</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema name.-It is an empty string for databases without such concept such as MySQL. </p></td>- </tr>-- <tr>- <td>tables</td>- <td><a href="#bytebase.store.TableCatalog">TableCatalog</a></td>- <td>repeated</td>- <td><p>The table_configs is the list of configs for tables in a schema. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.SchemaMetadata">SchemaMetadata</h3>- <p>SchemaMetadata is the metadata for schemas.</p><p>This is the concept of schema in Postgres, but it's a no-op for MySQL.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schema name.-It is an empty string for databases without such concept such as MySQL. </p></td>- </tr>-- <tr>- <td>tables</td>- <td><a href="#bytebase.store.TableMetadata">TableMetadata</a></td>- <td>repeated</td>- <td><p>The list of tables in a schema. </p></td>- </tr>-- <tr>- <td>external_tables</td>- <td><a href="#bytebase.store.ExternalTableMetadata">ExternalTableMetadata</a></td>- <td>repeated</td>- <td><p>The list of external tables in a schema. </p></td>- </tr>-- <tr>- <td>views</td>- <td><a href="#bytebase.store.ViewMetadata">ViewMetadata</a></td>- <td>repeated</td>- <td><p>The list of views in a schema. </p></td>- </tr>-- <tr>- <td>functions</td>- <td><a href="#bytebase.store.FunctionMetadata">FunctionMetadata</a></td>- <td>repeated</td>- <td><p>The list of functions in a schema. </p></td>- </tr>-- <tr>- <td>procedures</td>- <td><a href="#bytebase.store.ProcedureMetadata">ProcedureMetadata</a></td>- <td>repeated</td>- <td><p>The list of procedures in a schema. </p></td>- </tr>-- <tr>- <td>streams</td>- <td><a href="#bytebase.store.StreamMetadata">StreamMetadata</a></td>- <td>repeated</td>- <td><p>The list of streams in a schema, currently only used for Snowflake. </p></td>- </tr>-- <tr>- <td>tasks</td>- <td><a href="#bytebase.store.TaskMetadata">TaskMetadata</a></td>- <td>repeated</td>- <td><p>The list of tasks in a schema, currently only used for Snowflake. </p></td>- </tr>-- <tr>- <td>materialized_views</td>- <td><a href="#bytebase.store.MaterializedViewMetadata">MaterializedViewMetadata</a></td>- <td>repeated</td>- <td><p>The list of materialized views in a schema. </p></td>- </tr>-- <tr>- <td>sequences</td>- <td><a href="#bytebase.store.SequenceMetadata">SequenceMetadata</a></td>- <td>repeated</td>- <td><p>The list of sequences in a schema. </p></td>- </tr>-- <tr>- <td>packages</td>- <td><a href="#bytebase.store.PackageMetadata">PackageMetadata</a></td>- <td>repeated</td>- <td><p>The list of packages in a schema. </p></td>- </tr>-- <tr>- <td>owner</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>events</td>- <td><a href="#bytebase.store.EventMetadata">EventMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>enum_types</td>- <td><a href="#bytebase.store.EnumTypeMetadata">EnumTypeMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>composite_types</td>- <td><a href="#bytebase.store.CompositeTypeMetadata">CompositeTypeMetadata</a></td>- <td>repeated</td>- <td><p>The list of user-defined composite types in a schema (PostgreSQL family,-CREATE TYPE ... AS). Excludes table/view row types and derived types. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.SequenceMetadata">SequenceMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of a sequence. </p></td>- </tr>-- <tr>- <td>data_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The data type of a sequence. </p></td>- </tr>-- <tr>- <td>start</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The start value of a sequence. </p></td>- </tr>-- <tr>- <td>min_value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The minimum value of a sequence. </p></td>- </tr>-- <tr>- <td>max_value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The maximum value of a sequence. </p></td>- </tr>-- <tr>- <td>increment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The increment value of a sequence. </p></td>- </tr>-- <tr>- <td>cycle</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Whether the sequence cycles. </p></td>- </tr>-- <tr>- <td>cache_size</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Cache size of a sequence. </p></td>- </tr>-- <tr>- <td>last_value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The last value of a sequence. </p></td>- </tr>-- <tr>- <td>owner_table</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The table that owns the sequence. </p></td>- </tr>-- <tr>- <td>owner_column</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The column that owns the sequence. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.SpatialIndexConfig">SpatialIndexConfig</h3>- <p>SpatialIndexConfig is the configuration for spatial indexes across different database engines.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>method</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Index method/type (database-specific)-Examples: "SPATIAL" (MySQL/SQL Server), "GIST"/"SPGIST" (PostgreSQL), "MDSYS.SPATIAL_INDEX_V2" (Oracle) </p></td>- </tr>-- <tr>- <td>tessellation</td>- <td><a href="#bytebase.store.TessellationConfig">TessellationConfig</a></td>- <td></td>- <td><p>Tessellation configuration (primarily SQL Server) </p></td>- </tr>-- <tr>- <td>storage</td>- <td><a href="#bytebase.store.StorageConfig">StorageConfig</a></td>- <td></td>- <td><p>Storage and performance parameters </p></td>- </tr>-- <tr>- <td>dimensional</td>- <td><a href="#bytebase.store.DimensionalConfig">DimensionalConfig</a></td>- <td></td>- <td><p>Dimensional and constraint parameters </p></td>- </tr>-- <tr>- <td>engine_specific</td>- <td><a href="#bytebase.store.SpatialIndexConfig.EngineSpecificEntry">SpatialIndexConfig.EngineSpecificEntry</a></td>- <td>repeated</td>- <td><p>Database-specific parameters (stored as key-value pairs for extensibility) </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.SpatialIndexConfig.EngineSpecificEntry">SpatialIndexConfig.EngineSpecificEntry</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>key</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.StorageConfig">StorageConfig</h3>- <p>StorageConfig defines storage and performance parameters for spatial indexes.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>fillfactor</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p>PostgreSQL parameters--10-100 </p></td>- </tr>-- <tr>- <td>buffering</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>auto, on, off </p></td>- </tr>-- <tr>- <td>tablespace</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Oracle parameters </p></td>- </tr>-- <tr>- <td>work_tablespace</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>sdo_level</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>commit_interval</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>pad_index</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>SQL Server parameters </p></td>- </tr>-- <tr>- <td>sort_in_tempdb</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>ON, OFF </p></td>- </tr>-- <tr>- <td>drop_existing</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>online</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>allow_row_locks</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>allow_page_locks</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>maxdop</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>data_compression</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>NONE, ROW, PAGE </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.StreamMetadata">StreamMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the stream. </p></td>- </tr>-- <tr>- <td>table_name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The table_name is the name of the table/view that the stream is created on. </p></td>- </tr>-- <tr>- <td>owner</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The owner of the stream. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment of the stream. </p></td>- </tr>-- <tr>- <td>type</td>- <td><a href="#bytebase.store.StreamMetadata.Type">StreamMetadata.Type</a></td>- <td></td>- <td><p>The type of the stream. </p></td>- </tr>-- <tr>- <td>stale</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Indicates whether the stream was last read before the `stale_after` time. </p></td>- </tr>-- <tr>- <td>mode</td>- <td><a href="#bytebase.store.StreamMetadata.Mode">StreamMetadata.Mode</a></td>- <td></td>- <td><p>The mode of the stream. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition of the stream. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TableCatalog">TableCatalog</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the table. </p></td>- </tr>-- <tr>- <td>columns</td>- <td><a href="#bytebase.store.ColumnCatalog">ColumnCatalog</a></td>- <td>repeated</td>- <td><p>The column_configs is the ordered list of configs for columns in a table. </p></td>- </tr>-- <tr>- <td>object_schema</td>- <td><a href="#bytebase.store.ObjectSchema">ObjectSchema</a></td>- <td>optional</td>- <td><p> </p></td>- </tr>-- <tr>- <td>classification</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TableMetadata">TableMetadata</h3>- <p>TableMetadata is the metadata for tables.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the table. </p></td>- </tr>-- <tr>- <td>columns</td>- <td><a href="#bytebase.store.ColumnMetadata">ColumnMetadata</a></td>- <td>repeated</td>- <td><p>The columns is the ordered list of columns in a table. </p></td>- </tr>-- <tr>- <td>indexes</td>- <td><a href="#bytebase.store.IndexMetadata">IndexMetadata</a></td>- <td>repeated</td>- <td><p>The indexes is the list of indexes in a table. </p></td>- </tr>-- <tr>- <td>engine</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The engine is the engine of a table. </p></td>- </tr>-- <tr>- <td>collation</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The collation is the collation of a table. </p></td>- </tr>-- <tr>- <td>charset</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The character set of the table. </p></td>- </tr>-- <tr>- <td>row_count</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The row_count is the estimated number of rows of a table. </p></td>- </tr>-- <tr>- <td>data_size</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The data_size is the estimated data size of a table. </p></td>- </tr>-- <tr>- <td>index_size</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The index_size is the estimated index size of a table. </p></td>- </tr>-- <tr>- <td>data_free</td>- <td><a href="#int64">int64</a></td>- <td></td>- <td><p>The data_free is the estimated free data size of a table. </p></td>- </tr>-- <tr>- <td>create_options</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The create_options is the create option of a table. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment is the comment of a table. </p></td>- </tr>-- <tr>- <td>foreign_keys</td>- <td><a href="#bytebase.store.ForeignKeyMetadata">ForeignKeyMetadata</a></td>- <td>repeated</td>- <td><p>The foreign_keys is the list of foreign keys in a table. </p></td>- </tr>-- <tr>- <td>partitions</td>- <td><a href="#bytebase.store.TablePartitionMetadata">TablePartitionMetadata</a></td>- <td>repeated</td>- <td><p>The partitions is the list of partitions in a table. </p></td>- </tr>-- <tr>- <td>check_constraints</td>- <td><a href="#bytebase.store.CheckConstraintMetadata">CheckConstraintMetadata</a></td>- <td>repeated</td>- <td><p>The check_constraints is the list of check constraints in a table. </p></td>- </tr>-- <tr>- <td>owner</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>sorting_keys</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The sorting_keys is a tuple of column names or arbitrary expressions. ClickHouse specific field.-Reference: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#order_by </p></td>- </tr>-- <tr>- <td>triggers</td>- <td><a href="#bytebase.store.TriggerMetadata">TriggerMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>rules</td>- <td><a href="#bytebase.store.RuleMetadata">RuleMetadata</a></td>- <td>repeated</td>- <td><p>The rules is the list of rules in a table (PostgreSQL specific). </p></td>- </tr>-- <tr>- <td>sharding_info</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>https://docs.pingcap.com/tidb/stable/information-schema-tables/ </p></td>- </tr>-- <tr>- <td>primary_key_type</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>https://docs.pingcap.com/tidb/stable/clustered-indexes/#clustered-indexes-CLUSTERED or NONCLUSTERED. </p></td>- </tr>-- <tr>- <td>exclude_constraints</td>- <td><a href="#bytebase.store.ExcludeConstraintMetadata">ExcludeConstraintMetadata</a></td>- <td>repeated</td>- <td><p>The exclude_constraints is the list of EXCLUDE constraints in a table (PostgreSQL specific). </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TablePartitionMetadata">TablePartitionMetadata</h3>- <p>TablePartitionMetadata is the metadata for table partitions.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the table partition. </p></td>- </tr>-- <tr>- <td>type</td>- <td><a href="#bytebase.store.TablePartitionMetadata.Type">TablePartitionMetadata.Type</a></td>- <td></td>- <td><p>The type of a table partition. </p></td>- </tr>-- <tr>- <td>expression</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The expression is the expression of a table partition.-For PostgreSQL, the expression is the text of {FOR VALUES-partition_bound_spec}, see-https://www.postgresql.org/docs/current/sql-createtable.html. For MySQL,-the expression is the `expr` or `column_list` of the following syntax.-PARTITION BY- { [LINEAR] HASH(expr)- | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)- | RANGE{(expr) | COLUMNS(column_list)}- | LIST{(expr) | COLUMNS(column_list)} }. </p></td>- </tr>-- <tr>- <td>value</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The value is the value of a table partition.-For MySQL, the value is for RANGE and LIST partition types,-- For a RANGE partition, it contains the value set in the partition's-VALUES LESS THAN clause, which can be either an integer or MAXVALUE.-- For a LIST partition, this column contains the values defined in the-partition's VALUES IN clause, which is a list of comma-separated integer-values.-- For others, it's an empty string. </p></td>- </tr>-- <tr>- <td>use_default</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The use_default is whether the users use the default partition, it stores-the different value for different database engines. For MySQL, it's [INT]-type, 0 means not use default partition, otherwise, it's equals to number-in syntax [SUB]PARTITION {number}. </p></td>- </tr>-- <tr>- <td>subpartitions</td>- <td><a href="#bytebase.store.TablePartitionMetadata">TablePartitionMetadata</a></td>- <td>repeated</td>- <td><p>The subpartitions is the list of subpartitions in a table partition. </p></td>- </tr>-- <tr>- <td>indexes</td>- <td><a href="#bytebase.store.IndexMetadata">IndexMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>check_constraints</td>- <td><a href="#bytebase.store.CheckConstraintMetadata">CheckConstraintMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- <tr>- <td>exclude_constraints</td>- <td><a href="#bytebase.store.ExcludeConstraintMetadata">ExcludeConstraintMetadata</a></td>- <td>repeated</td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TaskMetadata">TaskMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the task. </p></td>- </tr>-- <tr>- <td>id</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The Snowflake-generated ID of the task.-Example: 01ad32a0-1bb6-5e93-0000-000000000001. </p></td>- </tr>-- <tr>- <td>owner</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The owner of the task. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment of the task. </p></td>- </tr>-- <tr>- <td>warehouse</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The warehouse of the task. </p></td>- </tr>-- <tr>- <td>schedule</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The schedule interval of the task. </p></td>- </tr>-- <tr>- <td>predecessors</td>- <td><a href="#string">string</a></td>- <td>repeated</td>- <td><p>The predecessor tasks of the task. </p></td>- </tr>-- <tr>- <td>state</td>- <td><a href="#bytebase.store.TaskMetadata.State">TaskMetadata.State</a></td>- <td></td>- <td><p>The state of the task. </p></td>- </tr>-- <tr>- <td>condition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The condition of the task. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition of the task. </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TessellationConfig">TessellationConfig</h3>- <p>TessellationConfig defines tessellation parameters for spatial indexes.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>scheme</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>Tessellation scheme-Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID </p></td>- </tr>-- <tr>- <td>bounding_box</td>- <td><a href="#bytebase.store.BoundingBox">BoundingBox</a></td>- <td></td>- <td><p>Bounding box for GEOMETRY indexes (SQL Server) </p></td>- </tr>-- <tr>- <td>grid_levels</td>- <td><a href="#bytebase.store.GridLevel">GridLevel</a></td>- <td>repeated</td>- <td><p>Grid level configuration (SQL Server) </p></td>- </tr>-- <tr>- <td>cells_per_object</td>- <td><a href="#int32">int32</a></td>- <td></td>- <td><p>Cells per object (SQL Server) </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.TriggerMetadata">TriggerMetadata</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the trigger. </p></td>- </tr>-- <tr>- <td>event</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The event that triggers this action, such as INSERT, UPDATE, DELETE, or TRUNCATE. </p></td>- </tr>-- <tr>- <td>timing</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The timing of when the trigger fires, such as BEFORE or AFTER. </p></td>- </tr>-- <tr>- <td>body</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The body of the trigger. </p></td>- </tr>-- <tr>- <td>sql_mode</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>character_set_client</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>collation_connection</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.store.ViewMetadata">ViewMetadata</h3>- <p>ViewMetadata is the metadata for views.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the view. </p></td>- </tr>-- <tr>- <td>definition</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The definition is the definition of a view. </p></td>- </tr>-- <tr>- <td>comment</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The comment is the comment of a view. </p></td>- </tr>-- <tr>- <td>dependency_columns</td>- <td><a href="#bytebase.store.DependencyColumn">DependencyColumn</a></td>- <td>repeated</td>- <td><p>The list of dependency columns of a view. </p></td>- </tr>-- <tr>- <td>columns</td>- <td><a href="#bytebase.store.ColumnMetadata">ColumnMetadata</a></td>- <td>repeated</td>- <td><p>The ordered list of columns in the view. </p></td>- </tr>-- <tr>- <td>triggers</td>- <td><a href="#bytebase.store.TriggerMetadata">TriggerMetadata</a></td>- <td>repeated</td>- <td><p>The list of triggers in the view. </p></td>- </tr>-- <tr>- <td>skip_dump</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>rules</td>- <td><a href="#bytebase.store.RuleMetadata">RuleMetadata</a></td>- <td>repeated</td>- <td><p>The rules is the list of rules in a view (PostgreSQL specific). </p></td>- </tr>-- </tbody>- </table>-------- <h3 id="bytebase.store.ColumnMetadata.IdentityGeneration">ColumnMetadata.IdentityGeneration</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>IDENTITY_GENERATION_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>ALWAYS</td>- <td>1</td>- <td><p></p></td>- </tr>-- <tr>- <td>BY_DEFAULT</td>- <td>2</td>- <td><p></p></td>- </tr>-- </tbody>- </table>-- <h3 id="bytebase.store.GenerationMetadata.Type">GenerationMetadata.Type</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>TYPE_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>TYPE_VIRTUAL</td>- <td>1</td>- <td><p></p></td>- </tr>-- <tr>- <td>TYPE_STORED</td>- <td>2</td>- <td><p></p></td>- </tr>-- </tbody>- </table><h3 id="bytebase.store.ObjectSchema.Type">ObjectSchema.Type</h3><p></p>@@ -6485,64 +3641,6 @@ Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID</tbody></table>- <h3 id="bytebase.store.StreamMetadata.Mode">StreamMetadata.Mode</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>MODE_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>MODE_DEFAULT</td>- <td>1</td>- <td><p></p></td>- </tr>-- <tr>- <td>MODE_APPEND_ONLY</td>- <td>2</td>- <td><p></p></td>- </tr>-- <tr>- <td>MODE_INSERT_ONLY</td>- <td>3</td>- <td><p></p></td>- </tr>-- </tbody>- </table>-- <h3 id="bytebase.store.StreamMetadata.Type">StreamMetadata.Type</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>TYPE_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>TYPE_DELTA</td>- <td>1</td>- <td><p></p></td>- </tr>-- </tbody>- </table>-<h3 id="bytebase.store.SyncStatus">SyncStatus</h3><p>SyncStatus is the status of the database sync operation.</p><table class="enum-table">@@ -6572,100 +3670,6 @@ Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID</tbody></table>- <h3 id="bytebase.store.TablePartitionMetadata.Type">TablePartitionMetadata.Type</h3>- <p>The type is the type of a table partition. Some database engines may not</p><p>support all types. Only available for the following database engines now:</p><p>MySQL: RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, LINEAR HASH, KEY,</p><p>LINEAR_KEY</p><p>(https://dev.mysql.com/doc/refman/8.0/en/partitioning-types.html) TiDB:</p><p>RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, KEY PostgreSQL: RANGE,</p><p>LIST, HASH (https://www.postgresql.org/docs/current/ddl-partitioning.html)</p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>TYPE_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>RANGE</td>- <td>1</td>- <td><p></p></td>- </tr>-- <tr>- <td>RANGE_COLUMNS</td>- <td>2</td>- <td><p></p></td>- </tr>-- <tr>- <td>LIST</td>- <td>3</td>- <td><p></p></td>- </tr>-- <tr>- <td>LIST_COLUMNS</td>- <td>4</td>- <td><p></p></td>- </tr>-- <tr>- <td>HASH</td>- <td>5</td>- <td><p></p></td>- </tr>-- <tr>- <td>LINEAR_HASH</td>- <td>6</td>- <td><p></p></td>- </tr>-- <tr>- <td>KEY</td>- <td>7</td>- <td><p></p></td>- </tr>-- <tr>- <td>LINEAR_KEY</td>- <td>8</td>- <td><p></p></td>- </tr>-- </tbody>- </table>-- <h3 id="bytebase.store.TaskMetadata.State">TaskMetadata.State</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>STATE_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>STATE_STARTED</td>- <td>1</td>- <td><p></p></td>- </tr>-- <tr>- <td>STATE_SUSPENDED</td>- <td>2</td>- <td><p></p></td>- </tr>-- </tbody>- </table>-diff --git a/proto/store/store/database.proto b/proto/store/store/database.protoindex 7c51bed32a..8ee111d8cb 100644--- a/proto/store/store/database.proto+++ b/proto/store/store/database.proto@@ -32,961 +32,6 @@ message DatabaseMetadata {string sync_error = 10;}-// DatabaseSchemaMetadata is the schema metadata for databases.-message DatabaseSchemaMetadata {- string name = 1;-- // The list of schemas in a database.- repeated SchemaMetadata schemas = 2;-- // The character set of the database.- string character_set = 3;-- // The collation of the database.- string collation = 4;-- // The list of extensions in a database.- repeated ExtensionMetadata extensions = 5;-- // The database belongs to a datashare.- bool datashare = 6;-- // The service name of the database. It's an Oracle-specific concept.- string service_name = 7;-- repeated LinkedDatabaseMetadata linked_databases = 8;-- string owner = 9;-- // The search_path is the search path of a PostgreSQL database.- string search_path = 10;-- // The list of event triggers in a database (PostgreSQL specific).- // Event triggers are database-level objects, not schema-scoped.- repeated EventTriggerMetadata event_triggers = 11;-}--message LinkedDatabaseMetadata {- string name = 1;-- string username = 2;-- string host = 3;-}--// SchemaMetadata is the metadata for schemas.-// This is the concept of schema in Postgres, but it's a no-op for MySQL.-message SchemaMetadata {- // The schema name.- // It is an empty string for databases without such concept such as MySQL.- string name = 1;-- // The list of tables in a schema.- repeated TableMetadata tables = 2;-- // The list of external tables in a schema.- repeated ExternalTableMetadata external_tables = 3;-- // The list of views in a schema.- repeated ViewMetadata views = 4;-- // The list of functions in a schema.- repeated FunctionMetadata functions = 5;-- // The list of procedures in a schema.- repeated ProcedureMetadata procedures = 6;-- // The list of streams in a schema, currently only used for Snowflake.- repeated StreamMetadata streams = 7;-- // The list of tasks in a schema, currently only used for Snowflake.- repeated TaskMetadata tasks = 8;-- // The list of materialized views in a schema.- repeated MaterializedViewMetadata materialized_views = 9;-- // The list of sequences in a schema.- repeated SequenceMetadata sequences = 10;-- // The list of packages in a schema.- repeated PackageMetadata packages = 11;-- string owner = 12;-- string comment = 13;-- repeated EventMetadata events = 14;-- repeated EnumTypeMetadata enum_types = 15;-- bool skip_dump = 16;-- // The list of user-defined composite types in a schema (PostgreSQL family,- // CREATE TYPE ... AS). Excludes table/view row types and derived types.- repeated CompositeTypeMetadata composite_types = 17;-}--message EnumTypeMetadata {- // The name of the enum type.- string name = 1;-- // The enum values of the type.- repeated string values = 2;-- string comment = 3;-- bool skip_dump = 4;-}--message CompositeTypeMetadata {- // The name of the composite type.- string name = 1;-- // The ordered attributes of the composite type.- repeated CompositeTypeAttribute attributes = 2;-- string comment = 3;-- bool skip_dump = 4;-}--message CompositeTypeAttribute {- // The name of the attribute.- string name = 1;-- // The attribute type. User-defined types are always schema-qualified.- string type = 2;-- // The non-default collation of the attribute as an emit-ready SQL- // identifier reference (quoted as needed, schema-qualified when outside- // pg_catalog), empty otherwise. e.g. `"C"` or `locale.en_us`.- string collation = 3;-- string comment = 4;-}--message EventMetadata {- // The name of the event.- string name = 1;-- // The schedule of the event.- string definition = 2;-- // The time zone of the event.- string time_zone = 3;-- string sql_mode = 4;-- string character_set_client = 5;-- string collation_connection = 6;-- string comment = 7;-}--message SequenceMetadata {- // The name of a sequence.- string name = 1;-- // The data type of a sequence.- string data_type = 2;-- // The start value of a sequence.- string start = 3;-- // The minimum value of a sequence.- string min_value = 4;-- // The maximum value of a sequence.- string max_value = 5;-- // The increment value of a sequence.- string increment = 6;-- // Whether the sequence cycles.- bool cycle = 7;-- // Cache size of a sequence.- string cache_size = 8;-- // The last value of a sequence.- string last_value = 9;-- // The table that owns the sequence.- string owner_table = 10;-- // The column that owns the sequence.- string owner_column = 11;-- string comment = 12;-- bool skip_dump = 13;-}--message TriggerMetadata {- reserved 2;- // The name of the trigger.- string name = 1;-- // The event that triggers this action, such as INSERT, UPDATE, DELETE, or TRUNCATE.- string event = 3;-- // The timing of when the trigger fires, such as BEFORE or AFTER.- string timing = 4;-- // The body of the trigger.- string body = 5;-- string sql_mode = 6;-- string character_set_client = 7;-- string collation_connection = 8;-- string comment = 9;-- bool skip_dump = 10;-}--// RuleMetadata is the metadata for PostgreSQL rules.-message RuleMetadata {- // The name of the rule.- string name = 1;-- // The event type of the rule: SELECT, INSERT, UPDATE, or DELETE.- string event = 2;-- // The WHERE condition of the rule (optional).- string condition = 3;-- // The command(s) to execute when the rule fires.- string action = 4;-- // The is_instead indicates whether this is an INSTEAD rule.- bool is_instead = 5;-- // The is_enabled indicates whether the rule is enabled.- bool is_enabled = 6;-- // The full CREATE RULE statement.- string definition = 7;-}--message TaskMetadata {- // The name of the task.- string name = 1;-- // The Snowflake-generated ID of the task.- // Example: 01ad32a0-1bb6-5e93-0000-000000000001.- string id = 2;-- // The owner of the task.- string owner = 3;-- // The comment of the task.- string comment = 4;-- // The warehouse of the task.- string warehouse = 5;-- // The schedule interval of the task.- string schedule = 6;-- // The predecessor tasks of the task.- repeated string predecessors = 7;-- enum State {- STATE_UNSPECIFIED = 0;- STATE_STARTED = 1;- STATE_SUSPENDED = 2;- }- // The state of the task.- State state = 8;-- // The condition of the task.- string condition = 9;-- // The definition of the task.- string definition = 10;-}--message StreamMetadata {- // The name of the stream.- string name = 1;-- // The table_name is the name of the table/view that the stream is created on.- string table_name = 2;-- // The owner of the stream.- string owner = 3;-- // The comment of the stream.- string comment = 4;-- enum Type {- TYPE_UNSPECIFIED = 0;- TYPE_DELTA = 1;- }- // The type of the stream.- Type type = 5;-- // Indicates whether the stream was last read before the `stale_after` time.- bool stale = 6;-- enum Mode {- MODE_UNSPECIFIED = 0;- MODE_DEFAULT = 1;- MODE_APPEND_ONLY = 2;- MODE_INSERT_ONLY = 3;- }- // The mode of the stream.- Mode mode = 7;-- // The definition of the stream.- string definition = 8;-}--// TableMetadata is the metadata for tables.-message TableMetadata {- reserved 13 to 14;- // The name of the table.- string name = 1;-- // The columns is the ordered list of columns in a table.- repeated ColumnMetadata columns = 2;-- // The indexes is the list of indexes in a table.- repeated IndexMetadata indexes = 3;-- // TODO(d): figure out whether we need to store table type such as "BASE- // TABLE".-- // The engine is the engine of a table.- string engine = 4;-- // The collation is the collation of a table.- string collation = 5;-- // The character set of the table.- string charset = 17;-- // The row_count is the estimated number of rows of a table.- int64 row_count = 6;-- // The data_size is the estimated data size of a table.- int64 data_size = 7;-- // The index_size is the estimated index size of a table.- int64 index_size = 8;-- // The data_free is the estimated free data size of a table.- int64 data_free = 9;-- // The create_options is the create option of a table.- string create_options = 10;-- // The comment is the comment of a table.- string comment = 11;-- // The foreign_keys is the list of foreign keys in a table.- repeated ForeignKeyMetadata foreign_keys = 12;-- // The partitions is the list of partitions in a table.- repeated TablePartitionMetadata partitions = 15;-- // The check_constraints is the list of check constraints in a table.- repeated CheckConstraintMetadata check_constraints = 16;-- string owner = 18;-- // The sorting_keys is a tuple of column names or arbitrary expressions. ClickHouse specific field.- // Reference: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#order_by- repeated string sorting_keys = 19;-- repeated TriggerMetadata triggers = 20;-- bool skip_dump = 21;-- // The rules is the list of rules in a table (PostgreSQL specific).- repeated RuleMetadata rules = 24;-- // https://docs.pingcap.com/tidb/stable/information-schema-tables/- string sharding_info = 22;-- // https://docs.pingcap.com/tidb/stable/clustered-indexes/#clustered-indexes- // CLUSTERED or NONCLUSTERED.- string primary_key_type = 23;-- // The exclude_constraints is the list of EXCLUDE constraints in a table (PostgreSQL specific).- repeated ExcludeConstraintMetadata exclude_constraints = 25;-}--message CheckConstraintMetadata {- // The name of the check constraint.- string name = 1;-- // The expression is the expression of a check constraint.- string expression = 2;-}--message ExcludeConstraintMetadata {- // The name of the EXCLUDE constraint.- string name = 1;-- // The expression is the full EXCLUDE constraint definition including "EXCLUDE" keyword.- // Example: "EXCLUDE USING gist (room_id WITH =, during WITH &&)"- string expression = 2;-}--message ExternalTableMetadata {- // The name of the external table.- string name = 1;-- // The external_server_name is the name of the external server.- string external_server_name = 2;-- // The external_database_name is the name of the external database.- string external_database_name = 3;-- // The columns is the ordered list of columns in a foreign table.- repeated ColumnMetadata columns = 4;-}--// TablePartitionMetadata is the metadata for table partitions.-message TablePartitionMetadata {- // The name of the table partition.- string name = 1;-- // The type is the type of a table partition. Some database engines may not- // support all types. Only available for the following database engines now:- // MySQL: RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, LINEAR HASH, KEY,- // LINEAR_KEY- // (https://dev.mysql.com/doc/refman/8.0/en/partitioning-types.html) TiDB:- // RANGE, RANGE COLUMNS, LIST, LIST COLUMNS, HASH, KEY PostgreSQL: RANGE,- // LIST, HASH (https://www.postgresql.org/docs/current/ddl-partitioning.html)- enum Type {- TYPE_UNSPECIFIED = 0;- RANGE = 1;- RANGE_COLUMNS = 2;- LIST = 3;- LIST_COLUMNS = 4;- HASH = 5;- LINEAR_HASH = 6;- KEY = 7;- LINEAR_KEY = 8;- }-- // The type of a table partition.- Type type = 2;-- // The expression is the expression of a table partition.- // For PostgreSQL, the expression is the text of {FOR VALUES- // partition_bound_spec}, see- // https://www.postgresql.org/docs/current/sql-createtable.html. For MySQL,- // the expression is the `expr` or `column_list` of the following syntax.- // PARTITION BY- // { [LINEAR] HASH(expr)- // | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)- // | RANGE{(expr) | COLUMNS(column_list)}- // | LIST{(expr) | COLUMNS(column_list)} }.- string expression = 3;-- // The value is the value of a table partition.- // For MySQL, the value is for RANGE and LIST partition types,- // - For a RANGE partition, it contains the value set in the partition's- // VALUES LESS THAN clause, which can be either an integer or MAXVALUE.- // - For a LIST partition, this column contains the values defined in the- // partition's VALUES IN clause, which is a list of comma-separated integer- // values.- // - For others, it's an empty string.- string value = 4;-- // The use_default is whether the users use the default partition, it stores- // the different value for different database engines. For MySQL, it's [INT]- // type, 0 means not use default partition, otherwise, it's equals to number- // in syntax [SUB]PARTITION {number}.- string use_default = 5;-- // The subpartitions is the list of subpartitions in a table partition.- repeated TablePartitionMetadata subpartitions = 6;-- repeated IndexMetadata indexes = 7;-- repeated CheckConstraintMetadata check_constraints = 8;-- repeated ExcludeConstraintMetadata exclude_constraints = 9;-}--// ColumnMetadata is the metadata for columns.-message ColumnMetadata {- reserved 4 to 5, 11 to 12;- // The name of the column.- string name = 1;-- // The position is the position in columns.- int32 position = 2;-- // The default value of the column.- string default = 3;-- // Oracle specific metadata.- // The default_on_null is the default on null of a column.- bool default_on_null = 16;-- // The on_update is the on update action of a column.- // For MySQL like databases, it's only supported for TIMESTAMP columns with- // CURRENT_TIMESTAMP as on update value.- string on_update = 13;-- // The nullable is the nullable of a column.- bool nullable = 6;-- // The type is the type of a column.- string type = 7;-- // The character_set is the character_set of a column.- string character_set = 8;-- // The collation is the collation of a column.- string collation = 9;-- // The comment is the comment of a column.- string comment = 10;-- // The generation is for generated columns.- GenerationMetadata generation = 14;-- bool is_identity = 17;-- enum IdentityGeneration {- IDENTITY_GENERATION_UNSPECIFIED = 0;- ALWAYS = 1;- BY_DEFAULT = 2;- }-- // The identity_generation is for identity columns, PG only.- IdentityGeneration identity_generation = 15;-- // The identity_seed is for identity columns, MSSQL only.- int64 identity_seed = 18;-- // The identity_increment is for identity columns, MSSQL only.- int64 identity_increment = 19;-- // The default_constraint_name is the name of the default constraint, MSSQL only.- // In MSSQL, default values are implemented as named constraints. When modifying or- // dropping a column's default value, you must reference the constraint by name.- // This field stores the actual constraint name from the database.- //- // Example: A column definition like:- // CREATE TABLE employees (- // status NVARCHAR(20) DEFAULT 'active'- // )- //- // Will create a constraint with an auto-generated name like 'DF__employees__statu__3B75D760'- // or a user-defined name if specified:- // ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'active' FOR status- //- // To modify the default, you must first drop the existing constraint by name:- // ALTER TABLE employees DROP CONSTRAINT DF__employees__statu__3B75D760- // ALTER TABLE employees ADD CONSTRAINT DF_employees_status DEFAULT 'inactive' FOR status- //- // This field is populated when syncing from the database. When empty (e.g., when parsing- // from SQL files), the system cannot automatically drop the constraint.- string default_constraint_name = 20;-- // The spatial reference system identifier of a spatial column, MySQL 8.0 only.- // Unset means the column declares no SRID; presence carries the explicit SRID,- // including the valid SRID 0. SRS_IDs are unsigned 32-bit (custom SRSs may exceed- // int32). Captured from information_schema.COLUMNS.SRS_ID and rendered as the- // `/*!80003 SRID n */` column attribute.- optional uint32 srid = 21;-- // Whether the column is invisible (hidden from SELECT *), MySQL 8.0.23+ only.- // Captured from information_schema.COLUMNS.EXTRA containing INVISIBLE and- // rendered as the `/*!80023 INVISIBLE */` column attribute.- bool is_invisible = 22;-}--message GenerationMetadata {- enum Type {- TYPE_UNSPECIFIED = 0;- TYPE_VIRTUAL = 1;- TYPE_STORED = 2;- }-- Type type = 1;- string expression = 2;-}--// ViewMetadata is the metadata for views.-message ViewMetadata {- // The name of the view.- string name = 1;-- // The definition is the definition of a view.- string definition = 2;-- // The comment is the comment of a view.- string comment = 3;-- // The list of dependency columns of a view.- repeated DependencyColumn dependency_columns = 4;-- // The ordered list of columns in the view.- repeated ColumnMetadata columns = 5;-- // The list of triggers in the view.- repeated TriggerMetadata triggers = 6;-- bool skip_dump = 7;-- // The rules is the list of rules in a view (PostgreSQL specific).- repeated RuleMetadata rules = 8;-}--// DependencyColumn is the metadata for dependency columns.-message DependencyColumn {- // The schema is the schema of a reference column.- string schema = 1;-- // The table is the table of a reference column.- string table = 2;-- // The column is the name of a reference column.- string column = 3;-}--// MaterializedViewMetadata is the metadata for materialized views.-message MaterializedViewMetadata {- // The name of the materialized view.- string name = 1;-- // The definition is the definition of a view.- string definition = 2;-- // The comment is the comment of a view.- string comment = 3;-- // The list of dependency columns of the view.- repeated DependencyColumn dependency_columns = 4;-- // The ordered list of columns in the materialized view.- repeated TriggerMetadata triggers = 5;-- // The list of indexes in the materialized view.- repeated IndexMetadata indexes = 6;-- bool skip_dump = 7;-}--message DependencyTable {- // The schema is the schema of a reference table.- string schema = 1;-- // The table is the name of a reference table.- string table = 2;-}--// FunctionMetadata is the metadata for functions.-message FunctionMetadata {- // The name of the function.- string name = 1;-- // The definition is the definition of a function.- string definition = 2;-- // The signature is the name with the number and type of input arguments the- // function takes.- string signature = 3;-- // MySQL specific metadata.- string character_set_client = 4;-- string collation_connection = 5;-- string database_collation = 6;-- string sql_mode = 7;-- string comment = 8;-- // The dependency_tables is the list of dependency tables of a function.- // For PostgreSQL, it's the list of tables that the function depends on the return type definition.- repeated DependencyTable dependency_tables = 9;-- bool skip_dump = 10;-}--// ProcedureMetadata is the metadata for procedures.-message ProcedureMetadata {- // The name of the procedure.- string name = 1;-- // The definition is the definition of a procedure.- string definition = 2;-- // The signature is the name with the number and type of input arguments the- // function takes.- string signature = 3;-- // MySQL specific metadata.- string character_set_client = 4;-- string collation_connection = 5;-- string database_collation = 6;-- string sql_mode = 7;-- string comment = 9;-- bool skip_dump = 8;-}--// PackageMetadata is the metadata for packages.-message PackageMetadata {- // The name of the package.- string name = 1;-- // The definition is the definition of a package.- string definition = 2;-}--// IndexMetadata is the metadata for indexes.-message IndexMetadata {- // The name of the index.- string name = 1;-- // The expressions are the ordered columns or expressions of an index.- //- // For PostgreSQL, the canonical shape for each entry matches- // pg_get_indexdef(oid, col, true) — the tightest `index_elem` grammar form:- // - column key: bare identifier e.g. "id", `"Name"`- // - function-call key: bare func_expr_windowless e.g. "lower(name)"- // - expression key: parenthesized a_expr e.g. "(payload ->> 'k'::text)"- // The DDL emitter writes entries verbatim into the CREATE INDEX key list.- repeated string expressions = 2;-- // The ordered list of key lengths for the index.- // If the key length is not specified, it is -1.- repeated int64 key_length = 9;-- // The ordered list of descending flags for the index columns.- repeated bool descending = 10;-- // The type is the type of an index.- string type = 3;-- // The unique is whether the index is unique.- bool unique = 4;-- // The primary is whether the index is a primary key index.- bool primary = 5;-- // The visible is whether the index is visible.- bool visible = 6;-- // The comment is the comment of an index.- string comment = 7;-- // The definition of an index.- string definition = 8;-- // The schema name of the parent index.- string parent_index_schema = 11;-- // The index name of the parent index.- string parent_index_name = 12;-- // The number of granules in the block. It's a ClickHouse specific field.- int64 granularity = 13;-- // It's a PostgreSQL specific field.- // The unique constraint and unique index are not the same thing in PostgreSQL.- bool is_constraint = 14;-- // Spatial index specific configuration- SpatialIndexConfig spatial_config = 15;-- // https://www.postgresql.org/docs/current/catalog-pg-opclass.html- // Name of the operator class for each column. (PostgreSQL specific).- repeated string opclass_names = 16;- // True if the operator class is the default. (PostgreSQL specific).- repeated bool opclass_defaults = 17;-}--// SpatialIndexConfig is the configuration for spatial indexes across different database engines.-message SpatialIndexConfig {- // Index method/type (database-specific)- // Examples: "SPATIAL" (MySQL/SQL Server), "GIST"/"SPGIST" (PostgreSQL), "MDSYS.SPATIAL_INDEX_V2" (Oracle)- string method = 1;-- // Tessellation configuration (primarily SQL Server)- TessellationConfig tessellation = 2;-- // Storage and performance parameters- StorageConfig storage = 3;-- // Dimensional and constraint parameters- DimensionalConfig dimensional = 4;-- // Database-specific parameters (stored as key-value pairs for extensibility)- map<string, string> engine_specific = 5;-}--// TessellationConfig defines tessellation parameters for spatial indexes.-message TessellationConfig {- // Tessellation scheme- // Examples: GEOMETRY_GRID, GEOGRAPHY_GRID, GEOMETRY_AUTO_GRID, GEOGRAPHY_AUTO_GRID- string scheme = 1;-- // Bounding box for GEOMETRY indexes (SQL Server)- BoundingBox bounding_box = 2;-- // Grid level configuration (SQL Server)- repeated GridLevel grid_levels = 3;-- // Cells per object (SQL Server)- int32 cells_per_object = 4;-}--// BoundingBox defines the bounding box for spatial indexes.-message BoundingBox {- double xmin = 1;- double ymin = 2;- double xmax = 3;- double ymax = 4;-}--// GridLevel defines a grid level for spatial tessellation.-message GridLevel {- int32 level = 1; // 1-4 for SQL Server- string density = 2; // LOW, MEDIUM, HIGH-}--// StorageConfig defines storage and performance parameters for spatial indexes.-message StorageConfig {- // PostgreSQL parameters- int32 fillfactor = 1; // 10-100- string buffering = 2; // auto, on, off-- // Oracle parameters- string tablespace = 3;- string work_tablespace = 4;- int32 sdo_level = 5;- int32 commit_interval = 6;-- // SQL Server parameters- bool pad_index = 7;- string sort_in_tempdb = 8; // ON, OFF- bool drop_existing = 9;- bool online = 10;- bool allow_row_locks = 11;- bool allow_page_locks = 12;- int32 maxdop = 13;- string data_compression = 14; // NONE, ROW, PAGE-}--// DimensionalConfig defines dimensional and constraint parameters for spatial indexes.-message DimensionalConfig {- // Number of dimensions (2-4, default 2)- int32 dimensions = 1;-- // Spatial data type- // Examples: GEOMETRY, GEOGRAPHY, POINT, POLYGON, etc.- string data_type = 2;-- // PostgreSQL operator class- // Examples: gist_geometry_ops_2d, gist_geometry_ops_nd, etc.- string operator_class = 3;-- // Oracle geometry type constraint- // Examples: POINT, LINE, POLYGON, COLLECTION- string layer_gtype = 4;-- // Parallel index creation- bool parallel_build = 5;-}--// ExtensionMetadata is the metadata for extensions.-message ExtensionMetadata {- // The name of the extension.- string name = 1;-- // The schema where the extension is installed. However, the extension usage- // is not limited to the schema.- string schema = 2;-- // The version is the version of an extension.- string version = 3;-- // The description is the description of an extension.- string description = 4;-}--// EventTriggerMetadata is the metadata for PostgreSQL event triggers.-// Event triggers are database-level objects that fire on DDL events.-message EventTriggerMetadata {- // The name of the event trigger.- string name = 1;-- // The event type: DDL_COMMAND_START, DDL_COMMAND_END, SQL_DROP, TABLE_REWRITE.- string event = 2;-- // The tags filter (e.g., ['CREATE TABLE', 'DROP TABLE']).- repeated string tags = 3;-- // The schema of the function to execute.- string function_schema = 4;-- // The name of the function to execute.- string function_name = 5;-- // Whether the trigger is enabled.- bool enabled = 6;-- // The full CREATE EVENT TRIGGER definition from pg_get_event_trigger_def().- // SDL output should prefer using this field.- string definition = 7;-- // The comment on the event trigger.- string comment = 8;-- // Skip dump flag (for extension-owned triggers).- bool skip_dump = 9;-}--// ForeignKeyMetadata is the metadata for foreign keys.-message ForeignKeyMetadata {- // The name of the foreign key.- string name = 1;-- // The columns are the ordered referencing columns of a foreign key.- repeated string columns = 2;-- // The referenced_schema is the referenced schema name of a foreign key.- // It is an empty string for databases without such concept such as MySQL.- string referenced_schema = 3;-- // The referenced_table is the referenced table name of a foreign key.- string referenced_table = 4;-- // The referenced_columns are the ordered referenced columns of a foreign key.- repeated string referenced_columns = 5;-- // The on_delete is the on delete action of a foreign key.- string on_delete = 6;-- // The on_update is the on update action of a foreign key.- string on_update = 7;-- // The match_type is the match type of a foreign key.- // The match_type is the PostgreSQL specific field.- // It's empty string for other databases.- string match_type = 8;-}-// InstanceRoleMetadata is the message for instance role.message InstanceRoleMetadata {reserved 1, 3 to 6;