Skip to content

Commit

Permalink
renames the primary key constraint on renaming table
Browse files Browse the repository at this point in the history
  • Loading branch information
bhushan lodha authored and bhushan lodha committed Feb 17, 2014
1 parent e00ab2d commit df67453
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -381,8 +381,10 @@ def rename_table(table_name, new_name)
if seq == "#{table_name}_#{pk}_seq"
new_seq = "#{new_name}_#{pk}_seq"
execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
execute "ALTER TABLE #{new_name} DROP CONSTRAINT #{table_name}_pkey;"
execute "ALTER TABLE #{new_name} ADD PRIMARY KEY (#{pk});"
end

rename_table_indexes(table_name, new_name)
end

Expand Down

0 comments on commit df67453

Please sign in to comment.