tapsoob 0.5.19-java → 0.5.21-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapsoob/cli/schema.rb +24 -2
- data/lib/tapsoob/schema.rb +14 -1
- data/lib/tapsoob/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f70dd3a031e79ff2e9ef17cfa393ff43ab72d5997764dff75868639fea538f
|
4
|
+
data.tar.gz: f6c9bfdd071441d86ecbef66932365860a7b30ca4e9485a187078430a9983fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16364c004373d3afb5092e14c5d831817ec40193563c4e4b6b20815a3168426a57cf7a8c2785dfc2eee3af1f0a02b67d4bccafc66fe56d920204eba730defbd6
|
7
|
+
data.tar.gz: feb890c468b17e7b8feccb5870a37a3c06edb307334134c0dee7ef9c4db6f5ce383d901da27d399e026c95d2b5d3109f4e68cc2735780b0b9fe595ad91b32b03
|
data/lib/tapsoob/cli/schema.rb
CHANGED
@@ -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 "
|
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)
|
data/lib/tapsoob/schema.rb
CHANGED
@@ -22,7 +22,7 @@ Class.new(Sequel::Migration) do
|
|
22
22
|
|
23
23
|
def down
|
24
24
|
<% db.send(:sort_dumped_tables, db.tables, {}).reverse.each do |table| %>
|
25
|
-
drop_table("<%= table %>", if_exists: true)
|
25
|
+
drop_table("<%= table %>", if_exists: true, cascade: true)
|
26
26
|
<% end %>
|
27
27
|
end
|
28
28
|
end
|
@@ -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
|
data/lib/tapsoob/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.21
|
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-
|
12
|
+
date: 2023-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.3.25
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Simple tool to import/export databases.
|