dbmanager 0.4.0 → 0.4.1
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/README.md +29 -0
- data/dbmanager.gemspec +6 -1
- data/features/readme.md +29 -0
- data/lib/dbmanager.rb +1 -0
- data/lib/dbmanager/capistrano.rb +32 -25
- data/lib/dbmanager/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjcwZmJiMTE4YzU4Nzk1NDhlZGYxZTQ1MWI3MjgxMDRmOWFiZjIxNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODUxYzM5NGZlZWU0NDQ0OGQ5ZWM3ZWQzODFlYzc2OGFhOGZjZDg0Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjZmMDhkZjliMjZiOTQwMGQwZTBmYzY5YjRkNDY3NDA1ZDBhMzI1ZmVmMDM3
|
10
|
+
NzU2ZWZjYmQ4MGZiZjAwYzUyNWFiNWE4OGU1MzY1MzNiMzgxYjgwMTIxMGM3
|
11
|
+
YzkxNmRhM2ZkZWIzOGMwNGM4YzcyZTUwMDNkNjdiMTgxZDYwZjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2JhODRmNWQ0OTU3MTZkNGJiNmVlNWQ1MjkyNWJiYTMxNTVhZDc3Y2VlNzJj
|
14
|
+
OGJmYzI2YjkxNjZjMzMzMmY5YWVlNGExNWRmZGQ5Mzc0N2QzZGQ5MmU0MzFl
|
15
|
+
YWIyZDc5NDYxOTdhOTVmMmM2MTRjYThmMTQ1MzQ2ZjNkZTNmMWI=
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -113,6 +113,35 @@ ignoretables directive:
|
|
113
113
|
```
|
114
114
|
|
115
115
|
|
116
|
+
## Capistrano Integration
|
117
|
+
|
118
|
+
You can use DBmanager via Capistrano as well. At the moment the only available
|
119
|
+
task is import the remote databases into your local machine. The use is currently
|
120
|
+
limited to Capistrano 2.x
|
121
|
+
|
122
|
+
You can do that by running
|
123
|
+
|
124
|
+
```bash
|
125
|
+
bundle exec cap <environment> db:import
|
126
|
+
```
|
127
|
+
|
128
|
+
### Custom Capistrano configuration
|
129
|
+
|
130
|
+
If you need to change some configuration option (notably overwrite database configurations from
|
131
|
+
database.yml such as username, password and so on) you need to set those custom values in your
|
132
|
+
deployment recipe.
|
133
|
+
For example, if you need to set the remote database password using the remote ENV values you
|
134
|
+
should add:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
set :dbmanager_remote_env, lambda {
|
138
|
+
Dbmanager::YmlParser.environments[rails_env.to_s].tap do |env|
|
139
|
+
env.password = capture('echo $MYSQL_PASSWORD').chomp
|
140
|
+
end
|
141
|
+
}
|
142
|
+
```
|
143
|
+
|
144
|
+
|
116
145
|
## Documentation
|
117
146
|
|
118
147
|
You can find some more documentation on the workings of the gem on relish:
|
data/dbmanager.gemspec
CHANGED
@@ -19,7 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
|
22
|
+
if RUBY_VERSION.to_f > 1.8
|
23
|
+
s.add_dependency 'rails'
|
24
|
+
else
|
25
|
+
s.add_dependency 'rails', '< 4'
|
26
|
+
s.add_development_dependency 'listen', '1.3.1'
|
27
|
+
end
|
23
28
|
s.add_development_dependency 'rspec', '~> 2.12'
|
24
29
|
s.add_development_dependency 'rake'
|
25
30
|
s.add_development_dependency 'mysql2'
|
data/features/readme.md
CHANGED
@@ -113,6 +113,35 @@ ignoretables directive:
|
|
113
113
|
```
|
114
114
|
|
115
115
|
|
116
|
+
## Capistrano Integration
|
117
|
+
|
118
|
+
You can use DBmanager via Capistrano as well. At the moment the only available
|
119
|
+
task is import the remote databases into your local machine. The use is currently
|
120
|
+
limited to Capistrano 2.x
|
121
|
+
|
122
|
+
You can do that by running
|
123
|
+
|
124
|
+
```bash
|
125
|
+
bundle exec cap <environment> db:import
|
126
|
+
```
|
127
|
+
|
128
|
+
### Custom Capistrano configuration
|
129
|
+
|
130
|
+
If you need to change some configuration option (notably overwrite database configurations from
|
131
|
+
database.yml such as username, password and so on) you need to set those custom values in your
|
132
|
+
deployment recipe.
|
133
|
+
For example, if you need to set the remote database password using the remote ENV values you
|
134
|
+
should add:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
set :dbmanager_remote_env, lambda {
|
138
|
+
Dbmanager::YmlParser.environments[rails_env.to_s].tap do |env|
|
139
|
+
env.password = capture('echo $MYSQL_PASSWORD').chomp
|
140
|
+
end
|
141
|
+
}
|
142
|
+
```
|
143
|
+
|
144
|
+
|
116
145
|
## Documentation
|
117
146
|
|
118
147
|
You can find some more documentation on the workings of the gem on relish:
|
data/lib/dbmanager.rb
CHANGED
data/lib/dbmanager/capistrano.rb
CHANGED
@@ -1,34 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
|
2
|
+
raise 'Capistrano 3 is not supported yet!'
|
3
|
+
end
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
6
|
+
# Those config vars can be overridden in your recipes
|
7
|
+
# in order to customize the dbmanager settings:
|
8
|
+
_cset :dbmanager_remote_env, lambda {
|
9
|
+
Dbmanager::YmlParser.environments[rails_env.to_s]
|
10
|
+
}
|
9
11
|
|
12
|
+
_cset :dbmanager_local_env, lambda {
|
13
|
+
Dbmanager::YmlParser.environments[Rails.env]
|
14
|
+
}
|
10
15
|
|
11
|
-
namespace :db do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
namespace :db do
|
17
|
+
task :import do
|
18
|
+
require 'config/environment.rb'
|
19
|
+
require 'active_support/core_ext'
|
20
|
+
require 'dbmanager'
|
21
|
+
require 'open3'
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
dumper = Dbmanager::Adapters::Mysql::Dumper.new(dbmanager_remote_env, '/dev/stdout')
|
24
|
+
loader = Dbmanager::Adapters::Mysql::Loader.new(dbmanager_local_env, '/dev/stdin')
|
25
|
+
dumper.mysqldump_version = dumper.extract_version capture('mysqldump --version')
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
Open3.popen3 loader.load_command do |input, output, error|
|
28
|
+
begin
|
29
|
+
run dumper.dump_command do |channel, stream, data|
|
30
|
+
input << data if stream == :out
|
31
|
+
raise data if stream == :err
|
32
|
+
end
|
33
|
+
input.close
|
34
|
+
ensure
|
35
|
+
output.read.tap { |s| puts "OUT: #{s}" unless s.empty? }
|
36
|
+
error.read.tap { |s| puts "ERR: #{s}" unless s.empty? }
|
26
37
|
end
|
27
|
-
input.close
|
28
|
-
ensure
|
29
|
-
output.read.tap { |s| puts "OUT: #{s}" unless s.empty? }
|
30
|
-
error.read.tap { |s| puts "ERR: #{s}" unless s.empty? }
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
34
|
-
end
|
41
|
+
end
|
data/lib/dbmanager/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|