I'm trying to use capistrano commands to create a database. I only found a command like deploy:migrate
. Is there a command for db:create
?
Capistrano doesn't provide any recipes for creating the database. As mentioned in this capistrano googlegroups thread:
it's not something that is generic enough to warrant inclusion in the core, and it really falls under the domain of "administration" which we try to avoid
Others have succeeded in automating the creation of database via capistrano by directly invoking the database creation command from the script.
The same thread mentioned above provides a link to a capistrano script which creates a mysql database by running the mysql
command from capistrano.
Here is another useful blogpost: Create MySQL database with Capistrano
As mentioned by @prakash above, capistrano doesn't really provide any recipes for doing rake tasks to create a database. However, there is a capistrano add on gem that makes the process seamlessly painless.
On your gemfile, add
gem 'capistrano-rails-collection'
Do a bundle install after that and then require it in your capfile like so
require 'capistrano/rails/collection'
Now you can run rake tasks to create databases like so
cap production rails:rake:db:reset
cap production rails:rake:db:seed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With