capistrano-db-pull 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/capistrano-db-pull.gemspec +1 -1
- data/lib/capistrano-db-pull/database.rb +0 -3
- data/lib/capistrano/tasks/db-pull.rake +17 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdcf105840d27767bf46b07b254bed58e57f384f
|
4
|
+
data.tar.gz: 656e12861763f1a53048840ddbc9c3b6d56bafb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3dd96c264f9ccde33739b97fb7b0c265c4d145613ef096a17b58e6c04c852786f664ff2ed7101d35ca44f850d22eaed40e694ce2a6de37f03a955fab7875091
|
7
|
+
data.tar.gz: '09da85be23c9f2747045811c439ebea7cc1da5fd173eda84b2a19ce9711747d75b6f93c2e769dca8a9325cb051f8548944aadfa70ed814fe308e66dc1ac64670'
|
data/README.md
ADDED
@@ -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
|
data/capistrano-db-pull.gemspec
CHANGED
@@ -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 "#{
|
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
|
-
|
18
|
-
|
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
|
+
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:
|
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.
|
65
|
+
rubygems_version: 2.6.14
|
65
66
|
signing_key:
|
66
67
|
specification_version: 4
|
67
68
|
summary: Download remote database to local database
|