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: index test (#10093)
Danny Xu6b10e81ffbca
diff --git a/backend/plugin/schema-engine/pg/structurer.go b/backend/plugin/schema-engine/pg/structurer.goindex 629eb2100b..35cf4974cd 100644--- a/backend/plugin/schema-engine/pg/structurer.go+++ b/backend/plugin/schema-engine/pg/structurer.go@@ -109,6 +109,7 @@ func ParseToMetadata(schema string) (*storepb.DatabaseSchemaMetadata, error) {referencedTable: constraint.Foreign.Table.Name,referencedColumns: constraint.Foreign.ColumnList,}+ case ast.ConstraintTypeUnique:}}@@ -183,10 +184,12 @@ func ParseToMetadata(schema string) (*storepb.DatabaseSchemaMetadata, error) {continue}table.indexes[stmt.Index.Name] = &indexState{- id: len(table.indexes),- name: stmt.Index.Name,- primary: false,- unique: stmt.Index.Unique,+ id: len(table.indexes),+ name: stmt.Index.Name,+ primary: false,+ unique: stmt.Index.Unique,+ keys: stmt.Index.GetKeyNameList(),+ definition: stmt.Text(),}case *ast.CommentStmt:switch stmt.Type {diff --git a/backend/plugin/schema-engine/pg/testdata/get_design_schema.yaml b/backend/plugin/schema-engine/pg/testdata/get_design_schema.yamlindex 73255c88ae..c2b1d5154b 100644--- a/backend/plugin/schema-engine/pg/testdata/get_design_schema.yaml+++ b/backend/plugin/schema-engine/pg/testdata/get_design_schema.yaml@@ -22,6 +22,7 @@COMMENT ON COLUMN public.t4.c IS 'comment with ''; test escape';ALTER TABLE public.t4 ADD CONSTRAINT pk_t4_a_c_d PRIMARY KEY (a, c, d);ALTER TABLE public.t4 ADD CONSTRAINT fk_t4_a_t2_b FOREIGN KEY (a) REFERENCES public.t2 (b);+ CREATE INDEX idx_t4_d ON public.t4 USING btree (d);target: |-{"schemas": [@@ -173,6 +174,7 @@COMMENT ON COLUMN public.t4.c IS 'comment with ''; test escape';ALTER TABLE public.t4 ADD CONSTRAINT pk_t4_a_c_d PRIMARY KEY ("a", "b", "c");ALTER TABLE public.t4 ADD CONSTRAINT fk_t4_a_t2_b FOREIGN KEY ("b") REFERENCES "public"."t2"("b");+ CREATE INDEX idx_t4_d ON public.t4 USING btree (d);CREATE SCHEMA "s1";CREATE TABLE "s1"."t" (diff --git a/backend/plugin/schema-engine/pg/testdata/parse_to_metadata.yaml b/backend/plugin/schema-engine/pg/testdata/parse_to_metadata.yamlindex 57d101e4d3..394bba5dfd 100644--- a/backend/plugin/schema-engine/pg/testdata/parse_to_metadata.yaml+++ b/backend/plugin/schema-engine/pg/testdata/parse_to_metadata.yaml@@ -9,6 +9,7 @@);create table public.t2(b int NOT NULL default NULL, constraint t2_pk primary key (b));comment on column public.t.a is 'this is a comment';+ CREATE INDEX idx_t_c ON public.t USING btree (c);metadata: |-{"schemas": [@@ -47,6 +48,14 @@"unique": true,"primary": true,"visible": true+ },+ {+ "name": "idx_t_c",+ "expressions": [+ "c"+ ],+ "visible": true,+ "definition": "CREATE INDEX idx_t_c ON public.t USING btree (c);"}],"foreignKeys": [