aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-07 09:52:34 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-07 09:52:34 -0700
commit3043d45eefc3776d5f3a9e7d212a01f99d869ef8 (patch)
tree1c9ba9e709bdffa25f83cdef0f58ebd3b80076a4 /activerecord/lib/active_record
parentca0275d36b395631725c4583db5a45c06443fdb9 (diff)
parent0e00c6b296b48e35fc3997648561f5da7295098a (diff)
downloadrails-3043d45eefc3776d5f3a9e7d212a01f99d869ef8.tar.gz
rails-3043d45eefc3776d5f3a9e7d212a01f99d869ef8.tar.bz2
rails-3043d45eefc3776d5f3a9e7d212a01f99d869ef8.zip
Merge pull request #10455 from patricksrobertson/bigserial_id_not_identifying_pk
Add PK constraint on bigserial ID columns on postgres adapter
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 88b09e7999..2d0eef6c84 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -359,8 +359,12 @@ module ActiveRecord
# a record (as primary keys cannot be +nil+). This might be done via the
# +SecureRandom.uuid+ method and a +before_save+ callback, for instance.
def primary_key(name, type = :primary_key, options = {})
- return super unless type == :uuid
- options[:default] = options.fetch(:default, 'uuid_generate_v4()')
+ return super unless type = :primary_key
+
+ if type == :uuid
+ options[:default] = options.fetch(:default, 'uuid_generate_v4()')
+ end
+
options[:primary_key] = true
column name, type, options
end