Skip to content
This repository

Update PG: rename sequence during table rename #202

Merged
merged 1 commit into from over 1 year ago

2 participants

Robb Kidd Nick Sieger
Robb Kidd

This keeps the ARJDBC implementation behavior in sync with Rails' Active Record following the acceptance of rails/rails#6874 update to Rails master and rails/rails#7031 backport to 3.2.

This runs fine within the activerecord-jdbc-adapter tests, but I am having difficulty running the Active Record test suite under jruby + activerecord-jdbc-adapter with or without this change. Given that, this is probably in some need of review.

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
efdf50a
Nick Sieger nicksieger merged commit 02fa182 into from
Nick Sieger nicksieger closed this
Nick Sieger
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 14, 2012
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
efdf50a
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 0 deletions. Show diff stats Hide diff stats

  1. 5  lib/arjdbc/postgresql/adapter.rb
5  lib/arjdbc/postgresql/adapter.rb
@@ -623,6 +623,11 @@ def disable_referential_integrity(&block) #:nodoc:
623 623
 
624 624
     def rename_table(name, new_name)
625 625
       execute "ALTER TABLE #{name} RENAME TO #{new_name}"
  626
+      pk, seq = pk_and_sequence_for(new_name)
  627
+      if seq == "#{name}_#{pk}_seq"
  628
+        new_seq = "#{new_name}_#{pk}_seq"
  629
+        execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
  630
+      end
626 631
     end
627 632
 
628 633
     # Adds a new column to the named table.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.