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.
@@ -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
- system %{ssh sites@#{db_server} mysqldump --set-charset #{db_name}}
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
- system %{mysqladmin create #{db_name}} # @todo Defv ignore errors
49
- system %{ssh sites@#{db_server} mysqldump --set-charset #{db_name} | mysql #{db_name}}
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
- system %{ssh sites@#{db_server} "mysqldump --set-charset #{$db_name} > #{current_path}/#{release_name}.sql" }
60
- system %{mysqldump --set-charset #{db_name} | ssh sites@#{db_server} #{db_name}}
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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sumodev_deploy"
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.authors = ["Jan De Poorter"]
8
8
  s.date = "2012-04-18"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumodev_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: