Giter Club home page Giter Club logo

capistrano-db-tasks's People

Contributors

antonal avatar artempartos avatar bigfive avatar bronislav avatar dtaniwaki avatar dynamick avatar elthariel avatar gkopylov avatar gnandretta avatar iamdeuterium avatar intractablequery avatar jakemauer avatar jobwat avatar majioa avatar matfiz avatar mdpatrick avatar numbata avatar opensourceame avatar prokopsimek avatar pugetive avatar rafaelsales avatar rdeshpande avatar roschaefer avatar sauliusgrigaitis avatar seliverstov-maxim avatar sgruhier avatar stephenaument avatar stevenchanin avatar tjoneseng avatar zedtux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capistrano-db-tasks's Issues

Remote dump files (`.sql.bz2`) not cleared

I understand that eventually these will dissapear with capistrano cleanup, but is there a reason these dump files arent cleared by the gem itself, I dont see an option in the README for this either

db_ignore_data_tables seem not to impact the dump

I tried using the db_ignore_data_tables option as follows (in config/deploy.rb):

set :db_ignore_data_tables, [:versions]

But it still downloads the whole versions table with data.

Where am I wrong?
Stack: Rails 4.2.4, capistrano 3.0.0, capistrano-db-tasks 0.4.

Option to drop database before import

The import cmd (at least for mysql) is

mysql #{credentials} -D #{database} < #{file}

which will result in the file being appended to the current database.

Is there an option to drop the database before import? If not, can there be?

undefined method `fetch'

I'm getting a strange error that I cannot fix. I have a clean rails 4.0.3 app, just created, nothing else, just those gems in the Gemfile:

gem 'capistrano'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano-bundler'
gem 'capistrano-db-tasks'

I run bundle install and when trying to run rails s or passenger+nginx I get the error above ):

With rails server:

/home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks/dbtasks.rb:5:in `<top (required)>': undefined method `fetch' for main:Object (NoMethodError)
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks.rb:2:in `require'
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks.rb:2:in `<top (required)>'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
        from /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
        from /home/jeff/repos/test-app/config/application.rb:7:in `<top (required)>'
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/railties-4.0.3/lib/rails/commands.rb:74:in `require'
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/railties-4.0.3/lib/rails/commands.rb:74:in `block in <top (required)>'
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap'
        from /home/jeff/.rvm/gems/ruby-2.1.1/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

With Passenger+Nginx:

undefined method `fetch' for main:Object (NoMethodError)
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks/dbtasks.rb:5:in `<top (required)>'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks.rb:2:in `require'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/capistrano-db-tasks-0.3/lib/capistrano-db-tasks.rb:2:in `<top (required)>'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
  /home/jeff/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
  /home/jeff/repos/test-app/config/application.rb:7:in `<top (required)>'
  /home/jeff/repos/test-app/config/environment.rb:2:in `require'
  /home/jeff/repos/test-app/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.38/helper-scripts/rack-preloader.rb:112:in `eval'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.38/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.38/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.38/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /home/jeff/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.38/helper-scripts/rack-preloader.rb:28:in `<main>'

Strangely, this only started happening on April 4th... when I attempted to use capistrano-db-tasks before it worked fine...

psych syntax error on db:pull

using the latest version from git: 5ecffdb

[jc@mac] cap db:pull
    triggering load callbacks
  * 2013-09-25 06:16:12 executing `production'
    triggering start callbacks for `db:pull'
  * 2013-09-25 06:16:12 executing `multistage:ensure'
  * 2013-09-25 06:16:12 executing `db:pull'
  * 2013-09-25 06:16:12 executing `db:local:sync'
local {...}
Local database: contacts
Are you sure you want to erase your local database with server database (y)es, (n)o  ? y
local {...}
  * executing "cat /u/apps/contacts/current/config/database.yml"
    servers: ["184.106.196.52"]
    [184.106.196.52] executing command
    command finished in 1098ms
/Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1 (Psych::SyntaxError)
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/capistrano-db-tasks-5ecffdba5d3d/lib/capistrano-db-tasks/database.rb:64:in `initialize'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/capistrano-db-tasks-5ecffdba5d3d/lib/capistrano-db-tasks/database.rb:122:in `new'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/capistrano-db-tasks-5ecffdba5d3d/lib/capistrano-db-tasks/database.rb:122:in `remote_to_local'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/capistrano-db-tasks-5ecffdba5d3d/lib/capistrano-db-tasks/dbtasks.rb:30:in `block (4 levels) in <top (required)>'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/capistrano-db-tasks-5ecffdba5d3d/lib/capistrano-db-tasks/dbtasks.rb:37:in `block (3 levels) in <top (required)>'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `each'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:34:in `execute!'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:14:in `execute'
  from /Users/jc/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-2.15.4/bin/cap:4:in `<main>'

My database.yml has ERB in it:

app@production-20130711:~$ cat /u/apps/contacts/current/config/database.yml
<%= ENV['RAILS_ENV'] %>:
  adapter: postgresql
  encoding: unicode
  database: <%= ENV['PGDATABASE'] %>
  pool: 5
  username: <%= ENV['PGUSER'] %>
  password: <%= ENV['PGPASSWORD'] %>
  host: <%= ENV['PGHOST'] %>
  port: <%= ENV['PGPORT'] %>

undefined method `fetch' for main:Object (NoMethodError)

This is a recent development since I upgraded from ruby 2.2.0 to 2.2.2. This occurs why I try to run any of the rails generators, specifically a migration is this instance.

/Users/Thomas/.rvm/gems/ruby-2.2.2@HexGen/gems/capistrano-db-tasks-0.4/lib/capistrano-db-tasks/dbtasks.rb:5:in <top (required)>': undefined methodfetch' for main:Object (NoMethodError)

Any idea what could cause such an error? I have to comment the gem out of my gemfile to create migrations.

Postgresql db:push doesn't create tables

Hey guys! Really glad this got updated for capistrano 3. Strangely, I've noticed that I have to run db migrations on my production server in order to get db:push. I would assume by the phrasing on the prompt that it would completely replace the database, but this doesn't appear to be the case.

I'll paste my error message below (pre-migration run):

DEBUG Uploading db/myapp_2014-03-26-172151.sql.bz2 0.0%
 INFO Uploading db/myapp_2014-03-26-172151.sql.bz2 100.0%
 INFO [413f2fbf] Running /usr/bin/env cd /var/www/myapp.com/current && bunzip2 -f db/myapp_2014-03-26-172151.sql.bz2 && RAILS_ENV=production && PGPASSWORD='KLkkE32@pple' psql  -U myapp  -h localhost myapp < db/myapp_2014-03-26-172151.sql on myapp.com
DEBUG [413f2fbf] Command: cd /var/www/myapp.com/current && bunzip2 -f db/myapp_2014-03-26-172151.sql.bz2 && RAILS_ENV=production && PGPASSWORD='KLkkE32@pple' psql  -U myapp  -h localhost myapp < db/myapp_2014-03-26-172151.sql
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "users_properties" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "unique_schema_migrations" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "posts_properties" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_votes_on_voter_id_and_voter_type_and_vote_scope" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_votes_on_votable_id_and_votable_type_and_vote_scope" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_versions_on_item_type_and_item_id" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_users_on_reset_password_token" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_users_on_email" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_active_admin_comments_on_resource_type_and_resource_id" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_active_admin_comments_on_namespace" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  index "index_active_admin_comments_on_author_type_and_author_id" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.votes" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.versions" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.users" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.posts" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.pages" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.images" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.attachments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.active_admin_comments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.votes" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.versions" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.users" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.posts" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.pages" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.images" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.attachments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  relation "public.active_admin_comments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "votes_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "votes" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "versions_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "versions" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "users_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "users" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "schema_migrations" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "posts_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "posts" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "pages_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "pages" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "images_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "images" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "attachments_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "attachments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  sequence "active_admin_comments_id_seq" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    DROP EXTENSION
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    DROP EXTENSION
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    DROP SCHEMA
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SCHEMA
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    COMMENT
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE EXTENSION
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    COMMENT
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE EXTENSION
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    COMMENT
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    SET
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER SEQUENCE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          1
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          9
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]         10
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          2
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          1
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          1
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]         13
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]     setval 
DEBUG [413f2fbf]    --------
DEBUG [413f2fbf]          1
DEBUG [413f2fbf]    (1 row)
DEBUG [413f2fbf]    
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    ALTER TABLE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    CREATE INDEX
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    REVOKE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    REVOKE
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    GRANT
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
DEBUG [413f2fbf]    GRANT
DEBUG [413f2fbf]    ERROR:  table "active_admin_comments" does not exist
 INFO [413f2fbf] Finished in 0.513 seconds with exit status 0 (successful).
 INFO [6d375ef1] Running /usr/bin/env cd /var/www/myapp.com/current && rm db/myapp_2014-03-26-172151.sql on myapp.com
DEBUG [6d375ef1] Command: cd /var/www/myapp.com/current && rm db/myapp_2014-03-26-172151.sql
 INFO [6d375ef1] Finished in 0.203 seconds with exit status 0 (successful).

I hope this is just a bug that can be fixed, I was really looking forward to being able to take my local database and put it exactly as it exists on production.

how do I pass credentials to pg_dump?

I am trying to sync my local dev environment with my prod environment. i do not deploy as the database user so it keeps asking me for a pssword which doesnt seem to let me type anything.

looks like i need to supply credentials to pg_dump. I can see in database file that it uses the @config variable but I do not know how to set it. Can you help?

Net::SCP failure when db_dump_dir is set

I keep previous dumps around to allow reloading (e.g. set :db_local_clean, false). With version 0.4, the dumps went into my projects ./db directory. With version 0.6, they were showing up in my project root. So I set :db_dump_dir as described in the README:

# configure location where the dump file should be created
set :db_dump_dir, "./db"

Now when I try to do a db:pull, I get a fatal error:

steven$ cap production db:pull
rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
ruby-2.3.1
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Loading local database config
Local database: myproject_development
Please enter answer (Are you sure you want to erase your local database with server database (y)es, (n)o  ? ): y
Loading local database config
Loading remote database config
00:00 db:local:sync
      01 cd /home/deploy/apps/myproject/current && PGPASSWORD='secret_thingy' pg_dump  -U deploy  myproject_production --no-acl --โ€ฆ
    โœ” 01 [email protected] 0.195s
      02 rm -f ./db/myproject_production_2017-01-05-084704.sql.bz2
    โœ” 02 [email protected] 0.042s
(Backtrace restricted to imported tasks)
cap aborted!
Net::SCP::Error: SCP did not finish successfully (1): scp: ./db/myproject_production_2017-01-05-084704.sql.bz2: No such file or directory

Tasks: TOP => db:pull => db:local:sync
(See full trace by running task with --trace)

