I am using PostgreSQL with Rails 3.2. One of my db migrations has the following:
execute <<-SQL CREATE INDEX users_multi_idx ON users (lower(left(fname, 1)), fname) WHERE deleted_at IS NULL; SQL
When porting to some dbs, we get the following error:
== AddFnameIndexToUsers: migrating =========================================== -- execute(" CREATE INDEX users_multi_idx\n ON users (lower(left(fname, 1)), fname)\n WHERE deleted_at IS NULL;\n") rake aborted! An error has occurred, this and all later migrations canceled: PG::Error: ERROR: function left(character varying, integer) does not exist LINE 2: ON users (lower(left(fname, 1)), fname) ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. : CREATE INDEX users_multi_idx ON users (lower(left(fname, 1)), fname) WHERE deleted_at IS NULL;
What is strange, this does not happen in all dbs, just in some (staging). Any suggestions as to what is wrong with this index execution?
source share