Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
pg: add basic index to sync schema.
spinningbotacf63d39961d
diff --git a/plugin/db/pg/pg.go b/plugin/db/pg/pg.goindex 86d0ddb8e5..bf21e68905 100644--- a/plugin/db/pg/pg.go+++ b/plugin/db/pg/pg.go@@ -340,6 +340,17 @@ func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.DBUser, []*db.DBSch}defer txn.Rollback()+ // Index statements.+ indicesMap := make(map[string][]*indexSchema)+ indices, err := getIndices(txn)+ if err != nil {+ return nil, nil, fmt.Errorf("failed to get indices from database %q: %s", dbName, err)+ }+ for _, idx := range indices {+ key := fmt.Sprintf("%s.%s", idx.schemaName, idx.tableName)+ indicesMap[key] = append(indicesMap[key], idx)+ }+// Table statements.tables, err := getPgTables(txn)if err != nil {@@ -354,6 +365,13 @@ func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.DBUser, []*db.DBSchdbColumn.Name = col.columnNamedbTable.ColumnList = append(dbTable.ColumnList, dbColumn)}+ indices := indicesMap[dbTable.Name]+ for _, idx := range indices {+ var dbIndex db.DBIndex+ dbIndex.Name = idx.name+ dbIndex.Expression = idx.Statement()+ dbTable.IndexList = append(dbTable.IndexList, dbIndex)+ }schema.TableList = append(schema.TableList, dbTable)}