@@ -194,6 +194,7 @@ def project_config_update(self):
194194 def models (self ):
195195 return {
196196 "fk_referenced_to_table.sql" : fixtures .fk_referenced_to_table ,
197+ "fk_referenced_to_table_2.sql" : fixtures .fk_referenced_to_table_2 ,
197198 "fk_referenced_from_table.sql" : fixtures .fk_referenced_from_table ,
198199 "schema.yml" : fixtures .constraint_schema_without_fk_constraint ,
199200 }
@@ -205,12 +206,14 @@ def test_add_foreign_key_constraint(self, project):
205206
206207 # Foreign key constraint is informational only, so we cannot verify enforcement.
207208 # Instead, check that the metadata is updated correctly.
208- util .write_file (fixtures .constraint_schema_with_fk_constraint , "models" , "schema.yml" )
209+ util .write_file (fixtures .constraint_schema_with_fk_constraints , "models" , "schema.yml" )
209210 util .run_dbt (["run" ])
210211 referential_constraints = project .run_sql (referential_constraint_sql , fetch = "all" )
211- assert len (referential_constraints ) == 1
212+ assert len (referential_constraints ) == 2
212213 assert referential_constraints [0 ][0 ] == "fk_to_parent"
213214 assert referential_constraints [0 ][1 ] == "pk_parent"
215+ assert referential_constraints [1 ][0 ] == "fk_to_parent_2"
216+ assert referential_constraints [1 ][1 ] == "pk_parent_2"
214217
215218
216219@pytest .mark .skip_profile ("databricks_cluster" )
@@ -225,8 +228,9 @@ def project_config_update(self):
225228 def models (self ):
226229 return {
227230 "fk_referenced_to_table.sql" : fixtures .fk_referenced_to_table ,
231+ "fk_referenced_to_table_2.sql" : fixtures .fk_referenced_to_table_2 ,
228232 "fk_referenced_from_table.sql" : fixtures .fk_referenced_from_table ,
229- "schema.yml" : fixtures .constraint_schema_with_fk_constraint ,
233+ "schema.yml" : fixtures .constraint_schema_with_fk_constraints ,
230234 }
231235
232236 def test_remove_foreign_key_constraint (self , project ):
@@ -235,9 +239,11 @@ def test_remove_foreign_key_constraint(self, project):
235239
236240 # Verify the constraint exists
237241 referential_constraints = project .run_sql (referential_constraint_sql , fetch = "all" )
238- assert len (referential_constraints ) == 1
242+ assert len (referential_constraints ) == 2
239243 assert referential_constraints [0 ][0 ] == "fk_to_parent"
240244 assert referential_constraints [0 ][1 ] == "pk_parent"
245+ assert referential_constraints [1 ][0 ] == "fk_to_parent_2"
246+ assert referential_constraints [1 ][1 ] == "pk_parent_2"
241247
242248 # Remove foreign key constraint and verify
243249 util .write_file (fixtures .constraint_schema_without_fk_constraint , "models" , "schema.yml" )
0 commit comments