Permalink
Browse files

Update PG: rename sequence during table rename

This keeps the ARJDBC implementation behavior in sync with
Rails' Active Record following the acceptance of rails/rails#7031
  • Loading branch information...
1 parent b76f828 commit efdf50aa3ceaa1454007bf8f170e1f017df0e177 Robb Kidd committed Jul 15, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/arjdbc/postgresql/adapter.rb
@@ -623,6 +623,11 @@ def disable_referential_integrity(&block) #:nodoc:
def rename_table(name, new_name)
execute "ALTER TABLE #{name} RENAME TO #{new_name}"
+ pk, seq = pk_and_sequence_for(new_name)
+ if seq == "#{name}_#{pk}_seq"
+ new_seq = "#{new_name}_#{pk}_seq"
+ execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
+ end
end
# Adds a new column to the named table.

0 comments on commit efdf50a

Please sign in to comment.