I’m trying to add a migration with foreign keys like this:
execute ‘ALTER TABLE projects ADD CONSTRAINT fk_project_user FOREIGN KEY
( user_id ) REFERENCES users ( id )’
the problem is that for development i’m using sqlite and I don’t think
that support foreign keys, at least the migration is giving me this
error:
– execute("ALTER TABLE projects ADD CONSTRAINT fk_projects_user FOREIGN
KEY ( user_id ) REFERENCES users( id ) ")
rake aborted!
SQLite3::SQLException: near “ADD”: syntax error: ALTER TABLE projects
ADD CONSTRAINT fk_projects_users FOREIGN KEY ( user_id ) REFERENCES
users( id )
So my question is how can I test to see what database the migration is
working on so that I can do the execute on mysql (production), but not
on sqlite (development)?
And of course if what I’m trying to do doesn’t really make sense, or
there’s a better way, please let me know.
Thanks,
Jesse