Skip to content

Commit

Permalink
Merge c0109a3 into dc6cb03
Browse files Browse the repository at this point in the history
  • Loading branch information
urkle committed Dec 14, 2018
2 parents dc6cb03 + c0109a3 commit 4c35c25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ module ConnectionAdapters
module PostgreSQL
module PostgreSQL # need two PostgreSQLs because the first gets stripped by schema_monkey
module SchemaDumper
def column_spec_for_primary_key(column)
spec = super

spec.delete :default

spec[:default] = schema_default(column)
spec[:default] ||= "nil" if explicit_primary_key_default?(column)
spec.compact!
spec
end

# quick hack fix quoting of column default functions to allow eval() when we
# capture the stream.
Expand Down
3 changes: 3 additions & 0 deletions spec/dumper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def after(env)
migration.create_table "other" do |t|
t.references :thing
end
migration.create_table "inttable", id: :serial do |t|
end
migration.add_foreign_key("other", "things")
migration.execute "CREATE TABLE custom_table ( my_column custom_type DEFAULT 'a'::custom_type NOT NULL)" if TestCustomType
end
Expand All @@ -82,6 +84,7 @@ def after(env)

context TestDumper::Middleware::Dumper::Tables do
Then { expect(dump).to match(/create_table "other".*create_table "#{middleware}".*create_table "things"/m) }
Then { expect(dump).to match(/create_table "inttable", id: :serial, force:/m) }
end

context TestDumper::Middleware::Dumper::Table do
Expand Down

0 comments on commit 4c35c25

Please sign in to comment.