aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb48
1 files changed, 23 insertions, 25 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb
index 2ba9657f24..2065816501 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb
@@ -3,19 +3,17 @@ module ActiveRecord
module MySQL
module ColumnDumper
def column_spec_for_primary_key(column)
- if column.bigint?
- spec = { id: :bigint.inspect }
- spec[:default] = schema_default(column) || 'nil' unless column.auto_increment?
- else
- spec = super
+ spec = super
+ if column.type == :integer && !column.auto_increment?
+ spec[:default] = schema_default(column) || "nil"
end
- spec[:unsigned] = 'true' if column.unsigned?
+ spec[:unsigned] = "true" if column.unsigned?
spec
end
def prepare_column_options(column)
spec = super
- spec[:unsigned] = 'true' if column.unsigned?
+ spec[:unsigned] = "true" if column.unsigned?
spec
end
@@ -25,29 +23,29 @@ module ActiveRecord
private
- def default_primary_key?(column)
- super && column.auto_increment?
- end
+ def default_primary_key?(column)
+ super && column.auto_increment?
+ end
- def schema_type(column)
- if column.sql_type == 'tinyblob'
- :blob
- else
- super
+ def schema_type(column)
+ if column.sql_type == "tinyblob"
+ :blob
+ else
+ super
+ end
end
- end
- def schema_precision(column)
- super unless /time/ === column.sql_type && column.precision == 0
- end
+ def schema_precision(column)
+ super unless /time/.match?(column.sql_type) && column.precision == 0
+ end
- def schema_collation(column)
- if column.collation && table_name = column.table_name
- @table_collation_cache ||= {}
- @table_collation_cache[table_name] ||= select_one("SHOW TABLE STATUS LIKE '#{table_name}'")["Collation"]
- column.collation.inspect if column.collation != @table_collation_cache[table_name]
+ def schema_collation(column)
+ if column.collation && table_name = column.table_name
+ @table_collation_cache ||= {}
+ @table_collation_cache[table_name] ||= select_one("SHOW TABLE STATUS LIKE '#{table_name}'")["Collation"]
+ column.collation.inspect if column.collation != @table_collation_cache[table_name]
+ end
end
- end
end
end
end