Skip to content

Commit

Permalink
Merge pull request #27884 from kamipo/deprecate_migration_keys
Browse files Browse the repository at this point in the history
Deprecate `ColumnDumper#migration_keys`
  • Loading branch information
jeremy committed Feb 7, 2017
2 parents abfd091 + 2aa9fd0 commit e0e20d6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
* Deprecate `ColumnDumper#migration_keys`.

*Ryuta Kamizono*

* Fix `association_primary_key_type` for reflections with symbol primary key

Fixes #27864
Expand Down
Expand Up @@ -49,9 +49,10 @@ def prepare_column_options(column)
end

# Lists the valid migration options
def migration_keys
[:limit, :precision, :scale, :default, :null, :collation, :comment]
def migration_keys # :nodoc:
column_options_keys
end
deprecate :migration_keys

private

Expand Down
Expand Up @@ -122,7 +122,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
checks = []
checks << lambda { |c| c.name == column_name }
checks << lambda { |c| c.type == type } if type
migration_keys.each do |attr|
column_options_keys.each do |attr|
checks << lambda { |c| c.send(attr) == options[attr] } if options.key?(attr)
end

Expand Down Expand Up @@ -1172,6 +1172,9 @@ def change_column_comment(table_name, column_name, comment) #:nodoc:
end

private
def column_options_keys
[:limit, :precision, :scale, :default, :null, :collation, :comment]
end

def add_index_sort_order(quoted_columns, **options)
if order = options[:order]
Expand Down
@@ -1,7 +1,7 @@
module ActiveRecord
module ConnectionAdapters
module MySQL
module ColumnDumper
module ColumnDumper # :nodoc:
def column_spec_for_primary_key(column)
spec = super
if [:integer, :bigint].include?(schema_type(column)) && !column.auto_increment?
Expand Down
@@ -1,7 +1,7 @@
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module ColumnDumper
module ColumnDumper # :nodoc:
def column_spec_for_primary_key(column)
spec = super
if schema_type(column) == :uuid
Expand Down
@@ -1,7 +1,7 @@
module ActiveRecord
module ConnectionAdapters
module SQLite3
module ColumnDumper
module ColumnDumper # :nodoc:
private

def default_primary_key?(column)
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/migration_test.rb
Expand Up @@ -1138,4 +1138,8 @@ def test_deprecate_initialize_internal_tables
assert_deprecated { ActiveRecord::Base.connection.initialize_schema_migrations_table }
assert_deprecated { ActiveRecord::Base.connection.initialize_internal_metadata_table }
end

def test_deprecate_migration_keys
assert_deprecated { ActiveRecord::Base.connection.migration_keys }
end
end

0 comments on commit e0e20d6

Please sign in to comment.