tapsoob 0.3.10 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/tapsoob/schema.rb +20 -4
- data/lib/tapsoob/version.rb +1 -1
- data/tapsoob.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55bc7c545448861ed66362939755b363326d7b2d87ccc048a670e47eee228be
|
4
|
+
data.tar.gz: c411d6a74337e37b7dd244066360320d81b1afda6ea1d0d070586011288f9f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cdd9c82ff53ac8328e201c82729bb2128230ee2dcd83aea69ebcd4fa1df6f1371c330e1cb0e79235881a9e1ced4cd47400fac3e15e39bfce97d9d9d4f156ee7
|
7
|
+
data.tar.gz: 0efe17386c054d46541ce9a78464300b4d302df2ed62f1df3b7517096f6701561f70b906880c5a71b8526e8211c3b29d6856c65565ee14d274f2595d9dd63ee5
|
data/README.md
CHANGED
@@ -36,6 +36,23 @@ You can list all available options using the command:
|
|
36
36
|
tapsoob push -h
|
37
37
|
|
38
38
|
|
39
|
+
## NEW : Piping your schema/indexes/data
|
40
|
+
|
41
|
+
Due to some needs we added ways to pipe your schema/indexes/data directly from one database to another, here's an equivalent of the export/import process described above using this technique :
|
42
|
+
|
43
|
+
```
|
44
|
+
tapsoob schema dump <db_source_url> | tapsoob schema load <db_target_url> --drop=true
|
45
|
+
tapsoob schema indexes <db_source_url> | tapsoob schema load_indexes <db_target_url>
|
46
|
+
tapsoob data pull <db_source_url> -p false | tapsoob data push <db_target_url>
|
47
|
+
tapsoob schema reset_db_sequences <db_target_url>
|
48
|
+
```
|
49
|
+
|
50
|
+
A few notes here :
|
51
|
+
|
52
|
+
* the `--drop` option for the `schema load` command defaults to false, if you don't intend to drop your tables on your target databases you can ommit it (if a table already exists tapsoob will exit w/ an error) ;
|
53
|
+
* the `data pull` and `data push` commands are new and have a few options that you can display w/ `tapsoob data <pull|push> -h`, by defaults it prints the progress of your data extraction/import but if you want to pipe directly your export into another database you'll have to set the `--progress` (shorthand `-p`) option to `false` (or `--no-progress`) as above ;
|
54
|
+
* resetting database sequences is important as a `data push` command doesn't handle that directly.
|
55
|
+
|
39
56
|
## Integration with Rails
|
40
57
|
|
41
58
|
If you're using Rails, there's also two Rake tasks provided:
|
data/lib/tapsoob/schema.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'sequel'
|
3
3
|
require 'sequel/extensions/schema_dumper'
|
4
4
|
require 'sequel/extensions/migration'
|
5
|
+
require 'erb'
|
5
6
|
require 'json'
|
6
7
|
|
7
8
|
module Tapsoob
|
@@ -11,17 +12,23 @@ module Tapsoob
|
|
11
12
|
def dump(database_url)
|
12
13
|
db = Sequel.connect(database_url)
|
13
14
|
db.extension :schema_dumper
|
14
|
-
|
15
|
+
template = ERB.new <<-END_MIG
|
15
16
|
Class.new(Sequel::Migration) do
|
16
17
|
def up
|
17
|
-
|
18
|
+
<% db.tables.each do |table| %>
|
19
|
+
<%= db.dump_table_schema(table, indexes: false) %>
|
20
|
+
<% end %>
|
18
21
|
end
|
19
22
|
|
20
23
|
def down
|
21
|
-
|
24
|
+
<% db.tables.each do |table| %>
|
25
|
+
drop_table("<%= table %>", if_exists: true)
|
26
|
+
<% end %>
|
22
27
|
end
|
23
28
|
end
|
24
29
|
END_MIG
|
30
|
+
|
31
|
+
template.result(binding)
|
25
32
|
end
|
26
33
|
|
27
34
|
def dump_table(database_url, table)
|
@@ -77,7 +84,16 @@ END_MIG
|
|
77
84
|
Sequel.connect(database_url) do |db|
|
78
85
|
db.extension :schema_dumper
|
79
86
|
klass = eval(schema)
|
80
|
-
|
87
|
+
if options[:drop]
|
88
|
+
# Start special hack for MySQL
|
89
|
+
db.run("SET foreign_key_checks = 0") if [:mysql, :mysql2].include?(db.adapter_scheme)
|
90
|
+
|
91
|
+
# Run down migration
|
92
|
+
klass.apply(db, :down)
|
93
|
+
|
94
|
+
# End special hack for MySQL
|
95
|
+
db.run("SET foreign_key_checks = 1") if [:mysql, :mysql2].include?(db.adapter_scheme)
|
96
|
+
end
|
81
97
|
klass.apply(db, :up)
|
82
98
|
end
|
83
99
|
end
|
data/lib/tapsoob/version.rb
CHANGED
data/tapsoob.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
# Dependencies
|
23
23
|
s.add_dependency "ripl", "~> 0.7.1"
|
24
24
|
s.add_dependency "sequel", "~> 5.25.0"
|
25
|
-
s.add_dependency "thor", "~> 0.
|
25
|
+
s.add_dependency "thor", "~> 1.0.1"
|
26
26
|
|
27
27
|
if (RUBY_PLATFORM =~ /java/).nil?
|
28
28
|
s.add_development_dependency "mysql2", "~> 0.4.10"
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapsoob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Félix Bellanger
|
8
8
|
- Michael Chrisco
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ripl
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: 1.0.1
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 1.0.1
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: mysql2
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,7 +134,7 @@ homepage: https://github.com/Keeguon/tapsoob
|
|
134
134
|
licenses:
|
135
135
|
- MIT
|
136
136
|
metadata: {}
|
137
|
-
post_install_message:
|
137
|
+
post_install_message:
|
138
138
|
rdoc_options: []
|
139
139
|
require_paths:
|
140
140
|
- lib
|
@@ -149,9 +149,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubyforge_project:
|
152
|
+
rubyforge_project:
|
153
153
|
rubygems_version: 2.7.6.2
|
154
|
-
signing_key:
|
154
|
+
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Simple tool to import/export databases.
|
157
157
|
test_files:
|