lexicon-common 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b24914e5f9dbd3d4261ec1b6c04741958a5d9fcfccb9dde8fd14b92b5c19b57
|
4
|
+
data.tar.gz: 7b2a40b0e4e033dbc111804a5c6a6a7105fdd2ac991d72baeb7022e66f585913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7e024f856d40571826aa8237cfbd0b1ea55be19bf31f997ce5f65cf04c561ffaa43d4b5c23b5fcdda05ae7f3b48629ae0ca68c0c91903fa362e4674e3cdbd4
|
7
|
+
data.tar.gz: 7c225eb0b67789074fa76e5a50bcc61439503b5fb579d811077732b7f9763efc822f7f4c12d2aa314d5b0719ef3820d0eff097e08aaa3c167d442f48665dbe64
|
@@ -50,7 +50,7 @@ module Lexicon
|
|
50
50
|
drop_schema(schema, cascade: true)
|
51
51
|
end
|
52
52
|
|
53
|
-
def drop_schema(name, cascade: false)
|
53
|
+
def drop_schema(name, cascade: false, if_exists: false)
|
54
54
|
cascade = if cascade
|
55
55
|
' CASCADE'
|
56
56
|
else
|
@@ -58,7 +58,7 @@ module Lexicon
|
|
58
58
|
end
|
59
59
|
|
60
60
|
query <<~SQL
|
61
|
-
DROP SCHEMA "#{name}"#{cascade};
|
61
|
+
DROP SCHEMA #{if_exists ? 'IF EXISTS ' : ''}"#{name}"#{cascade};
|
62
62
|
SQL
|
63
63
|
end
|
64
64
|
|
@@ -95,6 +95,28 @@ module Lexicon
|
|
95
95
|
@connection.copy_data(sql) { block.call(put_data) }
|
96
96
|
end
|
97
97
|
|
98
|
+
# @param [#to_s] table
|
99
|
+
# @param [#to_s | nil] schema
|
100
|
+
# @return [Boolean]
|
101
|
+
def table_exists?(table, schema: nil)
|
102
|
+
schema = search_path.first if schema.nil?
|
103
|
+
|
104
|
+
query(<<~SQL, table, schema).any?
|
105
|
+
SELECT table_name FROM information_schema.tables
|
106
|
+
WHERE table_name = $1 AND table_schema = $2
|
107
|
+
SQL
|
108
|
+
end
|
109
|
+
|
110
|
+
# @param [#to_s] schema_name
|
111
|
+
# @return [Boolean]
|
112
|
+
def schema_exists?(schema_name)
|
113
|
+
query(<<~SQL, schema_name).count > 0
|
114
|
+
SELECT "schema_name"
|
115
|
+
FROM "information_schema"."schemata"
|
116
|
+
WHERE "schema_name" = $1
|
117
|
+
SQL
|
118
|
+
end
|
119
|
+
|
98
120
|
private
|
99
121
|
|
100
122
|
# @return [PG::Connection]
|
@@ -153,7 +153,7 @@ module Lexicon
|
|
153
153
|
# @param [String] schema
|
154
154
|
def load_csv(file, into:, schema:)
|
155
155
|
psql.execute_raw(<<~SQL)
|
156
|
-
\\copy "#{schema}"."#{into}" FROM PROGRAM 'zcat #{file}' WITH csv
|
156
|
+
\\copy "#{schema}"."#{into}" FROM PROGRAM 'zcat < #{file}' WITH csv
|
157
157
|
SQL
|
158
158
|
end
|
159
159
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexicon-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ekylibre developers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
- - '='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 1.11.0
|
181
|
-
description:
|
181
|
+
description:
|
182
182
|
email:
|
183
183
|
- dev@ekylibre.com
|
184
184
|
executables: []
|
@@ -221,7 +221,7 @@ homepage: https://www.ekylibre.com
|
|
221
221
|
licenses:
|
222
222
|
- AGPL-3.0-only
|
223
223
|
metadata: {}
|
224
|
-
post_install_message:
|
224
|
+
post_install_message:
|
225
225
|
rdoc_options: []
|
226
226
|
require_paths:
|
227
227
|
- lib
|
@@ -236,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
- !ruby/object:Gem::Version
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
|
-
rubygems_version: 3.
|
240
|
-
signing_key:
|
239
|
+
rubygems_version: 3.4.7
|
240
|
+
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: Common classes and services for Ekylibre's Lexicon
|
243
243
|
test_files: []
|