dbmanager 0.0.2.beta → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -59,6 +59,17 @@ overwite. I take no responsibility for misuse or bugs in the code ;-)
|
|
59
59
|
Since some settings may be specific to the server environment (ie. host could
|
60
60
|
be a private ip not reachable from anywhere) you can overwrite the settings in
|
61
61
|
database.yml by adding a dbmanager_override.yml file in your rails config dir.
|
62
|
+
|
63
|
+
You can also use this file to tell the dumper to ignore certain tables with
|
64
|
+
the ignoretables directive:
|
65
|
+
|
66
|
+
```yaml
|
67
|
+
beta
|
68
|
+
ignoretables:
|
69
|
+
- users
|
70
|
+
- prods_view
|
71
|
+
```
|
72
|
+
|
62
73
|
Another use is to set some environments as protected, or vice versa allow to
|
63
74
|
overwrite production env.
|
64
75
|
For example if we want to override the following setting, and make the database
|
@@ -12,7 +12,8 @@ module Dbmanager
|
|
12
12
|
class Connection
|
13
13
|
attr_reader :environment
|
14
14
|
|
15
|
-
delegate :host, :adapter, :database, :username, :password, :
|
15
|
+
delegate :host, :adapter, :database, :username, :password, :ignoretables,
|
16
|
+
:encoding, :protected, :name, :port , :to => :environment
|
16
17
|
|
17
18
|
def initialize(environment)
|
18
19
|
@environment = environment
|
@@ -22,6 +23,12 @@ module Dbmanager
|
|
22
23
|
"-u#{username} #{flag :password, :p} #{flag :host, :h} #{flag :port, :P} #{database}"
|
23
24
|
end
|
24
25
|
|
26
|
+
def ignore_tables
|
27
|
+
ignoretables.inject('') do |s, view|
|
28
|
+
s << " --ignore-table=#{database}.#{view}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
25
32
|
def flag(name, flag)
|
26
33
|
send(name).present? ? "-#{flag}#{send(name)}" : ''
|
27
34
|
end
|
@@ -48,7 +55,7 @@ module Dbmanager
|
|
48
55
|
end
|
49
56
|
|
50
57
|
def dump_command
|
51
|
-
"mysqldump #{source.params} > #{filename}"
|
58
|
+
"mysqldump #{source.params} #{source.ignore_tables} > #{filename}"
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
data/lib/dbmanager/version.rb
CHANGED
@@ -19,6 +19,12 @@ module Dbmanager
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe '#ignore_tables' do
|
23
|
+
it 'returns expected string' do
|
24
|
+
subject.ignore_tables.should == ' --ignore-table=demo_test.view0 --ignore-table=demo_test.view1'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
describe '#protected?' do
|
23
29
|
it 'is false by default' do
|
24
30
|
subject.should_not be_protected
|
@@ -111,11 +117,17 @@ module Dbmanager
|
|
111
117
|
end
|
112
118
|
|
113
119
|
describe Dumper do
|
114
|
-
subject
|
120
|
+
subject do
|
121
|
+
Dumper.new(
|
122
|
+
mock(:params => 'source-params', :ignore_tables => '--ignore-table=view'),
|
123
|
+
'/tmp/dump_file.sql'
|
124
|
+
)
|
125
|
+
end
|
115
126
|
|
116
127
|
describe '#dump_command' do
|
117
128
|
it 'returns expected command' do
|
118
|
-
|
129
|
+
command = 'mysqldump source-params --ignore-table=view > /tmp/dump_file.sql'
|
130
|
+
subject.dump_command.should == command
|
119
131
|
end
|
120
132
|
end
|
121
133
|
end
|
data/spec/lib/yml_parser_spec.rb
CHANGED
@@ -46,6 +46,12 @@ module Dbmanager
|
|
46
46
|
it 'removes old unchanged settings' do
|
47
47
|
YmlParser.config['beta']['username'].should == 'beta_username'
|
48
48
|
end
|
49
|
+
|
50
|
+
context 'when the environment has a ignoretables directive' do
|
51
|
+
it 'should populate ignoretables with the expected array' do
|
52
|
+
YmlParser.config['beta']['ignoretables'].should == ['view0']
|
53
|
+
end
|
54
|
+
end
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.0.2
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- andrea longhi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-04 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -100,9 +100,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
none: false
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: "0"
|
106
106
|
requirements: []
|
107
107
|
|
108
108
|
rubyforge_project: dbmanager
|