tapsoob 0.3.6-java → 0.3.16-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dee2508d81d685a0296423c9b37e1679e691d12f96fc98e1f21a078d531acb0a
4
- data.tar.gz: 2097cd103e9f36ddbe351241306686a889a91a6a5c2e124992dae2e3b7817ecf
3
+ metadata.gz: 18966c1577d34ebe06aa3d2aa3a9fd9cff0ad2f5387c1e1029c5a7fa407771a4
4
+ data.tar.gz: 5d3a11bf9c10df2a44176c8f2475e1b9ba554330b3fe254551ee86ca050ad40c
5
5
  SHA512:
6
- metadata.gz: a29ec80bab12a4c94cfb8bd90cdf3d6b7dcf28ed1b13063143c4195f334284f90dd46288d8b19035f9bb1ce609fae137f63ea8b0ee5eaa6202094708681b266a
7
- data.tar.gz: a35f005141792106b619fe5861acf009230ba1b185fb94c0ce76d6b0cfcb1f2ab640dff69d7db2f58269344df203df9a11b52300d8e5c505df63c59821a2efa1
6
+ metadata.gz: e57e3746ceedaea48aeced9465945d637f043a18cf11c7776d3afae0b320d2be07f5388d88845689c18d31eb55802281a2576441540fdf66a27eff30f0ec7069
7
+ data.tar.gz: 2bba4014438cc84c04b89d940eacdf903237d8298e0ffe1fd5e41f1f85cb06abd342de875c259b2d1642b758230e6d902bfdb8d826fa9e6937e97362cec9e786
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:
@@ -39,7 +39,7 @@ module Tapsoob
39
39
  end
40
40
 
41
41
  desc "load DATABASE_URL [FILENAME]", "Load a database schema from a file to a database using a database URL"
42
- option :drop, type: boolean, default: false
42
+ option :drop, type: :boolean, default: false
43
43
  def load(database_url, filename = nil)
44
44
  schema = if filename && File.exists?(filename)
45
45
  File.read(filename)
@@ -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,7 +12,23 @@ module Tapsoob
11
12
  def dump(database_url)
12
13
  db = Sequel.connect(database_url)
13
14
  db.extension :schema_dumper
14
- db.dump_schema_migration(:indexes => false)
15
+ template = ERB.new <<-END_MIG
16
+ Class.new(Sequel::Migration) do
17
+ def up
18
+ <% db.tables.each do |table| %>
19
+ <%= db.dump_table_schema(table, indexes: false) %>
20
+ <% end %>
21
+ end
22
+
23
+ def down
24
+ <% db.tables.each do |table| %>
25
+ drop_table("<%= table %>", if_exists: true)
26
+ <% end %>
27
+ end
28
+ end
29
+ END_MIG
30
+
31
+ template.result(binding)
15
32
  end
16
33
 
17
34
  def dump_table(database_url, table)
@@ -21,11 +38,11 @@ module Tapsoob
21
38
  <<END_MIG
22
39
  Class.new(Sequel::Migration) do
23
40
  def up
24
- #{db.dump_table_schema(table, :indexes => false)}
41
+ #{db.dump_table_schema(table, indexes: false)}
25
42
  end
26
43
 
27
44
  def down
28
- drop_table("#{table}") if @db.table_exists?("#{table}")
45
+ drop_table("#{table}", if_exists: true)
29
46
  end
30
47
  end
31
48
  END_MIG
@@ -67,7 +84,16 @@ END_MIG
67
84
  Sequel.connect(database_url) do |db|
68
85
  db.extension :schema_dumper
69
86
  klass = eval(schema)
70
- klass.apply(db, :down) if options[:drop]
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
71
97
  klass.apply(db, :up)
72
98
  end
73
99
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.3.6".freeze
3
+ VERSION = "0.3.16".freeze
4
4
  end
@@ -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.20.3"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapsoob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.16
5
5
  platform: java
6
6
  authors:
7
7
  - Félix Bellanger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-27 00:00:00.000000000 Z
12
+ date: 2020-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.20.3
47
+ version: 1.0.1
48
48
  name: thor
49
49
  prerelease: false
50
50
  type: :runtime
@@ -52,7 +52,7 @@ dependencies:
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.20.3
55
+ version: 1.0.1
56
56
  - !ruby/object:Gem::Dependency
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
@@ -149,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.7.10
152
+ rubygems_version: 3.1.4
154
153
  signing_key:
155
154
  specification_version: 4
156
155
  summary: Simple tool to import/export databases.