Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: separate schema and table name (#3757)
Danny Xubd81cbcc3d98
diff --git a/plugin/db/clickhouse/sync.go b/plugin/db/clickhouse/sync.goindex dfef55bfcd..98e907a889 100644--- a/plugin/db/clickhouse/sync.go+++ b/plugin/db/clickhouse/sync.go@@ -170,6 +170,7 @@ func (driver *Driver) SyncDBSchema(ctx context.Context, databaseName string) (*dvar table db.Tabletable.Type = "BASE TABLE"table.Name = name+ table.ShortName = nametable.Engine = enginetable.Comment = commenttable.RowCount = rowCountdiff --git a/plugin/db/driver.go b/plugin/db/driver.goindex c1d501c7fa..29b4759e74 100644--- a/plugin/db/driver.go+++ b/plugin/db/driver.go@@ -96,7 +96,12 @@ type Column struct {// Table is the database table.type Table struct {+ // Name is a combination of schema and short name for legacy purpose.Name string+ // ShortName is the short table name.+ ShortName string+ // Schema is the schema name for a table. It should be supported only for Postgres and Snowflake.+ Schema string// CreatedTs isn't supported for ClickHouse, SQLite.CreatedTs int64// UpdatedTs isn't supported for SQLite.diff --git a/plugin/db/mysql/sync.go b/plugin/db/mysql/sync.goindex fae18a5efe..f1b0eadd01 100644--- a/plugin/db/mysql/sync.go+++ b/plugin/db/mysql/sync.go@@ -289,6 +289,7 @@ func (driver *Driver) SyncDBSchema(ctx context.Context, databaseName string) (*d); err != nil {return nil, err}+ table.ShortName = table.Nameswitch table.Type {case baseTableType:diff --git a/plugin/db/pg/sync.go b/plugin/db/pg/sync.goindex 5e092c606c..3148635f3e 100644--- a/plugin/db/pg/sync.go+++ b/plugin/db/pg/sync.go@@ -174,6 +174,8 @@ func (driver *Driver) SyncDBSchema(ctx context.Context, databaseName string) (*dfor _, tbl := range tables {var dbTable db.TabledbTable.Name = fmt.Sprintf("%s.%s", tbl.schemaName, tbl.name)+ dbTable.Schema = tbl.schemaName+ dbTable.ShortName = tbl.namedbTable.Type = "BASE TABLE"dbTable.Comment = tbl.commentdbTable.RowCount = tbl.rowCountdiff --git a/plugin/db/snowflake/sync.go b/plugin/db/snowflake/sync.goindex cb8c5425a5..05a5ceb273 100644--- a/plugin/db/snowflake/sync.go+++ b/plugin/db/snowflake/sync.go@@ -260,6 +260,8 @@ func (driver *Driver) syncTableSchema(ctx context.Context, database string) ([]d}table.Name = fmt.Sprintf("%s.%s", schemaName, tableName)+ table.Schema = schemaName+ table.ShortName = tableNametable.ColumnList = columnMap[table.Name]tables = append(tables, table)}diff --git a/plugin/db/sqlite/sync.go b/plugin/db/sqlite/sync.goindex 8d4cc31bba..805995518e 100644--- a/plugin/db/sqlite/sync.go+++ b/plugin/db/sqlite/sync.go@@ -144,6 +144,7 @@ func getTables(txn *sql.Tx, indicesMap map[string][]indexSchema) ([]db.Table, erfor _, name := range tableNames {var tbl db.Tabletbl.Name = name+ tbl.ShortName = nametbl.Type = "BASE TABLE"if err := func() error {diff --git a/server/runner/schemasync/syncer.go b/server/runner/schemasync/syncer.goindex 44928e7a90..7b8471600e 100644--- a/server/runner/schemasync/syncer.go+++ b/server/runner/schemasync/syncer.go@@ -428,7 +428,8 @@ func syncDBSchema(ctx context.Context, store *store.Store, database *api.Databasmetadata := &storepb.SchemaMetadata{}for _, t := range schema.TableList {metadata.TableMetadata = append(metadata.TableMetadata, &storepb.TableMetadata{- Name: t.Name,+ Schema: t.Schema,+ Name: t.ShortName,})}bytes, err := protojson.Marshal(metadata)