tapsoob 0.5.19-java → 0.5.20-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: 94ce22f5995d48ad5008a522728c40b3b6bfe35511b6a696c7428ed68e800d37
4
- data.tar.gz: 172533ab25a53c5a5cfd2b9efd8d29d258609894d1080b05d82581b6386f1c40
3
+ metadata.gz: c9da95cfa0ca6f5bba8840d86ceb8cb6f2476abd44274a900ae2076a4c2a83fe
4
+ data.tar.gz: '028c4375fd4efd418d248f53ef341ca6af15416fb4581302fc24e16fc654b27a'
5
5
  SHA512:
6
- metadata.gz: c0fc26dce8628d470ed098858371139cc1ef3197614e8c147e3b1f4d993aa2392e940facede2ee4d354607a6dd6ebf102dfbf1e77f36c2c671a253a1af47c878
7
- data.tar.gz: b9f16e984d5ddbee64aa5bc6ca1245071487bec8e86a0e283314034afe2cb8f3eb64fd83778beeeb43ea70d6c5805de6dfeb5488f7675386bfc758545ad9e090
6
+ metadata.gz: 5c67b884c0a4814784f13730c8243212b618652a4c9ecb26170daf5e2f8196b473112c19ef1ed3635e7d918c7c6fe036b2ceb347a29c0f326104de09a6b51e37
7
+ data.tar.gz: d70869b92b6c1291e5c16138295c078c6d90369a4b916461e96bf382f581f8a46ed6026bc7f964827fec4f84baf7c7317482f955845c48ec7e2e05c0c73128e4
@@ -15,10 +15,12 @@ module Tapsoob
15
15
 
16
16
  desc "dump DATABASE_URL", "Dump a database using a database URL"
17
17
  option :indexes, type: :boolean, default: false
18
+ option :"foreign-keys", type: :boolean, default: false
18
19
  option :"same-db", type: :boolean, default: false
19
20
  def dump(database_url)
20
21
  opts = {}
21
22
  opts[:indexes] = options[:"indexes"]
23
+ opts[:foreign_keys] = options[:"foreign-keys"]
22
24
  opts[:same_db] = options[:"same-db"]
23
25
 
24
26
  puts Tapsoob::Schema.dump(database_url, opts)
@@ -29,6 +31,11 @@ module Tapsoob
29
31
  puts Tapsoob::Schema.dump_table(database_url, table)
30
32
  end
31
33
 
34
+ desc "foreign_keys DATABASE_URL", "Dump foreign_keys from a database using a database URL"
35
+ def foreign_keys(database_url)
36
+ puts Tapsoob::Schema.foreign_keys(database_url)
37
+ end
38
+
32
39
  desc "indexes DATABASE_URL", "Dump indexes from a database using a database URL"
33
40
  def indexes(database_url)
34
41
  puts Tapsoob::Schema.indexes(database_url)
@@ -44,7 +51,7 @@ module Tapsoob
44
51
  Tapsoob::Schema.reset_db_sequences(database_url)
45
52
  end
46
53
 
47
- desc "load DATABASE_URL [FILENAME]", "Load a database schema from a file to a database using a database URL"
54
+ desc "load DATABASE_URL [FILENAME]", "Load a database schema from a file or STDIN to a database using a database URL"
48
55
  option :drop, type: :boolean, default: false
49
56
  def load(database_url, filename = nil)
50
57
  schema = if filename && File.exists?(filename)
@@ -60,7 +67,22 @@ module Tapsoob
60
67
  end
61
68
  end
62
69
 
63
- desc "load_indexes DATABASE_URL [FILENAME]", "Load indexes from a file to a database using a database URL"
70
+ desc "load_foreign_keys DATABASE_URL [FILENAME]", "Load foreign keys from a file or STDIN to a database using a database URL"
71
+ def load_foreign_keys(database_url, filename = nil)
72
+ indexes = if filename && File.exists?(filename)
73
+ File.read(filename)
74
+ else
75
+ STDIN.read
76
+ end
77
+
78
+ begin
79
+ Tapsoob::Schema.load_foreign_keys(database_url, indexes)
80
+ rescue Exception => e
81
+ throw e
82
+ end
83
+ end
84
+
85
+ desc "load_indexes DATABASE_URL [FILENAME]", "Load indexes from a file or STDIN to a database using a database URL"
64
86
  def load_indexes(database_url, filename = nil)
65
87
  indexes = if filename && File.exists?(filename)
66
88
  File.read(filename)
@@ -49,6 +49,12 @@ END_MIG
49
49
  end
50
50
  end
51
51
 
52
+ def foreign_keys(database_url)
53
+ db = Sequel.connect(database_url)
54
+ db.extension :schema_dumper
55
+ db.dump_foreign_key_migration
56
+ end
57
+
52
58
  def indexes(database_url)
53
59
  db = Sequel.connect(database_url)
54
60
  db.extension :schema_dumper
@@ -98,6 +104,13 @@ END_MIG
98
104
  end
99
105
  end
100
106
 
107
+ def load_foreign_keys(database_url, foreign_keys)
108
+ Sequel.connect(database_url) do |db|
109
+ db.extension :schema_dumper
110
+ eval(foreign_keys).apply(db, :up)
111
+ end
112
+ end
113
+
101
114
  def load_indexes(database_url, indexes)
102
115
  Sequel.connect(database_url) do |db|
103
116
  db.extension :schema_dumper
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.5.19".freeze
3
+ VERSION = "0.5.20".freeze
4
4
  end
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.5.19
4
+ version: 0.5.20
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: 2023-02-13 00:00:00.000000000 Z
12
+ date: 2023-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement