capistrano-db-pull 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2edb5bc8c4b770675c976fa59c36c63610cda82c
4
- data.tar.gz: 6ecef9aba431e6e32d342fa18a3a659df28cc340
3
+ metadata.gz: cdcf105840d27767bf46b07b254bed58e57f384f
4
+ data.tar.gz: 656e12861763f1a53048840ddbc9c3b6d56bafb4
5
5
  SHA512:
6
- metadata.gz: 7ec470d7f4c2ee050cd43abe66b4a7aaa9c5376dec256b4f8f860de9793891b1dc1a9be073ba82b3cfa2cb7a22a18776859f52761b142402828d0c0a5f9b7507
7
- data.tar.gz: 33acbfe017463e55279527c7c324b778849633f5cd9413eba61e4c71871811fa9f73bef0fe2e1f1f2bdd154aa6e62bf05db721c57e76a809241af9c7fe4806e2
6
+ metadata.gz: f3dd96c264f9ccde33739b97fb7b0c265c4d145613ef096a17b58e6c04c852786f664ff2ed7101d35ca44f850d22eaed40e694ce2a6de37f03a955fab7875091
7
+ data.tar.gz: '09da85be23c9f2747045811c439ebea7cc1da5fd173eda84b2a19ce9711747d75b6f93c2e769dca8a9325cb051f8548944aadfa70ed814fe308e66dc1ac64670'
@@ -0,0 +1,12 @@
1
+ # Capistrano DB Pull
2
+
3
+ Replace your local development database with a database pulled from the server.
4
+
5
+ ## Getting Started
6
+
7
+ * Add `gem capistrano-db-pull` to the :development group in your Gemfile
8
+ * Add `require 'capistrano/db/pull` to your Capfile
9
+
10
+ ## How To Use
11
+
12
+ * Run `cap <STAGE> db:pull`, e.g. `cap production db:pull` to pull your production database
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'capistrano-db-pull'
5
- s.version = '0.0.4'
5
+ s.version = '0.0.5'
6
6
  s.licenses = ['BSD-2-Clause']
7
7
 
8
8
  s.summary = 'Download remote database to local database'
@@ -23,9 +23,6 @@ module Database
23
23
  end
24
24
 
25
25
  class PostgreSQL < Base
26
- def dump
27
- "pg_dump --data-only --exclude-table=schema_migrations --column-inserts"
28
- end
29
26
  end
30
27
 
31
28
  class Sqlite3 < Base
@@ -1,10 +1,14 @@
1
1
  namespace :db do
2
2
  task :pull do
3
3
  remote = nil
4
+ local = Application::Local.new(self)
5
+
4
6
  on roles(:db) do
5
7
  remote = Application::Remote.new(self, fetch(:stage) || 'production')
6
- if remote.postgresql?
7
- execute "#{Database.factory(remote).dump} | gzip -9 > #{fetch(:application)}.sql.gz"
8
+ if remote.postgresql? && local.postgresql?
9
+ execute "pg_dump --no-owner #{remote.database} | gzip -9 > #{fetch(:application)}.sql.gz"
10
+ elsif remote.postgresql? && local.sqlite3?
11
+ execute "pg_dump --data-only --exclude-table=schema_migrations --column-inserts #{remote.database} | gzip -9 > #{fetch(:application)}.sql.gz"
8
12
  elsif remote.mysql?
9
13
  execute "mysqldump --skip-opt --no-create-info #{remote.database} | gzip -9 > #{fetch(:application)}.sql.gz"
10
14
  else
@@ -14,8 +18,11 @@ namespace :db do
14
18
  execute "rm #{fetch(:application)}.sql.gz"
15
19
  end
16
20
 
17
- local = Application::Local.new(self)
18
- if remote.postgresql? && local.sqlite3?
21
+ if remote.postgresql? && local.postgresql?
22
+ system 'bin/rake db:drop && bin/rake db:create'
23
+ system "gunzip -c #{fetch(:application)}.sql.gz | psql #{local.database}"
24
+ system 'bin/rails db:environment:set RAILS_ENV=development'
25
+ elsif remote.postgresql? && local.sqlite3?
19
26
  system "echo 'BEGIN;' > #{fetch(:application)}.sql"
20
27
  system "gunzip -c #{fetch(:application)}.sql.gz | sed '/^SET/ d' |\
21
28
  sed '/^SELECT pg_catalog.setval/ d' |\
@@ -26,18 +33,20 @@ namespace :db do
26
33
  sed \"s/true)/'t')/g\" |\
27
34
  sed \"s/false)/'f')/g\" >> #{fetch(:application)}.sql"
28
35
  system "echo 'END;' >> #{fetch(:application)}.sql"
36
+ system "bin/rake db:drop && bin/rake db:schema:load &&
37
+ cat #{fetch(:application)}.sql | sqlite3 db/development.sqlite3"
29
38
  elsif remote.mysql? && local.sqlite3?
30
39
  system "gunzip -c #{fetch(:application)}.sql.gz |
31
40
  sed 's/\\`//g' |
32
41
  sed \"s/\\\\\\\'/\'\'/g\" |
33
42
  sed 's/\\\"/\"/g' > #{fetch(:application)}.sql"
43
+ system "bin/rake db:drop && bin/rake db:schema:load &&
44
+ cat #{fetch(:application)}.sql | sqlite3 db/development.sqlite3"
34
45
  else
35
46
  raise "Local database adapter '#{local.adapter}' is currently unsupported"
36
47
  end
37
- system "bin/rake db:drop && bin/rake db:schema:load &&
38
- cat #{fetch(:application)}.sql | sqlite3 db/development.sqlite3"
39
48
 
40
- system "rm #{fetch(:application)}.sql"
41
- system "rm #{fetch(:application)}.sql.gz"
49
+ system "rm -f #{fetch(:application)}.sql"
50
+ system "rm -f #{fetch(:application)}.sql.gz"
42
51
  end
43
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-db-pull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Groeneveld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-28 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -35,6 +35,7 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - ".gitignore"
37
37
  - LICENSE
38
+ - README.md
38
39
  - capistrano-db-pull.gemspec
39
40
  - lib/capistrano-db-pull.rb
40
41
  - lib/capistrano-db-pull/application.rb
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  version: '0'
62
63
  requirements: []
63
64
  rubyforge_project:
64
- rubygems_version: 2.5.2
65
+ rubygems_version: 2.6.14
65
66
  signing_key:
66
67
  specification_version: 4
67
68
  summary: Download remote database to local database