aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
diff options
context:
space:
mode:
authorAndrey Novikov <envek@envek.name>2014-07-10 21:00:46 +0400
committerAndrey Novikov <envek@envek.name>2014-07-11 01:11:00 +0400
commit584fc8b33b66aa47b2ecabedbdca7c66f16653d7 (patch)
tree0081243e639af7390dd934137fc441a9d7352b5b /activerecord/lib/active_record/schema_dumper.rb
parent6e76031e8f1f815b390f966cb21e25c66e5ded50 (diff)
downloadrails-584fc8b33b66aa47b2ecabedbdca7c66f16653d7.tar.gz
rails-584fc8b33b66aa47b2ecabedbdca7c66f16653d7.tar.bz2
rails-584fc8b33b66aa47b2ecabedbdca7c66f16653d7.zip
Dump PostgreSQL primary key with custom function as a default.
For example, if use pgcrypto extension in PostgreSQL 9.4 beta 1, where uuid-ossp extension isn't available for moment of writing, and thus to use a gen_random_uuid() method as a primary key default. In this case schema dumper wasn't able to correctly reconstruct create_table statement and lost primary key constraint on schema load. Fixes #16111.
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 64bc68eefd..a94364bde1 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -120,7 +120,8 @@ HEADER
# first dump primary key column
if @connection.respond_to?(:pk_and_sequence_for)
pk, _ = @connection.pk_and_sequence_for(table)
- elsif @connection.respond_to?(:primary_key)
+ end
+ if !pk && @connection.respond_to?(:primary_key)
pk = @connection.primary_key(table)
end