aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2013-07-10 02:14:38 +0900
committerkennyj <kennyj@gmail.com>2013-07-10 02:16:27 +0900
commit4734e4ed3181bf8c8dca959078b7e6295e702719 (patch)
tree276d495f854ce7a05d840d1c738fba4434e7c099 /activerecord/lib
parent51e165808b8fdb0323d50aa7de973303224b7c7b (diff)
downloadrails-4734e4ed3181bf8c8dca959078b7e6295e702719.tar.gz
rails-4734e4ed3181bf8c8dca959078b7e6295e702719.tar.bz2
rails-4734e4ed3181bf8c8dca959078b7e6295e702719.zip
Migration dump UUID default functions to schema.rb. Fixes #10751.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 98126249df..5a9d93ef57 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -45,16 +45,18 @@ module ActiveRecord
module ConnectionAdapters
# PostgreSQL-specific extensions to column definitions in a table.
class PostgreSQLColumn < Column #:nodoc:
- attr_accessor :array
+ attr_accessor :array, :default_function
# Instantiates a new PostgreSQL column definition in a table.
def initialize(name, default, oid_type, sql_type = nil, null = true)
@oid_type = oid_type
+ default_value = self.class.extract_value_from_default(default)
+ @default_function = default if !default_value && default && default =~ /.+\(.*\)/
if sql_type =~ /\[\]$/
@array = true
- super(name, self.class.extract_value_from_default(default), sql_type[0..sql_type.length - 3], null)
+ super(name, default_value, sql_type[0..sql_type.length - 3], null)
else
@array = false
- super(name, self.class.extract_value_from_default(default), sql_type, null)
+ super(name, default_value, sql_type, null)
end
end
@@ -435,6 +437,7 @@ module ActiveRecord
def prepare_column_options(column, types)
spec = super
spec[:array] = 'true' if column.respond_to?(:array) && column.array
+ spec[:default] = "\"#{column.default_function}\"" if column.respond_to?(:default_function) && column.default_function
spec
end