No Pugs
they're evil
Fix for long index names in rails using postgresql (fix for "Input string is longer than NAMEDATALEN-1 (63)")
If you are getting this when running rails migrations using a postgresql adapter:
Input string is longer than NAMEDATALEN-1 (63)
Then this tiny plugin can solve this problem. Index names longer than 63 characters work fine with some postgresql adapters and not others. I’m not sure why. This adds a method to ActiveRecord::ConnectionAdapters::PostgreSQLAdapter that keeps the index_names under the limit.
here’s the entire piece of code:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
#There are PostgreSQL drivers/versions of drivers that truncate
#index names to 63 characters. Since some do not, this override makes
#sure that the truncate occurs regardless of PostgreSQL driver.
def index_name(table, columns)
super(table, columns)[0..62]
end
endTo install this plugin using ext, you can use:
ext install git://github.com/azimux/ax_fix_long_psql_index_names.git
or, using rake plugin:
./script/plugin install git://github.com/azimux/ax_fix_long_psql_index_names.git
Powered by Typo – Thème Frédéric de Villamil | Photo Glenn