pgsync 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07f27052ca6f110b7b6ace2ad5b56399876ee1e3905dd0fc21f6c7d459ec84ca
4
- data.tar.gz: 897b2b49d184ba7adf4610c4bb3bd779102982ee0f42d1592fb7b4f5bcf1a5fd
3
+ metadata.gz: ba1091cc780447fdf3369431b15d87cd3b6e47bb047f4a34e2a36a70bb873669
4
+ data.tar.gz: bf343a9fd3e785cb077953654656d51191827216b741b844736043bfaa2b7d8b
5
5
  SHA512:
6
- metadata.gz: ae0a54b59689868a51a212436d064ac59431cd5fe86606031f7f20797fd2e66effac1d2387a2531700b7bc62a6909d2dc1091700fccebbf6631972e901d46166
7
- data.tar.gz: 847b20e665fa5184975177c193dc0bf74b1c368008db663d69ba526602508c7d18cae61330487e892e8b0faf799966e74c8f5c2d7ffc1a23067bffb3b61f0b45
6
+ metadata.gz: f30e0cfdfa4a5f2f3d48db16d66dea9ff101025b8a95fd383f0eec8b60bce111d0f41cef64467c50df3d4820a55230e64f0f04e68ef09f40ea57d658b3584da6
7
+ data.tar.gz: 7feb71d51de95fba8d32d0080a43432a11f96080782aad0515dade6ce6f2b81def36f7b060a30aeeadcea14cc16dbf34fc1f94b02ebdb53c2453d1ff0ba6dd30
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.7.0 (2022-03-10)
2
+
3
+ - Changed `--defer-constraints` to `--defer-constraints-v1`
4
+ - Changed `--defer-constraints-v2` to `--defer-constraints`
5
+ - Fixed unknown alias error with Ruby 3.1
6
+ - Dropped support for Ruby < 2.5
7
+
1
8
  ## 0.6.8 (2021-09-21)
2
9
 
3
10
  - Fixed error when schema missing in destination with `--schema-first` and `--schema-only`
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2020 Andrew Kane
3
+ Copyright (c) 2015-2022 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
@@ -19,7 +19,7 @@ pgsync is a command line tool. To install, run:
19
19
  gem install pgsync
20
20
  ```
21
21
 
22
- This will give you the `pgsync` command. If installation fails, you may need to install [dependencies](#dependencies).
22
+ This will give you the `pgsync` command. You can also install it with [Homebrew](#homebrew). If installation fails, you may need to install [dependencies](#dependencies).
23
23
 
24
24
  ## Setup
25
25
 
@@ -205,7 +205,7 @@ Foreign keys can make it difficult to sync data. Three options are:
205
205
  To defer constraints, use:
206
206
 
207
207
  ```sh
208
- pgsync --defer-constraints-v2
208
+ pgsync --defer-constraints
209
209
  ```
210
210
 
211
211
  To manually specify the order of tables, use `--jobs 1` so tables are synced one-at-a-time.
@@ -347,6 +347,14 @@ Bundler.with_unbundled_env do
347
347
  end
348
348
  ```
349
349
 
350
+ ## Homebrew
351
+
352
+ On Mac, you can use:
353
+
354
+ ```sh
355
+ brew install ankane/brew/pgsync
356
+ ```
357
+
350
358
  ## Dependencies
351
359
 
352
360
  If installation fails, your system may be missing Ruby or libpq.
data/lib/pgsync/client.rb CHANGED
@@ -11,6 +11,7 @@ module PgSync
11
11
  result = Slop::Parser.new(slop_options).parse(@args)
12
12
  arguments = result.arguments
13
13
  options = result.to_h
14
+ options[:defer_constraints_v2] ||= options[:defer_constraints]
14
15
 
15
16
  raise Error, "Specify either --db or --config, not both" if options[:db] && options[:config]
16
17
  raise Error, "Cannot use --overwrite with --in-batches" if options[:overwrite] && options[:in_batches]
@@ -59,12 +60,13 @@ module PgSync
59
60
 
60
61
  o.separator ""
61
62
  o.separator "Foreign key options:"
62
- o.boolean "--defer-constraints-v2", "defer constraints", default: false
63
+ o.boolean "--defer-constraints", "defer constraints", default: false
63
64
  o.boolean "--disable-integrity", "disable foreign key triggers", default: false
64
65
  o.integer "-j", "--jobs", "number of tables to sync at a time"
65
66
 
