Reputation: 115
Why we get an error on the command rake db:migrate
Rails Error: Unable to access log file. Please ensure that /home/mahaloo/mahaloo/releases/20120329200051/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
unable to open database file
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Whats wrong there. I tryed to deploy via capistrano, i used this tutorial to setup capistrano http://teachmetocode.com/screencasts/basic-deployment-with-capistrano/
Upvotes: 0
Views: 2848
Reputation: 965
Have you try with sudo
if your enviroment its on linux, for example, i got that error trying to run the migration, rake db:migrate
, so i used sudo rake db:migrate
and that's work, maybe because the rake when its trying to consult development.log doesn't have the right permissions or something like that.
Upvotes: 0
Reputation: 328
This is likely because you're following the practice of not checking your database.yml into source control. If that is the case, you can make a copy of your database.yml in your deploy shared/config
folder, and create a Capistrano task to symlink that back into your release folder. Something like this (in namespace deploy
)
task :create_symlinks do
run "ln -nfs #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3"
run " -nfs #{shared_path}/config/ldap.yml #{release_path}/config/ldap.yml"
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
Then call this in a hook
after "deploy:finalize_update", "deploy:create_symlinks"
after "deploy:finalize_update", "deploy:migrate"
I think that would work, that's how we're step up on our project. This is similar to these questions:
database.yml deployment best practice Capistrano - can't deploy my database.yml How to manage Rails database.yml
Upvotes: 0
Reputation: 4877
You're either missing the log directory or file. Have you run cap deploy:setup ?
Otherwise manually create the log file first.
Upvotes: 1