Skip to content

Commit

Permalink
Update PG: rename sequence during table rename
Browse files Browse the repository at this point in the history
This keeps the ARJDBC implementation behavior in sync with
Rails' Active Record following the acceptance of rails/rails#7031
  • Loading branch information
Robb Kidd committed Jul 15, 2012
1 parent b76f828 commit efdf50a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/arjdbc/postgresql/adapter.rb
Expand Up @@ -623,6 +623,11 @@ def disable_referential_integrity(&block) #:nodoc:


def rename_table(name, new_name) def rename_table(name, new_name)
execute "ALTER TABLE #{name} RENAME TO #{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 end


# Adds a new column to the named table. # Adds a new column to the named table.
Expand Down

0 comments on commit efdf50a

Please sign in to comment.