diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-05-12 07:47:28 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-01-17 08:19:38 +0900 |
commit | b0923e4ca2dcf9058421e14873304603586396f6 (patch) | |
tree | 6c230f98e48e9f98ec5cbbc00cadc7f10546822e /activerecord/test/schema | |
parent | dc01a40eacfea12140378854b662e79a63dd874a (diff) | |
download | rails-b0923e4ca2dcf9058421e14873304603586396f6.tar.gz rails-b0923e4ca2dcf9058421e14873304603586396f6.tar.bz2 rails-b0923e4ca2dcf9058421e14873304603586396f6.zip |
Should work foreign key in test schema without `if supports_foreign_keys?` statement
If an adapter does not support foreign key feature, should be noop.
https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/foreign_key_test.rb#L288-L294
https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/references_foreign_key_test.rb#L208-L214
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r-- | activerecord/test/schema/schema.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index ba6f5de894..b38b9661b3 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -1005,16 +1005,14 @@ ActiveRecord::Schema.define do create_table :records, force: true do |t| end - if supports_foreign_keys? - # fk_test_has_fk should be before fk_test_has_pk - create_table :fk_test_has_fk, force: true do |t| - t.bigint :fk_id, null: false + disable_referential_integrity do + create_table :fk_test_has_pk, primary_key: "pk_id", force: :cascade do |t| end - create_table :fk_test_has_pk, force: true, primary_key: "pk_id" do |t| + create_table :fk_test_has_fk, force: true do |t| + t.references :fk, null: false + t.foreign_key :fk_test_has_pk, column: "fk_id", name: "fk_name", primary_key: "pk_id" end - - add_foreign_key :fk_test_has_fk, :fk_test_has_pk, column: "fk_id", name: "fk_name", primary_key: "pk_id" end create_table :overloaded_types, force: true do |t| |