dbmanager 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjcwZmJiMTE4YzU4Nzk1NDhlZGYxZTQ1MWI3MjgxMDRmOWFiZjIxNQ==
4
+ ZmIwZTE5NjE4OWNlYmYyZDQwMmVmN2IyMzRjN2U2Y2E3MzgwMmM3Yg==
5
5
  data.tar.gz: !binary |-
6
- ODUxYzM5NGZlZWU0NDQ0OGQ5ZWM3ZWQzODFlYzc2OGFhOGZjZDg0Mw==
6
+ YTQxYWZjNzQzMzEzODQ0M2I2YTZhNDczNzI5ZTE0YjM0OTVmMGU4OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjZmMDhkZjliMjZiOTQwMGQwZTBmYzY5YjRkNDY3NDA1ZDBhMzI1ZmVmMDM3
10
- NzU2ZWZjYmQ4MGZiZjAwYzUyNWFiNWE4OGU1MzY1MzNiMzgxYjgwMTIxMGM3
11
- YzkxNmRhM2ZkZWIzOGMwNGM4YzcyZTUwMDNkNjdiMTgxZDYwZjc=
9
+ NjQwYjZlYzQwNjNhYmY3ZDIzMDI1Mzk2NDgzMmM0ODk4ZTBlYTdhYTZiNTNj
10
+ NzAzYjNlYzE0ZjQ4ZmQ5OTQ1MzJmMTIxNzAxYzIzYmQxODkxYjFjNDZkNDkw
11
+ MTAzZjk5NWM4YmU4MDBiNDQxY2EzMjY3NjRhNmQxMjI2ZGFlY2U=
12
12
  data.tar.gz: !binary |-
13
- Y2JhODRmNWQ0OTU3MTZkNGJiNmVlNWQ1MjkyNWJiYTMxNTVhZDc3Y2VlNzJj
14
- OGJmYzI2YjkxNjZjMzMzMmY5YWVlNGExNWRmZGQ5Mzc0N2QzZGQ5MmU0MzFl
15
- YWIyZDc5NDYxOTdhOTVmMmM2MTRjYThmMTQ1MzQ2ZjNkZTNmMWI=
13
+ NGMxMDZmYWNkYzdkODdiYzNlMTNjMzYzMTVlMTcyMWI1YWZmOGFjNTRjMTA0
14
+ MzE4YTljYmVkOGE5OTFkNDI3OGY3ZWY2OGVlMDJiYjUwMTQyYzE2NWRlMTE1
15
+ NjJjNDRjNGJhMzk4NDdhYzhiNjY4MzBmZGNlNjJmMzg1YjNjZTM=
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ coverage
@@ -1,3 +1,7 @@
1
+ ## v0.4.2
2
+
3
+ * capistrano related code fix
4
+
1
5
  ## v0.4.1
2
6
 
3
7
  * capistrano recipe bug fixes
data/README.md CHANGED
@@ -115,16 +115,30 @@ ignoretables directive:
115
115
 
116
116
  ## Capistrano Integration
117
117
 
118
- You can use DBmanager via Capistrano as well. At the moment the only available
118
+ You can use dbmanager via Capistrano as well. At the moment the only available
119
119
  task is import the remote databases into your local machine. The use is currently
120
- limited to Capistrano 2.x
120
+ limited to Capistrano 2.x.
121
121
 
122
- You can do that by running
122
+ Update deploy.rb recipe to include dbmanager recipes:
123
+
124
+ ```ruby
125
+ require 'dbmanager/capistrano'
126
+ ```
127
+
128
+ Importing the remote db to your local machine is as easy as typing:
123
129
 
124
130
  ```bash
125
131
  bundle exec cap <environment> db:import
126
132
  ```
127
133
 
134
+ For database export from your local machine to remote:
135
+
136
+ ```bash
137
+ bundle exec cap <environment> db:export
138
+ ```
139
+ This whole functionality is still very WIP, so act accordingly.
140
+
141
+
128
142
  ### Custom Capistrano configuration
129
143
 
