diff options
author | Paul Mucur <paul@altmetric.com> | 2015-02-11 10:05:17 +0000 |
---|---|---|
committer | Paul Mucur <paul@altmetric.com> | 2015-04-15 09:53:55 +0100 |
commit | c0abeadc0e62fc6f7a066f4d8db9895525ad8258 (patch) | |
tree | 5363c08d005c83dcff877a82294b252c31a7b45e /activerecord/lib/active_record/connection_adapters | |
parent | 5f00ed10dd820b6802168933c2497d17c43c88f5 (diff) | |
download | rails-c0abeadc0e62fc6f7a066f4d8db9895525ad8258.tar.gz rails-c0abeadc0e62fc6f7a066f4d8db9895525ad8258.tar.bz2 rails-c0abeadc0e62fc6f7a066f4d8db9895525ad8258.zip |
Fix missing index when using timestamps with index
The `index` option used with `timestamps` should be passed to both
`column` definitions for `created_at` and `updated_at` rather than just
the first.
This was happening because `Hash#delete` is used to extract the `index`
option passed to `timestamps`, thereby mutating the `options` hash
in-place. Now take a copy of the `options` before deleting so that the
original is not modified.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index cb83d0022c..4761024ad0 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -359,6 +359,7 @@ module ActiveRecord def column(name, type, options = {}) name = name.to_s type = type.to_sym + options = options.dup if @columns_hash[name] && @columns_hash[name].primary_key? raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." |