Permalink
Browse files

[postgres] primary_key definition for AR-4.0

  • Loading branch information...
1 parent 59ae5f8 commit c801e14399a81e298b7a83b9df483fc7c1df609a @kares kares committed Apr 3, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/arjdbc/postgresql/adapter.rb
@@ -1434,7 +1434,14 @@ def json(name, options = {})
class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
include ColumnMethods
-
+
+ def primary_key(name, type = :primary_key, options = {})
+ return super unless type == :uuid
+ options[:default] ||= 'uuid_generate_v4()'
+ options[:primary_key] = true
+ column name, type, options
+ end if ActiveRecord::VERSION::MAJOR > 3 # 3.2 super expects (name)
+
def column(name, type = nil, options = {})
super
column = self[name]

0 comments on commit c801e14

Please sign in to comment.