diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-09-17 11:43:42 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-09-17 11:43:42 +0200 |
commit | 38b5e191f6ceb71fe9981f3e18455ef76ada3331 (patch) | |
tree | 4255d400fa5ff3fa1ddd4cf220da23683761e10d /activerecord | |
parent | 6d8221323f409b990876f98df73d1f744bf8cd71 (diff) | |
download | rails-38b5e191f6ceb71fe9981f3e18455ef76ada3331.tar.gz rails-38b5e191f6ceb71fe9981f3e18455ef76ada3331.tar.bz2 rails-38b5e191f6ceb71fe9981f3e18455ef76ada3331.zip |
do not dump foreign keys for ignored tables.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 5 |
3 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index de510da1e5..545d2b768d 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,5 @@ +* Do not dump foreign keys for ignored tables. *Yves Senn* + * PostgreSQL adapter correctly dumps foreign keys targeting tables outside the schema search path. diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 68d976c240..82c5ca291c 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -100,7 +100,7 @@ HEADER # dump foreign keys at the end to make sure all dependent tables exist. if @connection.supports_foreign_keys? sorted_tables.each do |tbl| - foreign_keys(tbl, stream) + foreign_keys(tbl, stream) unless ignored?(tbl) end end end diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index d7ee56374d..93fb502410 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -371,6 +371,11 @@ class SchemaDumperTest < ActiveRecord::TestCase output = standard_dump assert_match(/^\s+add_foreign_key "fk_test_has_fk"[^\n]+\n\s+add_foreign_key "lessons_students"/, output) end + + def test_do_not_dump_foreign_keys_for_ignored_tables + output = dump_table_schema "authors" + assert_equal ["authors"], output.scan(/^\s*add_foreign_key "([^"]+)".+$/).flatten + end end class CreateDogMigration < ActiveRecord::Migration |