I’ve written a simple Rails migration that adds an index to an existing
Postgres table:
class AddIndexToEvents < ActiveRecord::Migration
def change
add_index :sf_events, :account_id
end
end
However, when I run the migration, it fails due to a syntax error on the
CREATE INDEX line. I’m expecting some SQL like this to be generated:
CREATE INDEX index_sf_events_on_account_id ON sf_events (account_id);
But instead I get something like this:
CREATE INDEX index_sf_events_on_account_id ON sf_events ( );
The migration works fine on my friend’s Mac, but it fails on my Linux
box.
It seems like I may have the wrong/outdated packages. I’m running
Ubuntu
12.10 and have these packages installed: libpq-dev, libpq5, postgresql,
postgresql-9.1, postgresql-client-9.1,
postgresql-client-common, postgresql-common, postgresql-contrib,
postgresql-contrib-9.1.
Here’s the full error message:
== AddIndexToEvents: migrating