aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record.rb1
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb9
-rw-r--r--activerecord/test/schema_dumper_test.rb6
5 files changed, 12 insertions, 12 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 1aaaa96768..9374c487af 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,6 +1,6 @@
*SVN*
-* Added ActiveRecord::Base.schema_ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [TobiasLuetke]
+* Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [TobiasLuetke]
* SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [TobiasLuetke]
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 40ae8b8fd7..477ab24f1d 100755
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -74,3 +74,4 @@ RAILS_CONNECTION_ADAPTERS.each do |adapter|
end
require 'active_record/query_cache'
+require 'active_record/schema_dumper'
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 3beabda380..a08cd0f2df 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -332,12 +332,6 @@ module ActiveRecord #:nodoc:
cattr_accessor :schema_format
@@schema_format = :sql
- # A list of tables which should not be dumped to the schema.
- # Acceptable values are strings as well as regexp.
- # This setting is only used if schema_format == :ruby
- cattr_accessor :schema_ignore_tables
- @@schema_ignore_tables = []
-
class << self # Class methods
# Find operates with three different retrieval approaches:
#
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 4898bea203..fa45417153 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -4,6 +4,11 @@ module ActiveRecord
class SchemaDumper #:nodoc:
private_class_method :new
+ # A list of tables which should not be dumped to the schema.
+ # Acceptable values are strings as well as regexp.
+ # This setting is only used if ActiveRecord::Base.schema_format == :ruby
+ cattr_accessor :ignore_tables
+ @@ignore_tables = []
def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT)
new(connection).dump(stream)
@@ -44,12 +49,12 @@ HEADER
def tables(stream)
@connection.tables.sort.each do |tbl|
- next if ["schema_info", Base.schema_ignore_tables].flatten.any? do |ignored|
+ next if ["schema_info", ignore_tables].flatten.any? do |ignored|
case ignored
when String: tbl == ignored
when Regexp: tbl =~ ignored
else
- raise StandardError, 'ActiveRecord::Base.schema_ignore_tables accepts an array of String and / or Regexp values.'
+ raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.'
end
end
table(tbl, stream)
diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/schema_dumper_test.rb
index cc6a941554..242c5c5aa8 100644
--- a/activerecord/test/schema_dumper_test.rb
+++ b/activerecord/test/schema_dumper_test.rb
@@ -18,7 +18,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_with_string_ignored_table
stream = StringIO.new
- ActiveRecord::Base.schema_ignore_tables = ['accounts']
+ ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
assert_no_match %r{create_table "accounts"}, output
@@ -30,7 +30,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_with_regexp_ignored_table
stream = StringIO.new
- ActiveRecord::Base.schema_ignore_tables = [/^account/]
+ ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
assert_no_match %r{create_table "accounts"}, output
@@ -41,7 +41,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_illegal_ignored_table_value
stream = StringIO.new
- ActiveRecord::Base.schema_ignore_tables = [5]
+ ActiveRecord::SchemaDumper.ignore_tables = [5]
assert_raise(StandardError) do
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
end