views:

21

answers:

1

Hi!

Does anyone know if Rails can be configured so that rake (e.g. db:migrate) uses a different database user to the app itself?

It seems to me that the database user for the app does not need permissions to drop tables and columns, where as db:migrate does, so separate should make for a more secure app...?

But I assume by default both would use credentials in database.yml

I'm using 2.3.8 with MySQL.

Thanks!

Glen.

+1  A: 

You could make a new environment configuration, similar to development and production, database_admin, and use rake db:migrate RAILS_ENV=database_admin.

If you get tired of typing the extra environment information all the time, you could use the clever rake tasks here to help reduce the tedium: http://errtheblog.com/posts/31-rake-around-the-rosie

sarnold
Many thanks! Great solution. Didn't occur to me that I could just add pseudo environment...Will check out those clever rake tasks too.
morangie