提交 2aa9fd07 编写于 作者: R Ryuta Kamizono

Deprecate `ColumnDumper#migration_keys`

`ColumnDumper#migration_keys` was extracted to customize keys for
standardized column arguments widths. But the feature was removed in
df84e986. The internal method is no longer used for that.
上级 aff5e524
* Deprecate `ColumnDumper#migration_keys`.
*Ryuta Kamizono*
* Fix `association_primary_key_type` for reflections with symbol primary key * Fix `association_primary_key_type` for reflections with symbol primary key
Fixes #27864 Fixes #27864
......
...@@ -49,9 +49,10 @@ def prepare_column_options(column) ...@@ -49,9 +49,10 @@ def prepare_column_options(column)
end end
# Lists the valid migration options # Lists the valid migration options
def migration_keys def migration_keys # :nodoc:
[:limit, :precision, :scale, :default, :null, :collation, :comment] column_options_keys
end end
deprecate :migration_keys
private private
......
...@@ -122,7 +122,7 @@ def column_exists?(table_name, column_name, type = nil, options = {}) ...@@ -122,7 +122,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
checks = [] checks = []
checks << lambda { |c| c.name == column_name } checks << lambda { |c| c.name == column_name }
checks << lambda { |c| c.type == type } if type 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) checks << lambda { |c| c.send(attr) == options[attr] } if options.key?(attr)
end end
...@@ -1172,6 +1172,9 @@ def change_column_comment(table_name, column_name, comment) #:nodoc: ...@@ -1172,6 +1172,9 @@ def change_column_comment(table_name, column_name, comment) #:nodoc:
end end
private private
def column_options_keys
[:limit, :precision, :scale, :default, :null, :collation, :comment]
end
def add_index_sort_order(quoted_columns, **options) def add_index_sort_order(quoted_columns, **options)
if order = options[:order] if order = options[:order]
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module MySQL module MySQL
module ColumnDumper module ColumnDumper # :nodoc:
def column_spec_for_primary_key(column) def column_spec_for_primary_key(column)
spec = super spec = super
if [:integer, :bigint].include?(schema_type(column)) && !column.auto_increment? if [:integer, :bigint].include?(schema_type(column)) && !column.auto_increment?
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module PostgreSQL module PostgreSQL
module ColumnDumper module ColumnDumper # :nodoc:
def column_spec_for_primary_key(column) def column_spec_for_primary_key(column)
spec = super spec = super
if schema_type(column) == :uuid if schema_type(column) == :uuid
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module SQLite3 module SQLite3
module ColumnDumper module ColumnDumper # :nodoc:
private private
def default_primary_key?(column) def default_primary_key?(column)
......
...@@ -1138,4 +1138,8 @@ def test_deprecate_initialize_internal_tables ...@@ -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_schema_migrations_table }
assert_deprecated { ActiveRecord::Base.connection.initialize_internal_metadata_table } assert_deprecated { ActiveRecord::Base.connection.initialize_internal_metadata_table }
end end
def test_deprecate_migration_keys
assert_deprecated { ActiveRecord::Base.connection.migration_keys }
end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册