swarm_cluster_cli_ope 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/swarm_cluster_cli_ope/sync_configs/post_gres.rb +26 -24
- data/lib/swarm_cluster_cli_ope/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c8d4d620c7c8929ca7606a553347601906ebdf99c13ac77c103ee94e4d46c74
|
|
4
|
+
data.tar.gz: cb045c6a4f21ba1482e79b1d810476677c509ac737cc3ef000bd68afb34ea5eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34772d9e2eb49263ec059a78bcbaa75629043f3d58b2c47c15c8061c430f995d6c5af6100b66c63781b17d450e012574f32a3c48228b24e2c51fc587904204e6
|
|
7
|
+
data.tar.gz: 1f59ee9abaf08937a09f26e6f0d7c77d88b595154aac0a0b9399299a4dc2bb7ffb59c7c5906d4fbcdf9d69967ccbc8765fee58e64334544f19a48267fb93d75e
|
data/Gemfile.lock
CHANGED
|
@@ -2,7 +2,6 @@ module SwarmClusterCliOpe
|
|
|
2
2
|
module SyncConfigs
|
|
3
3
|
class PostGres < BaseDatabase
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
def pull
|
|
7
6
|
resume('pull')
|
|
8
7
|
|
|
@@ -13,11 +12,11 @@ module SwarmClusterCliOpe
|
|
|
13
12
|
local.container.copy_in(tmp_file, tmp_file)
|
|
14
13
|
|
|
15
14
|
# drop old db and recreate
|
|
16
|
-
if Gem::Version.new(local.database_version) <= Gem::Version.new("12")
|
|
17
|
-
|
|
18
|
-
else
|
|
19
|
-
|
|
20
|
-
end
|
|
15
|
+
# if Gem::Version.new(local.database_version) <= Gem::Version.new("12")
|
|
16
|
+
close_connections_and_drop_cmd(local)
|
|
17
|
+
# else
|
|
18
|
+
# raise "DA ANALIZZARE QUANDO LA 13 disponibile....dropdb ha un force come parametro"
|
|
19
|
+
# end
|
|
21
20
|
|
|
22
21
|
create_cmd(local)
|
|
23
22
|
|
|
@@ -37,12 +36,8 @@ module SwarmClusterCliOpe
|
|
|
37
36
|
dump_cmd(local, tmp_file)
|
|
38
37
|
remote.container.copy_in(tmp_file, tmp_file)
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
close_connections_and_drop_cmd(remote)
|
|
43
|
-
else
|
|
44
|
-
raise "DA ANALIZZARE QUANDO LA 13 disponibile....dropdb ha un force come parametro"
|
|
45
|
-
end
|
|
39
|
+
close_connections_and_drop_cmd(remote)
|
|
40
|
+
|
|
46
41
|
create_cmd(remote)
|
|
47
42
|
|
|
48
43
|
restore_cmd(remote, tmp_file)
|
|
@@ -125,23 +120,31 @@ module SwarmClusterCliOpe
|
|
|
125
120
|
|
|
126
121
|
end
|
|
127
122
|
|
|
128
|
-
|
|
129
123
|
# @param [EnvConfigs] config
|
|
130
124
|
def close_connections_and_drop_cmd(config)
|
|
125
|
+
|
|
131
126
|
cmd = []
|
|
132
|
-
cmd << "export PGPASSWORD=\"#{config.password}\" &&"
|
|
133
127
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
if Gem::Version.new(config.database_version) >= Gem::Version.new("13")
|
|
129
|
+
cmd << "export PGPASSWORD=\"#{config.password}\" &&"
|
|
130
|
+
cmd << 'dropdb --force --if-exists'
|
|
131
|
+
cmd << "-U #{config.username}"
|
|
132
|
+
cmd << config.database_name
|
|
137
133
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
cmd << 'psql'
|
|
141
|
-
cmd << "-U #{config.username}"
|
|
142
|
-
cmd << "postgres"
|
|
143
|
-
cmd
|
|
134
|
+
else
|
|
135
|
+
cmd << "export PGPASSWORD=\"#{config.password}\" &&"
|
|
144
136
|
|
|
137
|
+
sql = []
|
|
138
|
+
sql << "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '\"'\"'#{config.database_name}'\"'\"' AND pid <> pg_backend_pid();;"
|
|
139
|
+
sql << "DROP DATABASE IF EXISTS #{config.database_name};"
|
|
140
|
+
|
|
141
|
+
cmd << "echo \"#{sql.join(" ")}\" "
|
|
142
|
+
cmd << '|'
|
|
143
|
+
cmd << 'psql'
|
|
144
|
+
cmd << "-U #{config.username}"
|
|
145
|
+
cmd << "postgres"
|
|
146
|
+
|
|
147
|
+
end
|
|
145
148
|
logger.info { "CLOSE CONNECTIONS COMMAND: #{cmd.join(' ')}" }
|
|
146
149
|
config.container.exec("bash -c '#{cmd.join(' ')}'")
|
|
147
150
|
end
|
|
@@ -153,7 +156,6 @@ module SwarmClusterCliOpe
|
|
|
153
156
|
# PGPASSWORD='root' createdb -U root -h 0.0.0.0 -p 32790 development;
|
|
154
157
|
# PGPASSWORD='root' psql -U root -h 0.0.0.0 -p 32790 -d development < ./cortobio_production_new_2020-09-10-171742.sql
|
|
155
158
|
|
|
156
|
-
|
|
157
159
|
end
|
|
158
160
|
end
|
|
159
161
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swarm_cluster_cli_ope
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marino Bonetti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|