Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano commands for creating database

Tags:

capistrano

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?

like image 611
Feng Wan Avatar asked Jan 31 '13 21:01

Feng Wan


2 Answers

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

like image 158
Prakash Murthy Avatar answered Nov 13 '22 05:11

Prakash Murthy


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
like image 45
Sawo Cliff Avatar answered Nov 13 '22 05:11

Sawo Cliff