pgsync 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pgsync might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -0
- data/lib/pgsync/client.rb +6 -3
- data/lib/pgsync/data_source.rb +12 -8
- data/lib/pgsync/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4882191ef95d50ee90bc94d80a861d023c2cf118e7237e60856d5660115a2344
|
4
|
+
data.tar.gz: 4bff6764650781925126bef404deb11bfff26d3d9e9a93800781c3bb2ff8373b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04818ffeef0c5a34b36349825cc3f8fbcbb8eb04ce4f8c09c3bbf6bdf4f281d1b762819df7877969586337779f575fd661cf8b00ede3088ec2393d00695021e4'
|
7
|
+
data.tar.gz: dcdadf6a7c681eb1fe6a1164189daf968790d910c8f24f2f71cad7479fa30c531608edbf3fc14d5ce9f4e1c9185a7df2a5739ebb76f00b20cb641fc30a0aa2cf
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/lib/pgsync/client.rb
CHANGED
@@ -85,7 +85,8 @@ module PgSync
|
|
85
85
|
end
|
86
86
|
|
87
87
|
log "* Dumping schema"
|
88
|
-
|
88
|
+
schema_tables = tables if !opts[:all_schemas] || opts[:tables] || opts[:groups] || args[0] || opts[:exclude]
|
89
|
+
sync_schema(source, destination, schema_tables)
|
89
90
|
end
|
90
91
|
|
91
92
|
unless opts[:schema_only]
|
@@ -145,10 +146,12 @@ module PgSync
|
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
148
|
-
def sync_schema(source, destination, tables)
|
149
|
+
def sync_schema(source, destination, tables = nil)
|
149
150
|
dump_command = source.dump_command(tables)
|
150
151
|
restore_command = destination.restore_command
|
151
|
-
system("#{dump_command} | #{restore_command}")
|
152
|
+
unless system("#{dump_command} | #{restore_command}")
|
153
|
+
raise PgSync::Error, "Schema sync returned non-zero exit code"
|
154
|
+
end
|
152
155
|
end
|
153
156
|
|
154
157
|
def parse_args(args)
|
data/lib/pgsync/data_source.rb
CHANGED
@@ -45,7 +45,7 @@ module PgSync
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def sequences(table, columns)
|
48
|
-
execute("SELECT #{columns.map { |f| "pg_get_serial_sequence(#{escape("#{quote_ident_full(table)}")}, #{escape(f)}) AS #{f}" }.join(", ")}")[0].values.compact
|
48
|
+
execute("SELECT #{columns.map { |f| "pg_get_serial_sequence(#{escape("#{quote_ident_full(table)}")}, #{escape(f)}) AS #{quote_ident(f)}" }.join(", ")}")[0].values.compact
|
49
49
|
end
|
50
50
|
|
51
51
|
def max_id(table, primary_key, sql_clause = nil)
|
@@ -64,7 +64,7 @@ module PgSync
|
|
64
64
|
execute("TRUNCATE #{quote_ident_full(table)} CASCADE")
|
65
65
|
end
|
66
66
|
|
67
|
-
#
|
67
|
+
# https://stackoverflow.com/a/20537829
|
68
68
|
def primary_key(table)
|
69
69
|
query = <<-SQL
|
70
70
|
SELECT
|
@@ -111,7 +111,7 @@ module PgSync
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def dump_command(tables)
|
114
|
-
tables = tables.keys.map { |t| "-t #{Shellwords.escape(quote_ident_full(t))}" }.join(" ")
|
114
|
+
tables = tables ? tables.keys.map { |t| "-t #{Shellwords.escape(quote_ident_full(t))}" }.join(" ") : ""
|
115
115
|
"pg_dump -Fc --verbose --schema-only --no-owner --no-acl #{tables} -d #{@url}"
|
116
116
|
end
|
117
117
|
|
@@ -171,11 +171,15 @@ module PgSync
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def resolve_url(source)
|
174
|
-
if source
|
175
|
-
|
176
|
-
source
|
177
|
-
|
178
|
-
|
174
|
+
if source
|
175
|
+
source = source.dup
|
176
|
+
source.gsub!(/\$\([^)]+\)/) do |m|
|
177
|
+
command = m[2..-2]
|
178
|
+
result = `#{command}`.chomp
|
179
|
+
unless $?.success?
|
180
|
+
raise PgSync::Error, "Command exited with non-zero status:\n#{command}"
|
181
|
+
end
|
182
|
+
result
|
179
183
|
end
|
180
184
|
end
|
181
185
|
source
|
data/lib/pgsync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multiprocessing
|
@@ -145,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.7.6
|
148
|
+
rubygems_version: 3.0.3
|
150
149
|
signing_key:
|
151
150
|
specification_version: 4
|
152
151
|
summary: Sync Postgres data between databases
|