NoMethodError: undefined method `zone' for Time:Class

$ bundle exec cap --backtrace production app:pull
Loading local database config
Running via Spring preloader in process 92564
Local database     : MyWeb_development
Assets directories : ["public/uploads"]
Please enter answer (Are you sure you want to erase your local database AND your local assets with server database and assets(["public/uploads"]) (y)es, (n)o  ? ): y
Loading local database config
Running via Spring preloader in process 92590
Loading remote database config
cap aborted!
NoMethodError: undefined method `zone' for Time:Class
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:44:in `current_time'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:48:in `output_file'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:147:in `db_dump_file_path'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:130:in `clean_dump_if_needed'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:214:in `ensure in remote_to_local'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:214:in `remote_to_local'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/dbtasks.rb:109:in `block (4 levels) in <top (required)>'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
NoMethodError: undefined method `zone' for Time:Class
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:44:in `current_time'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:48:in `output_file'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:147:in `db_dump_file_path'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:120:in `dump'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:212:in `remote_to_local'
/Users/me/Documents/GitHub/capistrano-db-tasks/lib/capistrano-db-tasks/dbtasks.rb:109:in `block (4 levels) in <top (required)>'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/me/.rvm/gems/ruby-2.3.1@front-porch-2016-website/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => app:pull => app:local:sync

Happening in both master HEAD (07290e0) and the published 0.5 version of capistrano-db-tasks.

versions:

  • ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
  • Rails 5.0.0.1
  • Capistrano Version: 3.6.1 (Rake Version: 11.3.0)

Anonymize database dumps

In my opinion there should be some options/DSL that will provide ability to anonymize production database and import data into the development machine with already anonymous data. For example, all the emails, phones and passwords should be anonymized, because they may be harmful or even stolen from the dev's computer.

I can implement it, but lets discuss the best practice approach.

undefined method `zone' for Time:Class

I'm getting this error with the setup suggested in capistrano-db-tasks;

