capistrano-db-tasks 0.5 → 0.6
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -1
- data/README.md +4 -1
- data/lib/capistrano-db-tasks/database.rb +18 -14
- data/lib/capistrano-db-tasks/util.rb +1 -1
- data/lib/capistrano-db-tasks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70686927e9b1dbb60f98bfd3c862de83d6fb7a29
|
4
|
+
data.tar.gz: 42b36085956d02a87c8b3d68f8c199ad53aa6851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfbbf4e4be63dbea1b7b73f89e2f7022fd1a8d46d5be64276bce4cb29448fdff1706307562f52b0c633116a1b1c4e241bed492ffc05c37f80053a54565dbde4
|
7
|
+
data.tar.gz: 744bada441f262c52724899049b55a880008daf60caee2ac4173a04fce956edc67a14ba5479db4cc41aa381602752b6fc6fab75fdc71b5828daf889b9f27e000
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,10 +4,15 @@ Reverse Chronological Order:
|
|
4
4
|
|
5
5
|
## master
|
6
6
|
|
7
|
-
https://github.com/sgruhier/capistrano-db-tasks/compare/v0.
|
7
|
+
https://github.com/sgruhier/capistrano-db-tasks/compare/v0.6...HEAD
|
8
8
|
|
9
9
|
* Your contribution here!
|
10
10
|
|
11
|
+
# 0.6 (Dec 14 2016)
|
12
|
+
|
13
|
+
* Configurable dump folder #101 #75 #61 (@artempartos, @gmhawash)
|
14
|
+
* Fixed previous release bugs (@sitnikovme, @slavajacobson)
|
15
|
+
|
11
16
|
# 0.5 (Nov 29 2016)
|
12
17
|
|
13
18
|
* Fixed iteration on remote/local assets dir #98 (@elthariel)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CapistranoDbTasks | [](https://codeclimate.com/github/sgruhier/capistrano-db-tasks) [](http://badge.fury.io/rb/capistrano-db-tasks)
|
1
|
+
# CapistranoDbTasks | [](https://rubygems.org/gems/capistrano-db_sync)[](https://codeclimate.com/github/sgruhier/capistrano-db-tasks) [](http://badge.fury.io/rb/capistrano-db-tasks)
|
2
2
|
|
3
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
4
|
|
@@ -39,6 +39,9 @@ set :db_ignore_tables, []
|
|
39
39
|
# if you want to exclude table data (but not table schema) from dump
|
40
40
|
set :db_ignore_data_tables, []
|
41
41
|
|
42
|
+
# configure location where the dump file should be created
|
43
|
+
set :db_dump_dir, "./db"
|
44
|
+
|
42
45
|
# If you want to import assets, you can change default asset dir (default = system)
|
43
46
|
# This directory must be in your shared directory on the server
|
44
47
|
set :assets_dir, %w(public/assets public/att)
|
@@ -41,11 +41,11 @@ module Database
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def current_time
|
44
|
-
Time.
|
44
|
+
Time.now.strftime("%Y-%m-%d-%H%M%S")
|
45
45
|
end
|
46
46
|
|
47
47
|
def output_file
|
48
|
-
@output_file ||= "
|
48
|
+
@output_file ||= "#{database}_#{current_time}.sql.#{compressor.file_extension}"
|
49
49
|
end
|
50
50
|
|
51
51
|
def compressor
|
@@ -105,7 +105,7 @@ module Database
|
|
105
105
|
class Remote < Base
|
106
106
|
def initialize(cap_instance)
|
107
107
|
super(cap_instance)
|
108
|
-
|
108
|
+
puts "Loading remote database config"
|
109
109
|
@cap.within @cap.current_path do
|
110
110
|
@cap.with rails_env: @cap.fetch(:rails_env) do
|
111
111
|
dirty_config_content = @cap.capture(:rails, "runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\"", '2>/dev/null')
|
@@ -117,19 +117,19 @@ module Database
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def dump
|
120
|
-
@cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-',
|
120
|
+
@cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-', db_dump_file_path)}"
|
121
121
|
self
|
122
122
|
end
|
123
123
|
|
124
124
|
def download(local_file = "#{output_file}")
|
125
|
-
@cap.download!
|
125
|
+
@cap.download! db_dump_file_path, local_file
|
126
126
|
end
|
127
127
|
|
128
128
|
def clean_dump_if_needed
|
129
129
|
if @cap.fetch(:db_remote_clean)
|
130
|
-
@cap.execute "rm -f #{
|
130
|
+
@cap.execute "rm -f #{db_dump_file_path}"
|
131
131
|
else
|
132
|
-
|
132
|
+
puts "leaving #{db_dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -143,15 +143,19 @@ module Database
|
|
143
143
|
|
144
144
|
private
|
145
145
|
|
146
|
-
def
|
147
|
-
"#{
|
146
|
+
def db_dump_file_path
|
147
|
+
"#{db_dump_dir}/#{output_file}"
|
148
|
+
end
|
149
|
+
|
150
|
+
def db_dump_dir
|
151
|
+
@cap.fetch(:db_dump_dir) || "#{@cap.current_path}/db"
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
151
155
|
class Local < Base
|
152
156
|
def initialize(cap_instance)
|
153
157
|
super(cap_instance)
|
154
|
-
|
158
|
+
puts "Loading local database config"
|
155
159
|
command = "#{Dir.pwd}/bin/rails runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\""
|
156
160
|
stdout, status = Open3.capture2(command)
|
157
161
|
raise "Error running command (status=#{status}): #{command}" if status != 0
|
@@ -163,15 +167,15 @@ module Database
|
|
163
167
|
# cleanup = true removes the mysqldump file after loading, false leaves it in db/
|
164
168
|
def load(file, cleanup)
|
165
169
|
unzip_file = File.join(File.dirname(file), File.basename(file, ".#{compressor.file_extension}"))
|
166
|
-
|
170
|
+
puts "executing local: #{compressor.decompress(file)} && #{import_cmd(unzip_file)}"
|
167
171
|
execute("#{compressor.decompress(file)} && #{import_cmd(unzip_file)}")
|
168
172
|
if cleanup
|
169
|
-
|
173
|
+
puts "removing #{unzip_file}"
|
170
174
|
File.unlink(unzip_file)
|
171
175
|
else
|
172
|
-
|
176
|
+
puts "leaving #{unzip_file} (specify :db_local_clean in deploy.rb to remove)"
|
173
177
|
end
|
174
|
-
|
178
|
+
puts "Completed database import"
|
175
179
|
end
|
176
180
|
|
177
181
|
def dump
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-db-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Gruhier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|