130
144
  If you need to change some configuration option (notably overwrite database configurations from
@@ -115,16 +115,30 @@ ignoretables directive:
115
115
 
116
116
  ## Capistrano Integration
117
117
 
118
- You can use DBmanager via Capistrano as well. At the moment the only available
118
+ You can use dbmanager via Capistrano as well. At the moment the only available
119
119
  task is import the remote databases into your local machine. The use is currently
120
- limited to Capistrano 2.x
120
+ limited to Capistrano 2.x.
121
121
 
122
- You can do that by running
122
+ Update deploy.rb recipe to include dbmanager recipes:
123
+
124
+ ```ruby
125
+ require 'dbmanager/capistrano'
126
+ ```
127
+
128
+ Importing the remote db to your local machine is as easy as typing:
123
129
 
124
130
  ```bash
125
131
  bundle exec cap <environment> db:import
126
132
  ```
127
133
 
134
+ For database export from your local machine to remote:
135
+
136
+ ```bash
137
+ bundle exec cap <environment> db:export
138
+ ```
139
+ This whole functionality is still very WIP, so act accordingly.
140
+
141
+
128
142
  ### Custom Capistrano configuration
129
143
 
130
144
  If you need to change some configuration option (notably overwrite database configurations from
@@ -41,6 +41,10 @@ module Dbmanager
41
41
  "mysqldump #{ignoretables} #{set_gtid_purged_off} #{params(source)} > '#{filename}'"
42
42
  end
43
43
 
44
+ def dump_command_ssh
45
+ "mysqldump #{ignoretables} #{set_gtid_purged_off} #{params(source)}"
46
+ end
47
+
44
48
  def ignoretables
45
49
  if source.ignoretables.present?
46
50
  source.ignoretables.inject [] do |arr, table|
@@ -84,6 +88,10 @@ module Dbmanager
84
88
  "mysql #{params(target)} < '#{tmp_file}'"
85
89
  end
86
90
 
91
+ def load_command_ssh
92
+ "mysql #{params target}"
93
+ end
94
+
87
95
  def create_db_if_missing_command
88
96
  "bundle exec rake db:create RAILS_ENV=#{target.name}"
89
97
  end
@@ -23,10 +23,9 @@ Capistrano::Configuration.instance(:must_exist).load do
23
23
  dumper = Dbmanager::Adapters::Mysql::Dumper.new(dbmanager_remote_env, '/dev/stdout')
24
24
  loader = Dbmanager::Adapters::Mysql::Loader.new(dbmanager_local_env, '/dev/stdin')
25
25
  dumper.mysqldump_version = dumper.extract_version capture('mysqldump --version')
26
-
27
26
  Open3.popen3 loader.load_command do |input, output, error|
28
27
  begin
29
- run dumper.dump_command do |channel, stream, data|
28
+ run dumper.dump_command_ssh do |channel, stream, data|
30
29
  input << data if stream == :out
31
30
  raise data if stream == :err
32
31
  end
@@ -37,5 +36,21 @@ Capistrano::Configuration.instance(:must_exist).load do
37
36
  end
38
37
  end
39
38
  end
39
+
40
+ task :export do
41
+ require 'config/environment.rb'
42
+ require 'active_support/core_ext'
43
+ require 'dbmanager'
44
+
45
+ dumper = Dbmanager::Adapters::Mysql::Dumper.new(dbmanager_local_env, '')
46
+ loader = Dbmanager::Adapters::Mysql::Loader.new(dbmanager_remote_env, '')
47
+
48
+ raise Dbmanager::EnvironmentProtectedError if loader.target.protected?
49
+
50
+ address = "#{fetch :user}@#{roles[:web].first.host}"
51
+ command = "#{dumper.dump_command_ssh} | ssh #{address} '#{loader.load_command_ssh}'"
52
+ puts "executing #{command}..."
53
+ system command
54
+ end
40
55
  end
41
56
  end
@@ -1,3 +1,3 @@
1
1
  module Dbmanager
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbmanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrea longhi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails