Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: equal table tests foreign key (#13633)

h3n4l7536da7f96eb
diff --git a/backend/common/db_schema.go b/backend/common/db_schema.go
index 494c8bd5df..2f91f4a06b 100644
--- a/backend/common/db_schema.go
+++ b/backend/common/db_schema.go
@@ -142,6 +142,9 @@ func EqualTable(s, t *storepb.TableMetadata) bool {
if len(s.Indexes) != len(t.Indexes) {
return false
}
+ if len(s.ForeignKeys) != len(t.ForeignKeys) {
+ return false
+ }
if len(s.Partitions) != len(t.Partitions) {
return false
}
@@ -208,6 +211,33 @@ func EqualTable(s, t *storepb.TableMetadata) bool {
return false
}
}
+ for i := 0; i < len(s.GetForeignKeys()); i++ {
+ si, ti := s.GetForeignKeys()[i], t.GetForeignKeys()[i]
+ if si.GetName() != ti.GetName() {
+ return false
+ }
+ if !slices.Equal(si.GetColumns(), ti.GetColumns()) {
+ return false
+ }
+ if si.GetReferencedSchema() != ti.GetReferencedSchema() {
+ return false
+ }
+ if si.GetReferencedTable() != ti.GetReferencedTable() {
+ return false
+ }
+ if !slices.Equal(si.GetReferencedColumns(), ti.GetReferencedColumns()) {
+ return false
+ }
+ if si.GetOnDelete() != ti.GetOnDelete() {
+ return false
+ }
+ if si.GetOnUpdate() != ti.GetOnUpdate() {
+ return false
+ }
+ if si.GetMatchType() != ti.GetMatchType() {
+ return false
+ }
+ }
for i := 0; i < len(s.GetPartitions()); i++ {
si, ti := s.GetPartitions()[i], t.GetPartitions()[i]