Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Rails app and rake db:migrate use different database credentials?

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.

like image 780
morangie Avatar asked Aug 02 '10 10:08

morangie


1 Answers

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

like image 84
sarnold Avatar answered Oct 19 '22 09:10

sarnold