blackstack-db 1.0.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-db/crdb.rb +9 -10
- data/lib/blackstack-db/postgresql.rb +7 -7
- data/lib/blackstack-db.rb +2 -0
- metadata +42 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d09e6d2f5af17a813d5c536f864de997551a9194448902d6c461f4c534b89cea
|
4
|
+
data.tar.gz: 5516cc43d2b141c373f80fcd1140fd32771edb7ddc2592698ed70719bede0ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2834217481c0801578b04fe9d0b85517cbb4e38f1a8a148ab7e91650700a0b9d6fb4de9ce4b4de73c308b6c0288fe03903b1b7011c174d38152f8f05283d59af
|
7
|
+
data.tar.gz: b55847daa76635ac4df18db153343a286b4dd8ad9858986c70479a01442beeff46cb4f4ba829ea1300fa189a93c0c87b2daaee007538fcff629283d14e48663a
|
data/lib/blackstack-db/crdb.rb
CHANGED
@@ -115,7 +115,7 @@ module BlackStack
|
|
115
115
|
tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz]
|
116
116
|
DB["SELECT current_timestamp() at TIME ZONE '#{tz}' AS now"].first[:now]
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
# test the connection to the database.
|
120
120
|
# raise an exception if the connection fails, or if any incongruence is found.
|
121
121
|
def self.test(l=nil)
|
@@ -128,11 +128,11 @@ module BlackStack
|
|
128
128
|
l.logs "Testing connection... "
|
129
129
|
begin
|
130
130
|
@db = BlackStack::Deployer::DB::connect(
|
131
|
-
BlackStack::
|
131
|
+
BlackStack::CRDB::connection_string # use the connection parameters setting in ./config.rb
|
132
132
|
)
|
133
|
-
l.logf "success"
|
133
|
+
l.logf "success".green
|
134
134
|
rescue => e
|
135
|
-
l.logf "failed"
|
135
|
+
l.logf "failed".red
|
136
136
|
l.log e.message
|
137
137
|
end
|
138
138
|
|
@@ -140,14 +140,13 @@ module BlackStack
|
|
140
140
|
# This validation checks the connection to the correct database.
|
141
141
|
begin
|
142
142
|
l.logs "Verify database name... "
|
143
|
-
s = @db["SHOW DATABASES"].
|
144
|
-
raise 'Wrong database name' if s !~
|
145
|
-
l.logf "success"
|
143
|
+
s = @db["SHOW DATABASES"].all.map { |x| x[:database_name] }.join("\n")
|
144
|
+
raise 'Wrong database name'.red if s !~ /#{Regexp.escape(BlackStack::CRDB::db_name)}/i
|
145
|
+
l.logf "success".green
|
146
146
|
rescue => e
|
147
|
-
l.logf "failed"
|
147
|
+
l.logf "failed".red
|
148
148
|
l.log e.message
|
149
149
|
end
|
150
|
-
end
|
151
|
-
=end
|
150
|
+
end # test
|
152
151
|
end # module CRDB
|
153
152
|
end # module BlackStack
|
@@ -97,7 +97,7 @@ module BlackStack
|
|
97
97
|
tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz]
|
98
98
|
DB["SELECT (current_timestamp - interval '#{n} seconds') at TIME ZONE '#{tz}' AS now"].first[:now]
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
# test the connection to the database.
|
102
102
|
# raise an exception if the connection fails, or if any incongruence is found.
|
103
103
|
def self.test(l=nil)
|
@@ -112,9 +112,9 @@ module BlackStack
|
|
112
112
|
@db = BlackStack::Deployer::DB::connect(
|
113
113
|
BlackStack::PostgreSQL::connection_string # use the connection parameters setting in ./config.rb
|
114
114
|
)
|
115
|
-
l.logf "success"
|
115
|
+
l.logf "success".green
|
116
116
|
rescue => e
|
117
|
-
l.logf "failed"
|
117
|
+
l.logf "failed".red
|
118
118
|
l.log e.message
|
119
119
|
end
|
120
120
|
|
@@ -122,14 +122,14 @@ module BlackStack
|
|
122
122
|
# This validation checks the connection to the correct database.
|
123
123
|
begin
|
124
124
|
l.logs "Verify database name... "
|
125
|
-
s = @db["
|
125
|
+
s = @db["SELECT datname FROM pg_database"].first.to_s
|
126
126
|
raise 'Wrong database name' if s !~ /:database_name=>\"#{Regexp.escape(BlackStack::PostgreSQL::db_name)}\"/i
|
127
|
-
l.logf "success"
|
127
|
+
l.logf "success".green
|
128
128
|
rescue => e
|
129
|
-
l.logf "failed"
|
129
|
+
l.logf "failed".red
|
130
130
|
l.log e.message
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
end # module PostgreSQL
|
135
135
|
end
|
data/lib/blackstack-db.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.1
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: simple_cloud_logging
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.2.2
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.2.2
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.2.2
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.2.2
|
13
53
|
- !ruby/object:Gem::Dependency
|
14
54
|
name: sequel
|
15
55
|
requirement: !ruby/object:Gem::Requirement
|