diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2014-11-16 03:08:46 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-24 01:53:54 +0900 |
commit | b8d320c1294aa582ff34e1b15782c084edc0386b (patch) | |
tree | ffbc62d8615b78e8f18c9d27b492777f9e3382f3 /activerecord/lib/active_record | |
parent | e71f5dad4e0d27afbcc091173bee20bd6f4d2a4e (diff) | |
download | rails-b8d320c1294aa582ff34e1b15782c084edc0386b.tar.gz rails-b8d320c1294aa582ff34e1b15782c084edc0386b.tar.bz2 rails-b8d320c1294aa582ff34e1b15782c084edc0386b.zip |
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
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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 |