NoMethodError: undefined method `zone' for Time:Class
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:44:in `c
urrent_time'                                                                          
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:48:in `o
utput_file'                                                                           
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:147:in `
db_dump_file_path'                                                                    
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:130:in `
clean_dump_if_needed'                                                                 
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:214:in `
ensure in remote_to_local'                                                            
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:214:in `
remote_to_local'                                                                      
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/dbtasks.rb:41:in `bl
ock (4 levels) in <top (required)>'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `instance_exec'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `run'                                                           
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/runne
rs/parallel.rb:12:in `block (2 levels) in execute'                                    
NoMethodError: undefined method `zone' for Time:Class
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:44:in `c
urrent_time'                                                                          
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:48:in `o
utput_file'                                                                           
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:147:in `
db_dump_file_path'                                                                    
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:120:in `
dump'                                                                                 
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:212:in `
remote_to_local'                                                                      
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/dbtasks.rb:41:in `bl
ock (4 levels) in <top (required)>'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `instance_exec'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `run'     
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/runne
rs/parallel.rb:12:in `block (2 levels) in execute'                                    
Tasks: TOP => db:pull => db:local:sync

I had to add the following to my deploy.rb.
require "active_support/all"

This should be added to the readme or something as without this line it cannot find 'zone'.

Empty dump file

My db:pull seems to be completing correctly, but the dump file is empty. Trace below:

INFO [2c0b7433] Running /usr/bin/env mkdir -p /var/www/ilf-cms/rvm1scripts/ as deploy@ilf-web1
INFO [2c0b7433] Finished in 0.241 seconds with exit status 0 (successful).
INFO Uploading /Users/andrew/.rvm/gems/ruby-2.3.0/gems/rvm1-capistrano3-1.4.0/script/rvm-auto.sh 100.0%
INFO [ec8db92c] Running /usr/bin/env chmod +x /var/www/ilf-cms/rvm1scripts/rvm-auto.sh as deploy@ilf-web1
INFO [ec8db92c] Finished in 0.224 seconds with exit status 0 (successful).
local {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "username"=>"andrew", "pool"=>5, "timeout"=>5000, "port"=>5432, "database"=>"ilfcms_development"}
Local database: ilfcms_development
Please enter answer (Are you sure you want to erase your local database with server database (y)es, (n)o  ? ): y
local {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "username"=>"andrew", "pool"=>5, "timeout"=>5000, "port"=>5432, "database"=>"ilfcms_development"}
INFO [61b37d37] Running /usr/bin/env cd /var/www/ilf-cms/current &&  pg_dump --no-acl --no-owner   | bzip2 - - > db/_2016-02-11-100826.sql.bz2 as deploy@ilf-web1
INFO [61b37d37] Finished in 0.242 seconds with exit status 0 (successful).
INFO Downloading db/_2016-02-11-100826.sql.bz2 100.0%
INFO leaving /var/www/ilf-cms/current/db/_2016-02-11-100826.sql.bz2 on the server (add "set :db_remote_clean, true" to deploy.rb to remove)
INFO executing local: bunzip2 -f db/_2016-02-11-100826.sql.bz2 &&  psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'ilfcms_development' AND pid <> pg_backend_pid();;"  -U andrew  -h localhost  -p 5432 ;  dropdb  -U andrew  -h localhost  -p 5432  ilfcms_development;  createdb  -U andrew  -h localhost  -p 5432  ilfcms_development;  psql  -U andrew  -h localhost  -p 5432  -d ilfcms_development < db/_2016-02-11-100826.sql
 pg_terminate_backend
----------------------
(0 rows)

INFO leaving db/_2016-02-11-100826.sql (specify :db_local_clean in deploy.rb to remove)
INFO Completed database import

SSHKit::Runner::ExecuteError "rails exit status: 127" in versions 0.5 and 0.6

I recently upgraded from 0.4 to 0.6 and cap production db:pull no longer works. The problem seems to be in the code from PR #70 (it occurs in both 0.5 and 0.6, but 0.4 works fine) capistrano-db-tasks-0.6/lib/capistrano-db-tasks/database.rb:111 when its trying to execute this command on the remote side:

bundle exec rails runner "puts '__CAPISTRANODB_CONFIG_BEGIN_FLAG__' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '__CAPISTRANODB_CONFIG_END_FLAG__'" 2>/dev/null

I get an error:

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host abcsite.com: rails exit status: 127
rails stdout: Nothing written
rails stderr: Nothing written
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/command.rb:100:in `exit_status='
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:151:in `execute_command'
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:60:in `capture'
/Users/steven/.rvm/gems/ruby-2.3.1@diet/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:111:in `block (2 levels) in initialize'

My server is running RVM and (obviously) bundler, so I think it may be some kind of path or shell config problem, but I really don't know where to start.

I've checked my deploy.rb and everything is set like the README requests. I used to have the gem inside a group :development block, but I tried moving it out of that block so it would be present in all environments, but that didn't help:

# from Gemfile
group :development do
  gem 'capistrano',         require: false
  gem 'capistrano-rvm',     require: false
  gem 'capistrano-rails',   require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano3-puma',   require: false
end

gem "capistrano-db-tasks", '0.5', require: false

If I ssh into the server and directly run that command (preceding it with RAILS_ENV=production), it works and produces the following output

deploy@dabc1:~/apps/abc/current$ RAILS_ENV=production bundle exec rails runner "puts '__CAPISTRANODB_CONFIG_BEGIN_FLAG__' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '__CAPISTRANODB_CONFIG_END_FLAG__'"
__CAPISTRANODB_CONFIG_BEGIN_FLAG__---
:adapter: postgresql
:encoding: unicode
:pool: 5
:database: abc_production
:username: deploy
:password: ...pwdhere...
__CAPISTRANODB_CONFIG_END_FLAG__

My setup has ENV variables like DB password in a .sh file that gets loaded when an interactive shell loads.

Is anyone else having this problem? Any suggestions?

Here is a full trace (I added some puts to netssh.rb to I could see what command was failing).

steven$ cap production db:pull --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke rvm:hook (first_time)
** Execute rvm:hook
***************************
[ -d ~/.rvm ]
***************************
** Invoke rvm:check (first_time)
** Execute rvm:check
***************************
~/.rvm/bin/rvm version
***************************
rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
***************************
~/.rvm/bin/rvm current
***************************
ruby-2.3.1
***************************
~/.rvm/bin/rvm default do ruby --version
***************************
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
** Invoke db:pull (first_time)
** Invoke db:local:sync (first_time)
** Execute db:local:sync
00:00 db:local:sync
      Loading local database config
Local database: abc_development
Please enter answer (Are you sure you want to erase your local database with server database (y)es, (n)o  ? ): y
      Loading local database config
      Loading remote database config
***************************
if test ! -d /home/deploy/apps/abc/current; then echo "Directory does not exist '/home/deploy/apps/abc/current'" 1>&2; false; fi
***************************
***************************
bundle exec rails runner "puts '__CAPISTRANODB_CONFIG_BEGIN_FLAG__' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '__CAPISTRANODB_CONFIG_END_FLAG__'" 2>/dev/null
***************************
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host abcsite.com: rails exit status: 127
rails stdout: Nothing written
rails stderr: Nothing written
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
SSHKit::Command::Failed: rails exit status: 127
rails stdout: Nothing written
rails stderr: Nothing written
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/command.rb:100:in `exit_status='
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:151:in `execute_command'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:60:in `capture'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:111:in `block (2 levels) in initialize'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:93:in `with'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:110:in `block in initialize'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:85:in `within'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:109:in `initialize'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:203:in `new'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/database.rb:203:in `remote_to_local'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/capistrano-db-tasks-0.5/lib/capistrano-db-tasks/dbtasks.rb:41:in `block (4 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/steven/.rvm/gems/ruby-2.3.1@abc/gems/sshkit-1.11.5/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => db:pull => db:local:sync

Not using :default_env options

I've setting env PATH in the :default_env to point my pgsql binaries. The pg_dump command is executing on the server without these configs so pg_dump is not found. Can I workaround these in local without do any changes to my server configuration ?

db:push fails silently

I've pushed my db up using "cap staging db:push" to the staging server, and all the commands look as if they're succeeding, but it seems like it's failing silently, somewhere. When I run a rails console or go to the staging site, the data isn't uploaded. I also restarted the web service to see if that helped, but it did not. Any ideas? Here's the feedback I get when I run "cap staging db:push". Anything wrong here?

local {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"example_website_development", "host"=>"localhost", "pool"=>5, "min_messages"=>"WARNING", "username"=>"MyLocalUsername"}
INFO Uploading db/example_website_development_2015-03-24-170745.sql.bz2 61.86%
INFO Uploading db/example_website_development_2015-03-24-170745.sql.bz2 100.0%
INFO [5482fc3a] Running /usr/bin/env cd /home/example_website/public_html/examplewebsite.hostname.com/current && bunzip2 -f db/example_website_development_2015-03-24-170745.sql.bz2 && RAILS_ENV=staging && PGPASSWORD='databasepassword' psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'example_website_staging' AND pid <> pg_backend_pid();;"  -U example_website ; PGPASSWORD='databasepassword' dropdb  -U example_website  example_website_staging; PGPASSWORD='databasepassword' createdb  -U example_website  example_website_staging; PGPASSWORD='databasepassword' psql  -U example_website  -d example_website_staging < db/example_website_development_2015-03-24-170745.sql as [email protected]
INFO [5482fc3a] Finished in 5.441 seconds with exit status 0 (successful).
INFO [d5236471] Running /usr/bin/env cd /home/example_website/public_html/examplewebsite.hostname.com/current && rm db/example_website_development_2015-03-24-170745.sql as [email protected]
INFO [d5236471] Finished in 0.106 seconds with exit status 0 (successful).

GZip instead of BZip2

Is there any reason why BZip2 is used without option to change compression? We use this gem heavily for larger databases and GZip would be much better option, because it compresses much faster.

db:pull fails in Postgres if database with same name as current user does not exist

The workaround for this is fairly simple, but it's an issue nonetheless. If my local Postgres instance does not have a database with the same name as my current user, the db:pull command fails. See below:

INFO [01d8d37e] Running /usr/bin/env mkdir -p /var/www/ilf-cms/rvm1scripts/ as deploy@ilf-web1
INFO [01d8d37e] Finished in 0.219 seconds with exit status 0 (successful).
INFO Uploading /Users/andrew/.rvm/gems/ruby-2.3.0/gems/rvm1-capistrano3-1.4.0/script/rvm-auto.sh 100.0%
INFO [4efcaa1e] Running /usr/bin/env chmod +x /var/www/ilf-cms/rvm1scripts/rvm-auto.sh as deploy@ilf-web1
INFO [4efcaa1e] Finished in 0.213 seconds with exit status 0 (successful).
local {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "username"=>"andrew", "pool"=>5, "timeout"=>5000, "port"=>5432, "database"=>"ilfcms_development"}
Local database: ilfcms_development
Please enter answer (Are you sure you want to erase your local database with server database (y)es, (n)o  ? ): y
local {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "username"=>"andrew", "pool"=>5, "timeout"=>5000, "port"=>5432, "database"=>"ilfcms_development"}
INFO [cd624fcb] Running /usr/bin/env cd /var/www/ilf-cms/current &&  pg_dump --no-acl --no-owner   | bzip2 - - > db/_2016-02-11-101218.sql.bz2 as deploy@ilf-web1
INFO [cd624fcb] Finished in 0.240 seconds with exit status 0 (successful).
INFO Downloading db/_2016-02-11-101218.sql.bz2 100.0%
INFO leaving /var/www/ilf-cms/current/db/_2016-02-11-101218.sql.bz2 on the server (add "set :db_remote_clean, true" to deploy.rb to remove)
INFO executing local: bunzip2 -f db/_2016-02-11-101218.sql.bz2 &&  psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'ilfcms_development' AND pid <> pg_backend_pid();;"  -U andrew  -h localhost  -p 5432 ;  dropdb  -U andrew  -h localhost  -p 5432  ilfcms_development;  createdb  -U andrew  -h localhost  -p 5432  ilfcms_development;  psql  -U andrew  -h localhost  -p 5432  -d ilfcms_development < db/_2016-02-11-101218.sql
psql: FATAL:  database "andrew" does not exist
INFO leaving db/_2016-02-11-101218.sql (specify :db_local_clean in deploy.rb to remove)
INFO Completed database import

Net::SCP::Error: SCP No such file or directory

When I run capistrano-db-tasks using capistrano 3.7.0 to pull my database with 'cap production db:pull --trace' I get the following error;

Net::SCP::Error: SCP did not finish successfully (1): scp: ./db/vinocellar_production_2
016-12-14-104356.sql.bz2: No such file or directory                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-scp-1.2.1/lib/net/scp.rb:3
65:in `block (3 levels) in start_command'                                             
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/channel.rb:607:in `call'                                                       
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/channel.rb:607:in `do_close'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:614:in `channel_close'                                              
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:479:in `dispatch_incoming_packets'                                  
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:225:in `preprocess'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:206:in `process'                                                    
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:170:in `block in loop'                                              
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:170:in `loop'                                                       
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/session.rb:170:in `loop'                                                       
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/conn
ection/channel.rb:269:in `wait'                                                       
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/net-scp-1.2.1/lib/net/scp.rb:3
21:in `download!'                                                                     
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/netssh.rb:57:in `block in download!'                                              
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/connection_pool.rb:61:in `with'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/netssh.rb:155:in `with_ssh'                                                       
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/netssh.rb:56:in `download!'                                                       
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:125:in `
download'                                                                             
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:212:in `
remote_to_local'                                                                      
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/dbtasks.rb:41:in `bl
ock (4 levels) in <top (required)>'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `instance_exec'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `run'                                                           
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/runne
rs/parallel.rb:12:in `block (2 levels) in execute'                                    
Tasks: TOP => db:pull => db:local:sync

