From b8d320c1294aa582ff34e1b15782c084edc0386b Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 16 Nov 2014 03:08:46 +0900 Subject: Allow `:limit` option for MySQL bigint primary key support Example: create_table :foos, id: :primary_key, limit: 8 do |t| end # or create_table :foos, id: false do |t| t.column :id, limit: 8 end --- .../connection_adapters/abstract_mysql_adapter.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 8db4bcd7e3..e11eaabf4b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -11,6 +11,16 @@ module ActiveRecord options[:auto_increment] ||= type == :bigint super end + + def new_column_definition(name, type, options) # :nodoc: + column = super + case column.type + when :primary_key + column.type = :integer + column.auto_increment = true + end + column + end end class SchemaCreation < AbstractAdapter::SchemaCreation -- cgit v1.2.3