db_dumper 0.5.2 → 0.5.3
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 +4 -4
- data/README.md +11 -8
- data/lib/db_dumper/query_builder.rb +4 -5
- data/lib/db_dumper/query_builder/query.rb +6 -6
- data/lib/db_dumper/query_builder/table.rb +7 -4
- data/lib/db_dumper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18914983a2e3a39e23fd891de9ff495eda36da6bd23be62c1b41f17f144070e5
|
4
|
+
data.tar.gz: b025dc6ca5704703b2205805876659669b9d9f069613bae776226fc2a06979ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 145c849770ae6173546fc52dc87940cf57c1ca6bc2384351e19056e088068514993853b0082ddafa88b9d26f8c8842b4d15c4dc11d010cb14a0ca18b141d79f0
|
7
|
+
data.tar.gz: e98b614cdd9d491d6837f2405d5b76068301007e2043f1775b5b1abbd3ad842a7a3f65cc17adaad059b37fb0d3f2341d292e1087c9b0e86d3d8b1c3b337d584d
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# DB dumper - configurable SQL database data copying util from remote to local machine.
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/db_dumper)
|
4
|
+
[](https://codeclimate.com/github/alukyanov/db_dumper/maintainability)
|
4
5
|
|
5
6
|
## Index
|
6
7
|
- [Usage](#usage)
|
@@ -10,6 +11,8 @@
|
|
10
11
|
- [Bundler](#or-if-you-are-using-bundler)
|
11
12
|
|
12
13
|
## Usage
|
14
|
+
- Setup config/application.yml file properly.
|
15
|
+
- Install pg_dump, psql utils on remote machine for PostgreSQL adapter.
|
13
16
|
|
14
17
|
Example for simple Ruby file:
|
15
18
|
|
@@ -25,10 +28,10 @@ end
|
|
25
28
|
|
26
29
|
DbDumper.dump do
|
27
30
|
user_id = 1
|
28
|
-
dump('users').where(id: user_id)
|
31
|
+
dump q('users').where(id: user_id)
|
29
32
|
campaigns_q = q('campaigns').where('user_id = ? OR for_all IS TRUE', user_id)
|
30
|
-
dump
|
31
|
-
dump('offices').where(campaign_id: campaigns_q.ar)
|
33
|
+
dump campaigns_q
|
34
|
+
dump q('offices').where(campaign_id: campaigns_q.ar)
|
32
35
|
end
|
33
36
|
```
|
34
37
|
|
@@ -39,6 +42,10 @@ After executing you will see:
|
|
39
42
|
|
40
43
|
### Config
|
41
44
|
|
45
|
+
#### remote_db
|
46
|
+
##### adapter
|
47
|
+
Currently supported only postgres adapter, so you can dump only PostgreSQL.
|
48
|
+
|
42
49
|
Config file example at config/application.yml
|
43
50
|
|
44
51
|
```
|
@@ -63,10 +70,6 @@ local_machine:
|
|
63
70
|
dest_path: /tmp
|
64
71
|
```
|
65
72
|
|
66
|
-
### Testing
|
67
|
-
|
68
|
-
No tests fo now
|
69
|
-
|
70
73
|
## <a id="installation">Installation ##
|
71
74
|
|
72
75
|
### Manually from RubyGems.org ###
|
@@ -122,4 +125,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
122
125
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
123
126
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
124
127
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
125
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
128
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -17,15 +17,14 @@ module DbDumper
|
|
17
17
|
|
18
18
|
# DSL start
|
19
19
|
|
20
|
-
#
|
20
|
+
# add query to current dump
|
21
21
|
def dump(query)
|
22
|
-
|
23
|
-
query.tap { |q| queries << q }
|
22
|
+
queries << query
|
24
23
|
end
|
25
24
|
|
26
25
|
# creates new query
|
27
|
-
def q(
|
28
|
-
Query.new
|
26
|
+
def q(raw_table)
|
27
|
+
Query.new(raw_table)
|
29
28
|
end
|
30
29
|
|
31
30
|
# DSL end
|
@@ -7,22 +7,22 @@ module DbDumper
|
|
7
7
|
|
8
8
|
delegate :table_name, to: :table
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@table =
|
12
|
-
@ar =
|
10
|
+
def initialize(raw_table, exist_ar = nil)
|
11
|
+
@table = Table.from(raw_table)
|
12
|
+
@ar = exist_ar || table.ar.all
|
13
13
|
end
|
14
14
|
|
15
15
|
def where(*args)
|
16
|
-
|
16
|
+
self.class.new(table, ar.where(*args))
|
17
17
|
end
|
18
18
|
|
19
19
|
def joins(*args)
|
20
20
|
raise 'Only simple string for joins supported' unless args.size == 1 && args[0].is_a?(String)
|
21
|
-
|
21
|
+
self.class.new(table, ar.joins(*args))
|
22
22
|
end
|
23
23
|
|
24
24
|
def select(*args)
|
25
|
-
|
25
|
+
self.class.new(table, ar.select(*args))
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_sql
|
@@ -7,10 +7,13 @@ module DbDumper
|
|
7
7
|
|
8
8
|
@tables = {}
|
9
9
|
|
10
|
-
def self.from(
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def self.from(raw_table)
|
11
|
+
return raw_table if raw_table.is_a?(Table)
|
12
|
+
|
13
|
+
table_name_str = raw_table.to_s
|
14
|
+
@tables[table_name_str] ||= begin
|
15
|
+
ActiveRecord::Migration.create_table(table_name_str)
|
16
|
+
new(table_name_str)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
data/lib/db_dumper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_dumper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Lukyanov
|
@@ -96,7 +96,7 @@ licenses:
|
|
96
96
|
metadata:
|
97
97
|
bug_tracker_uri: https://github.com/alukyanov/db_dumper/issues
|
98
98
|
changelog_uri: https://github.com/alukyanov/db_dumper/CHANGELOG.md
|
99
|
-
documentation_uri: http://www.rubydoc.info/gems/db_dumper/0.5.
|
99
|
+
documentation_uri: http://www.rubydoc.info/gems/db_dumper/0.5.3
|
100
100
|
homepage_uri: https://github.com/alukyanov/db_dumper
|
101
101
|
source_code_uri: https://github.com/alukyanov/db_dumper
|
102
102
|
wiki_uri: https://github.com/alukyanov/db_dumper/wiki
|