@@ -94,20 +94,23 @@ def test_add_foreign_key_with_column
9494 end
9595
9696 def test_add_foreign_key_with_non_standard_primary_key
97- with_example_table @connection , " space_shuttles" , "pk BIGINT PRIMARY KEY" do
98- @connection . add_foreign_key ( :astronauts , :space_shuttles ,
99- column : "rocket_id" , primary_key : "pk" , name : "custom_pk" )
97+ @connection . create_table : space_shuttles, id : false , force : true do | t |
98+ t . bigint :pk , primary_key : true
99+ end
100100
101- foreign_keys = @connection . foreign_keys ( " astronauts" )
102- assert_equal 1 , foreign_keys . size
101+ @connection . add_foreign_key ( : astronauts, :space_shuttles ,
102+ column : "rocket_id" , primary_key : "pk" , name : "custom_pk" )
103103
104- fk = foreign_keys . first
105- assert_equal "astronauts" , fk . from_table
106- assert_equal "space_shuttles" , fk . to_table
107- assert_equal "pk" , fk . primary_key
104+ foreign_keys = @connection . foreign_keys ( "astronauts" )
105+ assert_equal 1 , foreign_keys . size
108106
109- @connection . remove_foreign_key :astronauts , name : "custom_pk"
110- end
107+ fk = foreign_keys . first
108+ assert_equal "astronauts" , fk . from_table
109+ assert_equal "space_shuttles" , fk . to_table
110+ assert_equal "pk" , fk . primary_key
111+ ensure
112+ @connection . remove_foreign_key :astronauts , name : "custom_pk"
113+ @connection . drop_table :space_shuttles
111114 end
112115
113116 def test_add_on_delete_restrict_foreign_key
0 commit comments