diff options
author | Abdelkader Boudih <terminale@gmail.com> | 2014-06-27 08:46:07 +0000 |
---|---|---|
committer | Abdelkader Boudih <terminale@gmail.com> | 2014-06-27 19:43:54 +0000 |
commit | b58ec66f0e96ef7741d9ae7ae619683e6cb9d1f8 (patch) | |
tree | e7798d3c07957d60e7be4b7d2cbb88870d981a8a /activerecord/lib/active_record | |
parent | 30b56084fb67d99fa3284d34c9bb914ebee378b6 (diff) | |
download | rails-b58ec66f0e96ef7741d9ae7ae619683e6cb9d1f8.tar.gz rails-b58ec66f0e96ef7741d9ae7ae619683e6cb9d1f8.tar.bz2 rails-b58ec66f0e96ef7741d9ae7ae619683e6cb9d1f8.zip |
rename sequence only if it exists
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 30df98be1b..596ebca5d6 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -375,8 +375,8 @@ module ActiveRecord end # Renames a table. - # Also renames a table's primary key sequence if the sequence name matches the - # Active Record default. + # Also renames a table's primary key sequence if the sequence name exists and + # matches the Active Record default. # # Example: # rename_table('octopuses', 'octopi') @@ -384,7 +384,7 @@ module ActiveRecord clear_cache! execute "ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}" pk, seq = pk_and_sequence_for(new_name) - if seq.identifier == "#{table_name}_#{pk}_seq" + if seq && seq.identifier == "#{table_name}_#{pk}_seq" new_seq = "#{new_name}_#{pk}_seq" execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}" end |