66
- # replaced by v2
67
- o.boolean "--defer-constraints", "defer constraints", default: false, help: false
67
+ # legacy
68
+ o.boolean "--defer-constraints-v1", "defer constraints", default: false, help: false
69
+ o.boolean "--defer-constraints-v2", "defer constraints", default: false, help: false
68
70
  # private, for testing
69
71
  o.boolean "--disable-integrity-v2", "disable foreign key triggers", default: false, help: false
70
72
 
data/lib/pgsync/sync.rb CHANGED
@@ -78,7 +78,16 @@ module PgSync
78
78
  file = config_file
79
79
  if file
80
80
  begin
81
- YAML.load_file(file) || {}
81
+ # same options as YAML.load_file
82
+ File.open(file, "r:bom|utf-8") do |f|
83
+ # changed to keyword arguments in 3.1.0.pre1
84
+ # https://github.com/ruby/psych/commit/c79ed445b4b3f8c9adf3da13bca3c976ddfae258
85
+ if Psych::VERSION.to_f >= 3.1
86
+ YAML.safe_load(f, aliases: true, filename: file) || {}
87
+ else
88
+ YAML.safe_load(f, [], [], true, file) || {}
89
+ end
90
+ end
82
91
  rescue Psych::SyntaxError => e
83
92
  raise Error, e.message
84
93
  rescue Errno::ENOENT
@@ -125,7 +125,7 @@ module PgSync
125
125
  end
126
126
 
127
127
  # for non-deferrable constraints
128
- if opts[:defer_constraints]
128
+ if opts[:defer_constraints_v1]
129
129
  constraints = non_deferrable_constraints(destination)
130
130
  constraints = tasks.flat_map { |t| constraints[t.table] || [] }
131
131
  warning "Non-deferrable constraints: #{constraints.join(", ")}" if constraints.any?
@@ -230,7 +230,7 @@ module PgSync
230
230
 
231
231
  # disable multiple jobs for defer constraints and disable integrity
232
232
  # so we can use a transaction to ensure a consistent snapshot
233
- if opts[:debug] || opts[:in_batches] || opts[:defer_constraints] || opts[:defer_constraints_v2] || opts[:disable_integrity] || opts[:disable_integrity_v2]
233
+ if opts[:debug] || opts[:in_batches] || opts[:defer_constraints_v1] || opts[:defer_constraints_v2] || opts[:disable_integrity] || opts[:disable_integrity_v2]
234
234
  warning "--jobs ignored" if jobs
235
235
  jobs = 0
236
236
  end
@@ -268,7 +268,7 @@ module PgSync
268
268
  source.transaction do
269
269
  yield
270
270
  end
271
- elsif opts[:defer_constraints] || opts[:defer_constraints_v2]
271
+ elsif opts[:defer_constraints_v1] || opts[:defer_constraints_v2]
272
272
  destination.transaction do
273
273
  if opts[:defer_constraints_v2]
274
274
  table_constraints = non_deferrable_constraints(destination)
data/lib/pgsync/task.rb CHANGED
@@ -149,7 +149,7 @@ module PgSync
149
149
  destination.execute("INSERT INTO #{quoted_table} (#{fields}) (SELECT #{fields} FROM #{quote_ident_full(temp_table)}) ON CONFLICT (#{on_conflict}) DO #{action}")
150
150
  else
151
151
  # use delete instead of truncate for foreign keys
152
- if opts[:defer_constraints] || opts[:defer_constraints_v2]
152
+ if opts[:defer_constraints_v1] || opts[:defer_constraints_v2]
153
153
  destination.execute("DELETE FROM #{quoted_table}")
154
154
  else
155
155
  destination.truncate(table)
@@ -1,3 +1,3 @@
1
1
  module PgSync
2
- VERSION = "0.6.8"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/pgsync.rb CHANGED
@@ -5,12 +5,12 @@ require "slop"
5
5
  require "tty-spinner"
6
6
 
7
7
  # stdlib
8
+ require "open3"
8
9
  require "set"
9
10
  require "shellwords"
10
11
  require "tempfile"
11
12
  require "uri"
12
13
  require "yaml"
13
- require "open3"
14
14
 
15
15
  # modules
16
16
  require "pgsync/utils"
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.6.8
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description:
70
- email: andrew@chartkick.com
70
+ email: andrew@ankane.org
71
71
  executables:
72
72
  - pgsync
73
73
  extensions: []
@@ -103,14 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '2.2'
106
+ version: '2.5'
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.2.22
113
+ rubygems_version: 3.3.7
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Sync Postgres data between databases