The work around is to set my db_dump_dir to "/tmp" instead of "./db" as it cannot find this. I would assume that this ./db directory should be relative to my Rails.root path on the production server but it doesn't seem to be working.

Support for non Rails applications?

I like the idea how this library works and would like to use it for my (php) applications.
However it seems primary focussed for Rail applications which I have no experience with. How could I make the sync tasks work for any other kind of application?

db:fetch

Most of the time I want to fetch the production db, without overwriting my local db.

So I written a small task todo so:

namespace :db do
  desc 'Fetches remote database and stores it.
  task :fetch do
    on roles(:db) do
      remote_db = Database::Remote.new(self)

      begin
        remote_db.dump.download
      ensure
        remote_db.clean_dump_if_needed
      end
    end
  end
end

Allow to specify 'postgres' user password

My app database user is restricted user that can not drop or create databases, so db:push fails, because it tries to drop database on behalf of restricted user. I really don't want to change permissions for app database user, so I see two ways how to resolve it:

  1. Allow to pass password for 'postgres' user, so dabatase create/drop will be run on behalf of 'postgres' user.
  2. Truncate tables instead of database drop/create. I don't prefer it, because it's a bit tricky thing on Postgresql.

Any ideas?

DB:pull 127 error

Postgres datebase.

When
gem 'capistrano-db-tasks', '0.6', require: false

