From 72e59fedb126ab2f42290796108a81f503257de5 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Fri, 16 Dec 2016 23:02:52 +1030 Subject: Tweak bigint PK handling * Don't force PKs on tables that have explicitly opted out * All integer-like PKs are autoincrement unless they have an explicit default --- .../lib/active_record/connection_adapters/mysql/schema_dumper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb') 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 2065816501..d44c35714f 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb @@ -4,8 +4,8 @@ module ActiveRecord module ColumnDumper def column_spec_for_primary_key(column) spec = super - if column.type == :integer && !column.auto_increment? - spec[:default] = schema_default(column) || "nil" + if [:integer, :bigint].include?(schema_type(column)) && !column.auto_increment? + spec[:default] ||= schema_default(column) || "nil" end spec[:unsigned] = "true" if column.unsigned? spec -- cgit v1.2.3