|
| 1 | +# CapistranoDbTasks | [](https://codeclimate.com/github/sgruhier/capistrano-db-tasks) [](http://badge.fury.io/rb/capistrano-db-tasks) |
| 2 | + |
| 3 | +Add database AND assets tasks to capistrano to a Rails project. It only works with capistrano 3. Older versions until 0.3 works with capistrano 2. |
| 4 | + |
| 5 | +Currently |
| 6 | + |
| 7 | +* It only supports mysql and postgresql (both side remote and local) |
| 8 | +* Synchronize assets remote to local and local to remote |
| 9 | + |
| 10 | +Commands mysql, mysqldump (or pg\_dump, psql), bzip2 and unbzip2 (or gzip) must be in your PATH |
| 11 | + |
| 12 | +Feel free to fork and to add more database support or new tasks. |
| 13 | + |
| 14 | +## Install |
| 15 | + |
| 16 | +Add it as a gem: |
| 17 | + |
| 18 | +```ruby |
| 19 | +gem "capistrano-db-tasks", require: false |
| 20 | +``` |
| 21 | + |
| 22 | +Add to config/deploy.rb: |
| 23 | + |
| 24 | +```ruby |
| 25 | +require 'capistrano-db-tasks' |
| 26 | + |
| 27 | +# if you haven't already specified |
| 28 | +set :rails_env, "production" |
| 29 | + |
| 30 | +# if you want to remove the local dump file after loading |
| 31 | +set :db_local_clean, true |
| 32 | + |
| 33 | +# if you want to remove the dump file from the server after downloading |
| 34 | +set :db_remote_clean, true |
| 35 | + |
| 36 | +# if you want to exclude table from dump |
| 37 | +set :db_ignore_tables, [] |
| 38 | + |
| 39 | +# if you want to exclude table data (but not table schema) from dump |
| 40 | +set :db_ignore_data_tables, [] |
| 41 | + |
| 42 | +# If you want to import assets, you can change default asset dir (default = system) |
| 43 | +# This directory must be in your shared directory on the server |
| 44 | +set :assets_dir, %w(public/assets public/att) |
| 45 | +set :local_assets_dir, %w(public/assets public/att) |
| 46 | + |
| 47 | +# if you want to work on a specific local environment (default = ENV['RAILS_ENV'] || 'development') |
| 48 | +set :locals_rails_env, "production" |
| 49 | + |
| 50 | +# if you are highly paranoid and want to prevent any push operation to the server |
| 51 | +set :disallow_pushing, true |
| 52 | + |
| 53 | +# if you prefer bzip2/unbzip2 instead of gzip |
| 54 | +set :compressor, :bzip2 |
| 55 | +``` |
| 56 | + |
| 57 | +Add to .gitignore |
| 58 | + |
| 59 | +```yml |
| 60 | +/db/*.sql |
| 61 | +``` |
| 62 | + |
| 63 | +[How to install bzip2 on Windows](http://stackoverflow.com/a/25625988/3324219) |
| 64 | + |
| 65 | +## Available tasks |
| 66 | + |
| 67 | +``` |
| 68 | +app:local:sync || app:pull # Synchronize your local assets AND database using remote assets and database |
| 69 | +app:remote:sync || app:push # Synchronize your remote assets AND database using local assets and database |
| 70 | +
|
| 71 | +assets:local:sync || assets:pull # Synchronize your local assets using remote assets |
| 72 | +assets:remote:sync || assets:push # Synchronize your remote assets using local assets |
| 73 | +
|
| 74 | +db:local:sync || db:pull # Synchronize your local database using remote database data |
| 75 | +db:remote:sync || db:push # Synchronize your remote database using local database data |
| 76 | +``` |
| 77 | + |
| 78 | +## Example |
| 79 | + |
| 80 | +``` |
| 81 | +cap db:pull |
| 82 | +cap production db:pull # if you are using capistrano-ext to have multistages |
| 83 | +``` |
| 84 | + |
| 85 | +## Contributors |
| 86 | + |
| 87 | +* tilsammans (http://github.com/tilsammansee) |
| 88 | +* bigfive (http://github.com/bigfive) |
| 89 | +* jakemauer (http://github.com/jakemauer) |
| 90 | +* tjoneseng (http://github.com/tjoneseng) |
| 91 | +* numbata (http://github.com/numbata) |
| 92 | +* rafaelsales (http://github.com/rafaelsales) |
| 93 | +* rdeshpande (http://github.com/rdeshpande) |
| 94 | + |
| 95 | +## TODO |
| 96 | + |
| 97 | +* May be change project's name as it's not only database tasks now :) |
| 98 | +* Add tests |
| 99 | + |
| 100 | +Copyright (c) 2009 [Sébastien Gruhier - XILINUS], released under the MIT license |
0 commit comments