cap production db:pull error

rails exit status: 127
rails stdout: Nothing written
rails stderr: Nothing written

when
gem 'capistrano-db-tasks', '0.4', require: false

it`s work fine.

cap staging db:push fails because of psql syntax(pid column not exists)

first, the log

INFO [5b7228a5] Running /usr/bin/env cd /home/deployer/apps/artoflife/current && bunzip2 -f db/artoflife_development_2014-04-24-200512.sql.bz2 && RAILS_ENV=production && PGPASSWORD='deployer123./' psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'artoflife_production' AND pid <> pg_backend_pid();;"  -U deployer  -h localhost; PGPASSWORD='deployer123./' dropdb  -U deployer  -h localhost artoflife_production; PGPASSWORD='deployer123./' createdb  -U deployer  -h localhost artoflife_production; PGPASSWORD='deployer123./' psql  -U deployer  -h localhost -d artoflife_production < db/artoflife_development_2014-04-24-200512.sql on 198.199.95.61
DEBUG [5b7228a5] Command: cd /home/deployer/apps/artoflife/current && bunzip2 -f db/artoflife_development_2014-04-24-200512.sql.bz2 && RAILS_ENV=production && PGPASSWORD='deployer123./' psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'artoflife_production' AND pid <> pg_backend_pid();;"  -U deployer  -h localhost; PGPASSWORD='deployer123./' dropdb  -U deployer  -h localhost artoflife_production; PGPASSWORD='deployer123./' createdb  -U deployer  -h localhost artoflife_production; PGPASSWORD='deployer123./' psql  -U deployer  -h localhost -d artoflife_production < db/artoflife_development_2014-04-24-200512.sql
DEBUG [5b7228a5]    psql: FATAL:  database "deployer" does not exist
DEBUG [5b7228a5]    SET
DEBUG [5b7228a5]    psql: FATAL:  database "deployer" does not exist
DEBUG [5b7228a5]    SET
DEBUG [5b7228a5]    ERROR:  unrecognized configuration parameter "lock_timeout"
DEBUG [5b7228a5]    SET
DEBUG [5b7228a5]    ERROR:  unrecognized configuration parameter "lock_timeout"
DEBUG [5b7228a5]    SET
DEBUG [5b7228a5]    ERROR:  unrecognized configuration parameter "lock_timeout"

i've tried to login as same user, copy these commands to psql console,
for this line: SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'artoflife_production' AND pid <> pg_backend_pid();;
i got this error,

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity;
ERROR:  column pg_stat_activity.pid does not exist
LINE 1: SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_st...```

i checked there is no pid in pg_stat_activity view, my postgres version is 9.1, it's procpid. on 9.3 doc, it's pid.

so why we need to terminate the connection before we import the data, we don't even need to dropdb, because we can dump the data with -c(clean flag).

thanks !

postgres password and import errors

  1. pg_dump fails because no password
    this fork bigfive/capistrano-db-tasks works well but i got

  2. on import errors
    ERROR: role "postgres" does not exist
    ERROR: role "postgres" does not exist
    GRANT

cap production assets:pull does not read user from Capistrano configuration.

gem attempts the connection
opening connection using: ssh -p 22 -l [SERVER IP ADDRESS] rsync --server --sender -vvlLogDtpre.iLs . /home/deploy/apps/brahma_demo/current/system
However I have declared in capistrano configuration
set :user, 'deploy'
In ssh command, user 'deploy' should go after -l switch...
Thanks in advance

typo in the assets documentation: local_assets_dir

According to the asset.rb where you have:

system("rsync -a --del -L -K -vv --progress --rsh='ssh -p #{port}' ./#{dir} #{user}@#{server}:#{cap.current_path}/#{cap.fetch(:local_assets_dir)}")

The variable local_assets_direxpects a string, not an array like in the docs:

set :local_assets_dir, %w(public/assets public/att)

Please fix it.

db:pull without providing ENV password and username?

In database.yml on my production server I define my database keys like this:

production:
  database: awesome_app_production
  pool: 25
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>

And when pulling the database to my local environment I need to do this:

$ cap production db:pull DATABASE_USERNAME=my_username DATABASE_PASSWORD=my_password

Is there a way of letting capistrano-db-tasks to automatically pull the information from the .rbenv-vars located in the shared folder on the production folder? That is where I enter database credentials and environment variables since I'm using rbenv-vars.

It would be nice to be able to only run cap production db:pull

cap assets:push syncs files to current, replaces shared symlink

When using cap assets:push, my assets are getting synced to my server into current, not shared.

current/public/uploads/ is a symlink to shared/public/uploads/, but when I cap assets:push, it overwrites the symlink and syncs the folder directly in current.

My deploy.rb settings look like:
set :assets_dir, %w(public/assets/uploads)

