aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-11-20 17:37:54 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-11-20 17:37:54 -0800
commit3e92806357543cdbabad813884a591fca69193c2 (patch)
tree64f1f65b18399df4232740342455383eedc6fc85 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parentee80e22f03b36f5e2c35288226c66a44e2e722e2 (diff)
downloadrails-3e92806357543cdbabad813884a591fca69193c2.tar.gz
rails-3e92806357543cdbabad813884a591fca69193c2.tar.bz2
rails-3e92806357543cdbabad813884a591fca69193c2.zip
raise a better exception for renaming long indexes
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb3
1 files changed, 3 insertions, 0 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 51853c6812..b4b066c06e 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -478,6 +478,9 @@ module ActiveRecord
end
def rename_index(table_name, old_name, new_name)
+ if new_name.length > allowed_index_name_length
+ raise ArgumentError, "Index name '#{new_name}' on table '#{table_name}' is too long; the limit is #{allowed_index_name_length} characters"
+ end
execute "ALTER INDEX #{quote_column_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
end