sample_data_dump_postgres_data_store 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +15 -15
- data/LICENSE.md +11 -0
- data/lib/sample_data_dump_postgres_data_store/gateway.rb +13 -23
- data/lib/sample_data_dump_postgres_data_store/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 156cad5b2ebd342e4d30290fd561d327b4639dc7
|
4
|
+
data.tar.gz: 49cd3561612b59c104aeae6bf2f61cc704163362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47336fe15b95530d7de7718ac1211649f65ab4637e75df8eb20e93ca84a484fd383a65b0d30a91747ab0416845a4a7f49161d32487ef109de2f8493c13f5e3a5
|
7
|
+
data.tar.gz: b3d621b6a6a4c59912a76ee93300c754fd89782f6a59e32d3a339c45bf09c6614ab776f0ac38d5b46ddfdfc239bc9981f98a85e7094357091164e93028718fa0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sample_data_dump_postgres_data_store (0.0.
|
4
|
+
sample_data_dump_postgres_data_store (0.0.3)
|
5
5
|
activerecord
|
6
6
|
dry-matcher
|
7
7
|
dry-monads
|
@@ -15,26 +15,26 @@ PATH
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
|
-
actionpack (5.2.
|
19
|
-
actionview (= 5.2.
|
20
|
-
activesupport (= 5.2.
|
18
|
+
actionpack (5.2.2)
|
19
|
+
actionview (= 5.2.2)
|
20
|
+
activesupport (= 5.2.2)
|
21
21
|
rack (~> 2.0)
|
22
22
|
rack-test (>= 0.6.3)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
25
|
-
actionview (5.2.
|
26
|
-
activesupport (= 5.2.
|
25
|
+
actionview (5.2.2)
|
26
|
+
activesupport (= 5.2.2)
|
27
27
|
builder (~> 3.1)
|
28
28
|
erubi (~> 1.4)
|
29
29
|
rails-dom-testing (~> 2.0)
|
30
30
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
31
|
-
activemodel (5.2.
|
32
|
-
activesupport (= 5.2.
|
33
|
-
activerecord (5.2.
|
34
|
-
activemodel (= 5.2.
|
35
|
-
activesupport (= 5.2.
|
31
|
+
activemodel (5.2.2)
|
32
|
+
activesupport (= 5.2.2)
|
33
|
+
activerecord (5.2.2)
|
34
|
+
activemodel (= 5.2.2)
|
35
|
+
activesupport (= 5.2.2)
|
36
36
|
arel (>= 9.0)
|
37
|
-
activesupport (5.2.
|
37
|
+
activesupport (5.2.2)
|
38
38
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
39
39
|
i18n (>= 0.7, < 2)
|
40
40
|
minitest (~> 5.1)
|
@@ -149,9 +149,9 @@ GEM
|
|
149
149
|
nokogiri (>= 1.6)
|
150
150
|
rails-html-sanitizer (1.0.4)
|
151
151
|
loofah (~> 2.2, >= 2.2.2)
|
152
|
-
railties (5.2.
|
153
|
-
actionpack (= 5.2.
|
154
|
-
activesupport (= 5.2.
|
152
|
+
railties (5.2.2)
|
153
|
+
actionpack (= 5.2.2)
|
154
|
+
activesupport (= 5.2.2)
|
155
155
|
method_source
|
156
156
|
rake (>= 0.8.7)
|
157
157
|
thor (>= 0.19.0, < 2.0)
|
data/LICENSE.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Copyright 2018 Bellroy
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
4
|
+
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
6
|
+
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
+
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -12,7 +12,7 @@ module SampleDataDumpPostgresDataStore
|
|
12
12
|
implements_interface SampleDataDump::Interfaces::DataStoreGateway
|
13
13
|
|
14
14
|
def initialize(postgresql_adapter, settings)
|
15
|
-
@
|
15
|
+
@postgresql_adapter = postgresql_adapter
|
16
16
|
@settings = settings
|
17
17
|
end
|
18
18
|
|
@@ -21,7 +21,7 @@ module SampleDataDumpPostgresDataStore
|
|
21
21
|
uncompressed_file_path = dump_file.local_dump_file_path
|
22
22
|
|
23
23
|
sql = extraction_sql(table_configuration)
|
24
|
-
results = @
|
24
|
+
results = @postgresql_adapter.execute(sql)
|
25
25
|
export_results_to_sql(results, table_configuration, uncompressed_file_path)
|
26
26
|
Dry::Monads::Success(uncompressed_file_path)
|
27
27
|
end
|
@@ -36,24 +36,24 @@ module SampleDataDumpPostgresDataStore
|
|
36
36
|
end
|
37
37
|
|
38
38
|
sql = File.read(source_file_path)
|
39
|
-
@
|
39
|
+
@postgresql_adapter.execute(sql)
|
40
40
|
Dry::Monads::Success(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
def reset_sequence(table_configuration)
|
44
44
|
table_name = table_configuration.qualified_table_name
|
45
45
|
sql = "SELECT setval('#{table_name}_id_seq', coalesce((SELECT MAX(id) FROM #{table_name}),1))"
|
46
|
-
@
|
46
|
+
@postgresql_adapter.execute(sql)
|
47
47
|
Dry::Monads::Success(true)
|
48
48
|
end
|
49
49
|
|
50
50
|
def valid?(table_configuration)
|
51
|
-
TableConfigurationValidator.new(table_configuration, @
|
51
|
+
TableConfigurationValidator.new(table_configuration, @postgresql_adapter).validation_result
|
52
52
|
end
|
53
53
|
|
54
54
|
def wipe_table(table_configuration)
|
55
55
|
qualified_table_name = table_configuration.qualified_table_name
|
56
|
-
@
|
56
|
+
@postgresql_adapter.execute "DELETE FROM #{qualified_table_name} CASCADE"
|
57
57
|
Dry::Monads::Success(true)
|
58
58
|
end
|
59
59
|
|
@@ -62,22 +62,12 @@ module SampleDataDumpPostgresDataStore
|
|
62
62
|
attr_reader :settings
|
63
63
|
delegate :compacted_dump_directory, :lorem_ipsum_function_schema, to: :settings
|
64
64
|
|
65
|
-
class SquishedSqlRunner
|
66
|
-
def initialize(postgresql_adapter)
|
67
|
-
@postgresql_adapter = postgresql_adapter
|
68
|
-
end
|
69
|
-
|
70
|
-
def run(sql)
|
71
|
-
@postgresql_adapter.execute sql.squish
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
65
|
class TableConfigurationValidator
|
76
66
|
include Dry::Monads::Do.for(:validation_result)
|
77
67
|
|
78
|
-
def initialize(table_configuration,
|
68
|
+
def initialize(table_configuration, postgresql_adapter)
|
79
69
|
@table_configuration = table_configuration
|
80
|
-
@
|
70
|
+
@postgresql_adapter = postgresql_adapter
|
81
71
|
end
|
82
72
|
|
83
73
|
def validation_result
|
@@ -106,7 +96,7 @@ module SampleDataDumpPostgresDataStore
|
|
106
96
|
WHERE nspname = '#{schema_name}'
|
107
97
|
);
|
108
98
|
SQL
|
109
|
-
results = @
|
99
|
+
results = @postgresql_adapter.execute(sql)
|
110
100
|
|
111
101
|
return Dry::Monads::Success(true) if results.first['exists']
|
112
102
|
|
@@ -122,7 +112,7 @@ module SampleDataDumpPostgresDataStore
|
|
122
112
|
AND table_name = '#{table_name}'
|
123
113
|
);
|
124
114
|
SQL
|
125
|
-
results = @
|
115
|
+
results = @postgresql_adapter.execute(sql)
|
126
116
|
|
127
117
|
return Dry::Monads::Success(true) if results.first['exists']
|
128
118
|
|
@@ -135,7 +125,7 @@ module SampleDataDumpPostgresDataStore
|
|
135
125
|
WHERE #{dump_where}
|
136
126
|
LIMIT 1
|
137
127
|
SQL
|
138
|
-
@
|
128
|
+
@postgresql_adapter.execute(sql)
|
139
129
|
Dry::Monads::Success(true)
|
140
130
|
rescue ActiveRecord::StatementInvalid
|
141
131
|
Dry::Monads::Failure("dump_where for #{qualified_table_name} invalid")
|
@@ -146,7 +136,7 @@ module SampleDataDumpPostgresDataStore
|
|
146
136
|
return success_result if obfuscate_columns.empty?
|
147
137
|
|
148
138
|
sql = "SELECT #{obfuscate_columns.join(', ')} FROM #{qualified_table_name} LIMIT 1"
|
149
|
-
@
|
139
|
+
@postgresql_adapter.execute(sql)
|
150
140
|
success_result
|
151
141
|
rescue ActiveRecord::StatementInvalid
|
152
142
|
Dry::Monads::Failure("obfuscate_columns for #{qualified_table_name} invalid")
|
@@ -174,7 +164,7 @@ module SampleDataDumpPostgresDataStore
|
|
174
164
|
WHERE table_schema = '#{table_configuration.schema_name}'
|
175
165
|
AND table_name = '#{table_configuration.table_name}'
|
176
166
|
SQL
|
177
|
-
@
|
167
|
+
@postgresql_adapter.execute(sql).map { |row| row['column_name'] }
|
178
168
|
end
|
179
169
|
|
180
170
|
def lorem_ipsum_columns(table_configuration)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sample_data_dump_postgres_data_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bellroy Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- Gemfile
|
195
195
|
- Gemfile.lock
|
196
196
|
- Guardfile
|
197
|
+
- LICENSE.md
|
197
198
|
- README.md
|
198
199
|
- lib/sample_data_dump_postgres_data_store.rb
|
199
200
|
- lib/sample_data_dump_postgres_data_store/gateway.rb
|