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 +8 -8
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +17 -3
- data/features/readme.md +17 -3
- data/lib/dbmanager/adapters/mysql.rb +8 -0
- data/lib/dbmanager/capistrano.rb +17 -2
- 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
|
+
ZmIwZTE5NjE4OWNlYmYyZDQwMmVmN2IyMzRjN2U2Y2E3MzgwMmM3Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTQxYWZjNzQzMzEzODQ0M2I2YTZhNDczNzI5ZTE0YjM0OTVmMGU4OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjQwYjZlYzQwNjNhYmY3ZDIzMDI1Mzk2NDgzMmM0ODk4ZTBlYTdhYTZiNTNj
|
10
|
+
NzAzYjNlYzE0ZjQ4ZmQ5OTQ1MzJmMTIxNzAxYzIzYmQxODkxYjFjNDZkNDkw
|
11
|
+
MTAzZjk5NWM4YmU4MDBiNDQxY2EzMjY3NjRhNmQxMjI2ZGFlY2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGMxMDZmYWNkYzdkODdiYzNlMTNjMzYzMTVlMTcyMWI1YWZmOGFjNTRjMTA0
|
14
|
+
MzE4YTljYmVkOGE5OTFkNDI3OGY3ZWY2OGVlMDJiYjUwMTQyYzE2NWRlMTE1
|
15
|
+
NjJjNDRjNGJhMzk4NDdhYzhiNjY4MzBmZGNlNjJmMzg1YjNjZTM=
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -115,16 +115,30 @@ ignoretables directive:
|
|
115
115
|
|
116
116
|
## Capistrano Integration
|
117
117
|
|
118
|
-
You can use
|
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
|
-
|
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
|
data/features/readme.md
CHANGED
@@ -115,16 +115,30 @@ ignoretables directive:
|
|
115
115
|
|
116
116
|
## Capistrano Integration
|
117
117
|
|
118
|
-
You can use
|
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
|
-
|
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
|
data/lib/dbmanager/capistrano.rb
CHANGED
@@ -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.
|
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
|
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.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-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|