sumodev_deploy 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sumodev_deploy.rb +30 -6
- data/sumodev_deploy.gemspec +1 -1
- metadata +1 -1
data/lib/sumodev_deploy.rb
CHANGED
@@ -40,13 +40,30 @@ configuration.load do
|
|
40
40
|
|
41
41
|
desc "Dump the remote database, and outputs the content so you can pipe it"
|
42
42
|
task :dump, :roles => :db do
|
43
|
-
|
43
|
+
run "mysqldump --set-charset #{db_name}" do |ch, stream, out|
|
44
|
+
if stream == :err
|
45
|
+
ch[:options][:logger].send(:important, out, "#{stream} :: #{ch[:server]}" )
|
46
|
+
else
|
47
|
+
print out
|
48
|
+
end
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
desc "Imports the database from the server into your local database"
|
47
53
|
task :get, :roles => :db do
|
48
|
-
|
49
|
-
|
54
|
+
run_locally %{mysqladmin create #{db_name}} rescue nil
|
55
|
+
|
56
|
+
mysql = IO.popen("mysql #{db_name}", 'r+')
|
57
|
+
run "mysqldump --set-charset #{db_name}" do |ch, stream, out|
|
58
|
+
if stream == :err
|
59
|
+
ch[:options][:logger].send(:important, out, "#{stream} :: #{ch[:server]}" )
|
60
|
+
else
|
61
|
+
mysql.write out
|
62
|
+
end
|
63
|
+
end
|
64
|
+
mysql.close_write
|
65
|
+
puts mysql.read
|
66
|
+
mysql.close
|
50
67
|
end
|
51
68
|
|
52
69
|
desc "Get database info"
|
@@ -55,9 +72,16 @@ configuration.load do
|
|
55
72
|
end
|
56
73
|
|
57
74
|
desc "Imports the database from your local server to the remote one"
|
58
|
-
task :put, :roles => :db do
|
59
|
-
|
60
|
-
|
75
|
+
task :put, :roles => :db, :only => {:primary => true} do
|
76
|
+
run "mysqldump --set-charset #{db_name} > #{current_path}/#{release_name}.sql" rescue nil
|
77
|
+
|
78
|
+
dump = StringIO.new(run_locally "mysqldump --set-charset #{db_name}")
|
79
|
+
dump_path = "#{shared_path}/db_upload.tmp.sql"
|
80
|
+
upload dump, dump_path
|
81
|
+
run %{
|
82
|
+
mysql #{db_name} < #{dump_path} &&
|
83
|
+
rm #{dump_path}
|
84
|
+
}
|
61
85
|
end
|
62
86
|
end
|
63
87
|
|
data/sumodev_deploy.gemspec
CHANGED