capistrano-ash 1.1.10 → 1.1.11
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.
- data/VERSION +1 -1
- data/lib/ash/base.rb +93 -0
- metadata +2 -2
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.11
|
data/lib/ash/base.rb
CHANGED
|
@@ -69,6 +69,21 @@ configuration.load do
|
|
|
69
69
|
# show password requests on windows
|
|
70
70
|
# (http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1)
|
|
71
71
|
default_run_options[:pty] = true
|
|
72
|
+
|
|
73
|
+
# Database migration settings
|
|
74
|
+
set :db_local_host, "192.168.16.116"
|
|
75
|
+
set :db_local_user, "developer"
|
|
76
|
+
set :db_local_name, proc{text_prompt("Local database name: #{db_local_name}: ")}
|
|
77
|
+
set :db_local_pass, proc{text_prompt("Local database password for: #{db_local_user}: ")}
|
|
78
|
+
set :db_remote_user, proc{text_prompt("Remote database user: #{db_remote_user}: ")}
|
|
79
|
+
set :db_remote_pass, proc{text_prompt("Remote database password for: #{db_remote_user}: ")}
|
|
80
|
+
set :db_remote_name, proc{text_prompt("Remote database name: #{db_remote_name}: ")}
|
|
81
|
+
set :db_remote_host, "localhost"
|
|
82
|
+
|
|
83
|
+
# Database replacement values
|
|
84
|
+
# Format: local => remote
|
|
85
|
+
set :db_regex_hash, {
|
|
86
|
+
}
|
|
72
87
|
|
|
73
88
|
# --------------------------------------------
|
|
74
89
|
# Overloaded tasks
|
|
@@ -129,7 +144,85 @@ configuration.load do
|
|
|
129
144
|
end
|
|
130
145
|
end
|
|
131
146
|
end
|
|
147
|
+
|
|
148
|
+
# --------------------------------------------
|
|
149
|
+
# Remote/Local database migration tasks
|
|
150
|
+
# --------------------------------------------
|
|
151
|
+
namespace :db do
|
|
152
|
+
desc "Migrate remote application database to local server"
|
|
153
|
+
task :to_local do
|
|
154
|
+
remote_export
|
|
155
|
+
remote_download
|
|
156
|
+
local_import
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
desc "Migrate local application database to remote server"
|
|
160
|
+
task :to_remote do
|
|
161
|
+
local_export
|
|
162
|
+
local_upload
|
|
163
|
+
remote_import
|
|
164
|
+
end
|
|
132
165
|
|
|
166
|
+
desc "Handles importing a MySQL database dump file. Uncompresses the file, does regex replacements, and imports."
|
|
167
|
+
task :local_import do
|
|
168
|
+
# check for compressed file and decompress
|
|
169
|
+
if local_file_exists?("#{db_remote_name}.sql.gz")
|
|
170
|
+
system "gunzip -f #{db_remote_name}.sql.gz"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if local_file_exists?("#{db_remote_name}.sql")
|
|
174
|
+
# run through replacements on SQL file
|
|
175
|
+
db_regex_hash.each_pair do |local, remote|
|
|
176
|
+
system "perl -pi -e 's/#{remote}/#{local}/' #{db_remote_name}.sql"
|
|
177
|
+
end
|
|
178
|
+
# import into database
|
|
179
|
+
system "mysql -h#{db_local_host} -u#{db_local_user} -p#{db_local_pass} #{db_local_name} < #{db_remote_name}.sql"
|
|
180
|
+
# remove used file
|
|
181
|
+
run "rm -f #{deploy_to}/#{db_remote_name}.sql.gz"
|
|
182
|
+
system "rm -f #{db_remote_name}.sql"
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
task :local_export do
|
|
187
|
+
system "mysqldump --opt -h#{db_local_host} -u#{db_local_user} -p#{db_local_pass} #{db_local_name} | gzip -c --best > #{db_local_name}.sql.gz"
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
desc "Upload locally created MySQL dumpfile to remote server via SCP"
|
|
191
|
+
task :local_upload do
|
|
192
|
+
upload "#{db_local_name}.sql.gz", "#{deploy_to}/#{db_local_name}.sql.gz", :via => :scp
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
desc "Handles importing a MySQL database dump file. Uncompresses the file, does regex replacements, and imports."
|
|
196
|
+
task :remote_import, :roles => :db do
|
|
197
|
+
# check for compressed file and decompress
|
|
198
|
+
if remote_file_exists?("#{deploy_to}/#{db_local_name}.sql.gz")
|
|
199
|
+
run "gunzip -f #{deploy_to}/#{db_local_name}.sql.gz"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
if remote_file_exists?("#{deploy_to}/#{db_local_name}.sql")
|
|
203
|
+
# run through replacements on SQL file
|
|
204
|
+
db_regex_hash.each_pair do |local, remote|
|
|
205
|
+
run "perl -pi -e 's/#{local}/#{remote}/' #{deploy_to}/#{db_local_name}.sql"
|
|
206
|
+
end
|
|
207
|
+
# import into database
|
|
208
|
+
run "mysql -h#{db_remote_host} -u#{db_remote_user} -p#{db_remote_pass} #{db_remote_name} < #{deploy_to}/#{db_local_name}.sql"
|
|
209
|
+
# remove used file
|
|
210
|
+
run "rm -f #{deploy_to}/#{db_local_name}.sql"
|
|
211
|
+
system "rm -rf #{db_local_name}.sql.gz"
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
desc "Create a compressed MySQL dumpfile of the remote database"
|
|
216
|
+
task :remote_export, :roles => :db do
|
|
217
|
+
run "mysqldump --opt -h#{db_remote_host} -u#{db_remote_user} -p#{db_remote_pass} #{db_remote_name} | gzip -c --best > #{deploy_to}/#{db_remote_name}.sql.gz"
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
desc "Download remotely created MySQL dumpfile to local machine via SCP"
|
|
221
|
+
task :remote_download do
|
|
222
|
+
download "#{deploy_to}/#{db_remote_name}.sql.gz", "#{db_remote_name}.sql.gz", :via => :scp
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
133
226
|
# --------------------------------------------
|
|
134
227
|
# phpMyAdmin tasks
|
|
135
228
|
# --------------------------------------------
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capistrano-ash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.11
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-
|
|
12
|
+
date: 2011-09-12 00:00:00.000000000Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: August Ash recipes for Capistrano
|
|
15
15
|
email: code@augustash.com
|