diff options
author | David Stosik <david.stosik+git-noreply@gmail.com> | 2018-03-22 10:12:58 +0000 |
---|---|---|
committer | David Stosik <david.stosik+git-noreply@gmail.com> | 2018-03-22 10:12:58 +0000 |
commit | f6e612b2723ca7ae730ba3e98267c19356b386b3 (patch) | |
tree | 4378f40cd943f206f5b21f52a53ed5152f613676 /activerecord/lib | |
parent | 87194b736ef767bf31c997b799d032eb09516aac (diff) | |
download | rails-f6e612b2723ca7ae730ba3e98267c19356b386b3.tar.gz rails-f6e612b2723ca7ae730ba3e98267c19356b386b3.tar.bz2 rails-f6e612b2723ca7ae730ba3e98267c19356b386b3.zip |
Move fk_ignore_pattern from config.active_record to SchemaDumper
This makes more sense, as the foreign key ignore pattern is only used by
the schema dumper.
Diffstat (limited to 'activerecord/lib')
4 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index b91f591e1a..6a498b353c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -102,7 +102,7 @@ module ActiveRecord alias validated? validate? def export_name_on_schema_dump? - name !~ ActiveRecord::Base.fk_ignore_pattern + name !~ ActiveRecord::SchemaDumper.fk_ignore_pattern end def defined_for?(to_table_ord = nil, to_table: nil, **options) diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 4e63d1a273..e1a0b2ecf8 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -125,12 +125,6 @@ module ActiveRecord mattr_accessor :belongs_to_required_by_default, instance_accessor: false - ## - # :singleton-method: - # Specify a custom regular expression matching foreign keys which name - # should not be dumped to db/schema.rb. - mattr_accessor :fk_ignore_pattern, instance_accessor: false - class_attribute :default_connection_handler, instance_writer: false def self.connection_handler diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 7f58780fdf..6ab80a654d 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -27,7 +27,6 @@ module ActiveRecord config.active_record.use_schema_cache_dump = true config.active_record.maintain_test_schema = true - config.active_record.fk_ignore_pattern = ActiveRecord::ForeignKeys::DEFAULT_IGNORE_PATTERN config.active_record.sqlite3 = ActiveSupport::OrderedOptions.new config.active_record.sqlite3.represent_boolean_as_integer = nil diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 72b7460342..8fc2752f0c 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -17,6 +17,12 @@ module ActiveRecord # Only strings are accepted if ActiveRecord::Base.schema_format == :sql. cattr_accessor :ignore_tables, default: [] + ## + # :singleton-method: + # Specify a custom regular expression matching foreign keys which name + # should not be dumped to db/schema.rb. + cattr_accessor :fk_ignore_pattern, default: ActiveRecord::ForeignKeys::DEFAULT_IGNORE_PATTERN + class << self def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base) connection.create_schema_dumper(generate_options(config)).dump(stream) |