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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deeeb31f5b17f54bd476bb6cc8100c91dbba91386188ee468e14b1d50c36b99a
4
- data.tar.gz: d6cd6932874bd1d393b4c975e1978f64db2870f3705bb3e243f4792114c60a42
3
+ metadata.gz: 0c8d4d620c7c8929ca7606a553347601906ebdf99c13ac77c103ee94e4d46c74
4
+ data.tar.gz: cb045c6a4f21ba1482e79b1d810476677c509ac737cc3ef000bd68afb34ea5eb
5
5
  SHA512:
6
- metadata.gz: 694ec83f00a6c979fbb1f525d02194d3bdb58cd6a91239a511774d1d3ef9a3a38cd9068edcd3757a2318cc3f863b6c362692519500cd4d4436f431fa3a091320
7
- data.tar.gz: 3bcb05e5402cf1750908310b29fa930424da6afb74f2157978989e0a7872f94b6090122e0d7bd1568b8ef408bf75d1dc0cc1ac12abadda1416b1bc372985346e
6
+ metadata.gz: 34772d9e2eb49263ec059a78bcbaa75629043f3d58b2c47c15c8061c430f995d6c5af6100b66c63781b17d450e012574f32a3c48228b24e2c51fc587904204e6
7
+ data.tar.gz: 1f59ee9abaf08937a09f26e6f0d7c77d88b595154aac0a0b9399299a4dc2bb7ffb59c7c5906d4fbcdf9d69967ccbc8765fee58e64334544f19a48267fb93d75e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swarm_cluster_cli_ope (0.5.1)
4
+ swarm_cluster_cli_ope (0.5.2)
5
5
  activesupport
6
6
  open4
7
7
  thor (~> 1.0)
@@ -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
- close_connections_and_drop_cmd(local)
18
- else
19
- raise "DA ANALIZZARE QUANDO LA 13 disponibile....dropdb ha un force come parametro"
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
- # drop old db and recreate
41
- if Gem::Version.new(local.database_version) <= Gem::Version.new("12")
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
- sql = []
135
- 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();;"
136
- sql << "DROP DATABASE IF EXISTS #{config.database_name};"
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
- cmd << "echo \"#{sql.join(" ")}\" "
139
- cmd << '|'
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
@@ -1,3 +1,3 @@
1
1
  module SwarmClusterCliOpe
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  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.1
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: 2020-11-13 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor