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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dd029f7881055cb38f098ec23ecab2e70e06f118c7d50cfd09d43d5c8c6ad28
4
- data.tar.gz: 24eff3b8de6a4a59b55dd749dcc3134785bfb2e1361aaec2fec1edc30a579875
3
+ metadata.gz: 4882191ef95d50ee90bc94d80a861d023c2cf118e7237e60856d5660115a2344
4
+ data.tar.gz: 4bff6764650781925126bef404deb11bfff26d3d9e9a93800781c3bb2ff8373b
5
5
  SHA512:
6
- metadata.gz: e6eca6142c30b5bcf43608eaf338aea4c6a71b37781b979e34f9028e1418f50c3188a02998e6f4b74111ec58c85eff6b04ad005c8dfa9a1085f653b10e9b37db
7
- data.tar.gz: d39a13d5a83b168f0ccb90b04309ca1f616dab646963a6a6b873da06fdbc883eeef7e758890aa486f4df06c211417ac00afd60ff843ee17e17421eb65bb6abff
6
+ metadata.gz: '04818ffeef0c5a34b36349825cc3f8fbcbb8eb04ce4f8c09c3bbf6bdf4f281d1b762819df7877969586337779f575fd661cf8b00ede3088ec2393d00695021e4'
7
+ data.tar.gz: dcdadf6a7c681eb1fe6a1164189daf968790d910c8f24f2f71cad7479fa30c531608edbf3fc14d5ce9f4e1c9185a7df2a5739ebb76f00b20cb641fc30a0aa2cf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.4.2
2
+
3
+ - Improved flexibility of commands
4
+ - Sync all objects when no tables specified
5
+
1
6
  # 0.4.1
2
7
 
3
8
  - Made `psql` version check more robust
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2018 Andrew Kane
3
+ Copyright (c) 2015-2019 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -302,6 +302,7 @@ bundle install
302
302
 
303
303
  createdb pgsync_test1
304
304
  createdb pgsync_test2
305
+ createdb pgsync_test3
305
306
 
306
307
  bundle exec rake
307
308
  ```
data/lib/pgsync/client.rb CHANGED
@@ -85,7 +85,8 @@ module PgSync
85
85
  end
86
86
 
87
87
  log "* Dumping schema"
88
- sync_schema(source, destination, tables)
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)
@@ -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
- # http://stackoverflow.com/a/20537829
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 && source[0..1] == "$(" && source[-1] == ")"
175
- command = source[2..-2]
176
- source = `#{command}`.chomp
177
- unless $?.success?
178
- raise PgSync::Error, "Command exited with non-zero status:\n#{command}"
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
@@ -1,3 +1,3 @@
1
1
  module PgSync
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
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.1
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: 2018-12-15 00:00:00.000000000 Z
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
- rubyforge_project:
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