NoMethodError: undefined method `info' for main:Object

$ cap --backtrace production app:pull
[Deprecation Warning] git_strategy is deprecated and will be removed in Capistrano 3.7.0.
https://github.com/capistrano/capistrano/blob/master/UPGRADING-3.7.md
rvm 1.26.11 (latest) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/]
ruby-2.0.0-p643
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
cap aborted!
NoMethodError: undefined method info' for main:Object /home/vagrant/.rvm/gems/ruby-2.0.0-p643/bundler/gems/capistrano-db-tasks-5da36172e9c3/lib/capistrano-db-tasks/database.rb:158:in initialize'
/home/vagrant/.rvm/gems/ruby-2.0.0-p643/bundler/gems/capistrano-db-tasks-5da36172e9c3/lib/capistrano-db-tasks/dbtasks.rb:105:in new' /home/vagrant/.rvm/gems/ruby-2.0.0-p643/bundler/gems/capistrano-db-tasks-5da36172e9c3/lib/capistrano-db-tasks/dbtasks.rb:105:in block (3 levels) in <top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/rake-11.3.0/lib/rake/task.rb:248:in call' /home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/rake-11.3.0/lib/rake/task.rb:248:in block in execute'
/home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/rake-11.3.0/lib/rake/task.rb:243:in each' /home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/rake-11.3.0/lib/rake/task.rb:243:in execute'
/home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/airbrussh-1.1.1/lib/airbrussh/rake/context.rb:62:in `execute'

Rails 4
Capistrano 3.6.1
Capistrano DB Tasks - Master branch (Tried 0.5 too)

A relative `deploy_to` isnt supported. Bug?

Hi, My deploy_to is at ~ on my machine and this isnt supported. I get the error talked about at http://stackoverflow.com/a/9669507/1520364 . I am not sure if this is a bug at your end or net-scp or sshkit.

The exact error i get is
*** Net::SCP::Error Exception: SCP did not finish successfully (1): scp: ~/<app>/current/db/<db>_2014-05-24-150321.sql.bz2: No such file or directory

It works if i prepend the /home/<user>/ to it in debugger. Is this an option that needs to be supplied to net scp by u? or sshkit?

Speed improvements (db:pull/db:push)

You can use bzcat instead of uncompressing the file, it will be faster (as will not require 2 steps and hd writes).

The command will look like: "bzcat dumpfile.bz2 | mysql -p -u user..."

undefined method `strftime' for "20161214104743":String

When using capistrano-db-tasks with capistrano 3.7.0 on a ruby 2.2.5, with rails 3.0 I get the following error;

NoMethodError: undefined method `strftime' for "20161214104743":String

/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:45:in `c
urrent_time'                                                                          
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:49:in `o
utput_file'                                                                           
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:148:in `
db_dump_file_path'                                                                    
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:131:in `
clean_dump_if_needed'                                                                 
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:215:in `
ensure in remote_to_local'                                                            
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:215:in `
remote_to_local'                                                                      
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/dbtasks.rb:41:in `bl
ock (4 levels) in <top (required)>'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `instance_exec'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `run'                                                           
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/runne
rs/parallel.rb:12:in `block (2 levels) in execute'                                    
NoMethodError: undefined method `strftime' for "20161214104743":String
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:45:in `c
urrent_time'                                                                          
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:49:in `o
utput_file'                                                                           
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:148:in `
db_dump_file_path'                                                                    
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:121:in `
dump'                                                                                 
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/database.rb:213:in `
remote_to_local'                                                                      
/home/map7/code/capistrano-db-tasks-master/lib/capistrano-db-tasks/dbtasks.rb:41:in `bl
ock (4 levels) in <top (required)>'                                                   
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `instance_exec'                                                 
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/backe
nds/abstract.rb:29:in `run'                                                           
/usr/local/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.11.4/lib/sshkit/runne
rs/parallel.rb:12:in `block (2 levels) in execute'                                    
Tasks: TOP => db:pull => db:local:sync

To get around this error I had to change the code in database.rb to

    def current_time
      Time.zone.now.to_datetime.strftime("%Y-%m-%d-%H%M%S")
    end

If this gem is required, and `rails_env` is not specified, it defaults it to `production`. This breaks `cap staging XXX` silently..

Capistrano 3 doesnt require us to set rails_env, so I havent set it. However on requiring this gem, it auto sets that to production. Thus deploying to staging is now broken. This is handled by setting rails_env as specified in the todo.. but this should just not happen.. Silently breaking capistrano even when not explicitly using the db tasks.. is evil...

Wasted a lot of time before we spotted the dark blue RAILS_ENV=production over the black background of the terminal..

Create new DB if one doesn't exist

It looks like you started this and commented it out.

It would be ideal if this created it via mysqladmin and not with rails/rake tasks, as I'm also using the tasks with PHP projects as well.

Synchronize your local database using local file

Given I have already pull my production db, and I only want to replace my local db using the dump file which is remaining in my db/ folder.

We should be able to do something like the following:

$ cap db:local:load

pull sequences as part of db:pull task

I'm wondering if there is anyway of pulling the sequences as part of the bundle exec cap production db:pull? Right now it's only pulling the schema and the rows on the tables.

SSH Port from :ssh_options not being used

It is not detecting the SSH port properly. It is trying to use port 22 instead of the one I have set in:

## Global SSH Options
set :ssh_options, {
  forward_agent: true,
  port: 1022,
  keepalive: true,
  keepalive_interval: 60, #seconds - prevents idle timeouts on long tasks
}

I asked about this in #capistrano IRC, but no one appeared to be awake :)

... also, shouldn't it try to find the :primary server? or not?

NoMethodError: undefined method `[]' for nil:NilClass

This commit from @numbata introduced a new syntax for getting the remote login data: 8808d0f

I have two projects that use this gem, updated both on the same day, same server environment (ruby 2.3.0), same server, etc...

One of the projects works fine.

The second project throws an error saying:

NoMethodError: undefined method `[]' for nil:NilClass
capistrano-db-tasks/lib/capistrano-db-tasks/database.rb:115:in `block (2 levels) in initialize'

If a put a breakpoint on that line and inspect the content of dirty_config_content, I see:

"Usage:\r\n  rails new APP_PATH [options]\r\n\r\nOptions:\r\n  -r, [--ruby=PATH]                                      # Path to the Ruby binary of your choice\r\n                                                         # Default: ~/.rbenv/versions/2.3.0/bin/ruby\r\n  -m, [--template=TEMPLATE]                              # Path to some application template (can be a filesystem path or URL)\r\n      [--skip-gemfile], [--no-skip-gemfile]              # Don't create a Gemfile\r\n  -B, [--skip-bundle], [--no-skip-bundle]                # Don't run bundle install\r\n  -G, [--skip-git], [--no-skip-git]                      # Skip .gitignore file\r\n      [--skip-keeps], [--no-skip-keeps]                  # Skip source control .keep files\r\n  -O, [--skip-active-record], [--no-skip-active-record]  # Skip Active Record files\r\n  -S, [--skip-sprockets], [--no-skip-sprockets]          # Skip Sprockets files\r\n      [--skip-spring], [--no-skip-spring]                # Don't install Spring application preloader\r\n  -d, [--database=DATABASE]                              # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)\r\n                                                         # Default: sqlite3\r\n  -j, [--javascript=JAVASCRIPT]                          # Preconfigure for selected JavaScript library\r\n                                                         # Default: jquery\r\n  -J, [--skip-javascript], [--no-skip-javascript]        # Skip JavaScript files\r\n      [--dev], [--no-dev]                                # Setup the application with Gemfile pointing to your Rails checkout\r\n      [--edge], [--no-edge]                              # Setup the application with Gemfile pointing to Rails repository\r\n      [--skip-turbolinks], [--no-skip-turbolinks]        # Skip turbolinks gem\r\n  -T, [--skip-test-unit], [--no-skip-test-unit]          # Skip Test::Unit files\r\n      [--rc=RC]                                          # Path to file containing extra configuration options for rails command\r\n      [--no-rc], [--no-no-rc]                            # Skip loading of extra configuration options from .railsrc file\r\n\r\nRuntime options:\r\n  -f, [--force]                    # Overwrite files that already exist\r\n  -p, [--pretend], [--no-pretend]  # Run but do not make any changes\r\n  -q, [--quiet], [--no-quiet]      # Suppress status output\r\n  -s, [--skip], [--no-skip]        # Skip files that already exist\r\n\r\nRails options:\r\n  -h, [--help], [--no-help]        # Show this help message and quit\r\n  -v, [--version], [--no-version]  # Show Rails version number and quit\r\n\r\nDescription:\r\n    The 'rails new' command creates a new Rails application with a default\r\n    directory structure and configuration at the path you specify.\r\n\r\n    You can specify extra command-line arguments to be used every time\r\n    'rails new' runs in the .railsrc configuration file in your home directory.\r\n\r\n    Note that the arguments specified in the .railsrc file don't affect the\r\n    defaults values shown above in this help message.\r\n\r\nExample:\r\n    rails new ~/Code/Ruby/weblog\r\n\r\n    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.\r\n    See the README in the newly created application to get going."

If I put the same breakpoint in and output the contents of that variable in my other project, i can see there's a line with the following syntax at the beginning:

__CAPISTRANODB_CONFIG_BEGIN_FLAG__---\r\n:adapter: mysql2\r\n:encoding: utf8\r\n:username: MYSQLUSERNAME\r\n:password: PASSWORD\r\n:database: DATABASE_NAME\r\n:host: DATABASE_HOST\r\n:flags: 2\r\n__CAPISTRANODB_CONFIG_END_FLAG__\r\n

If I take the old syntax from the commit above and put that in my console where I've got the breakpoint, I get:

"development:\r\n  adapter: mysql2\r\n  encoding: utf8\r\n  database: DATABASE\r\n  username: USERNAME\r\n  password: PASSWORD\r\n\r\n# Warning: The database defined as \"test\" will be erased and\r\n# re-generated from your development database when you run \"rake\".\r\n# Do not set this db to the same as development or production.\r\ntest:\r\n  adapter: mysql2\r\n  encoding: utf8\r\n  database: DATABASE\r\n  username: USERNAME\r\n  password: PASSWORD\r\n\r\nstaging:\r\n  adapter: mysql2\r\n  encoding: utf8\r\n  database: DATABASE\r\n  username: USERNAME\r\n  password: PASSWORD\r\n\r\nproduction:\r\n  adapter: mysql2\r\n  encoding: utf8\r\n database: DATABASE\r\n  username: USERNAME\r\n  password: PASSWORD\r\n  host: DATABASE_HOST"

And the next line from the old code appears to properly set the @config var:

 @config = YAML.load(ERB.new(@config).result)[@cap.fetch(:rails_env).to_s]
{"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"DATABASE", "username"=>"USERNAME", "password"=>"PASSWORD", "host"=>DATABASE_HOST"}

I can't really explain why, but I can definitely say that this new syntax is causing a really weird error using the latest version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.