From 89bb01a5dd553cd766149eafbad700f8e6ec1e24 Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Tue, 29 Dec 2020 09:55:23 -0700 Subject: [PATCH] Set default of `primary_key` column to be unsigned. At CNTRAL, we default our primary keys to be unsigned. As of Rails 5+, there is not clean way to do this in a monkey patch so we fork the rails repo and made this adjustment. --- .../connection_adapters/mysql/schema_definitions.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb index 33669cd7c2d4..78cc0703028c 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb @@ -77,6 +77,7 @@ def new_column_definition(name, type, **options) # :nodoc: type = :integer options[:limit] ||= 8 options[:primary_key] = true + options[:unsigned] ||= true # NOTE: At CNTRAL, we default our primary keys to be unsigned. As of Rails 5+, there is not clean way to do this in a monkey patch so we fork the rails repo and made this adjustment. when /\Aunsigned_(?.+)\z/ type = $~[:type].to_sym options[:unsigned] = true