pgsync 0.7.1 → 0.7.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/CHANGELOG.md +6 -0
- data/README.md +17 -4
- data/lib/pgsync/schema_sync.rb +5 -3
- data/lib/pgsync/sync.rb +2 -2
- data/lib/pgsync/table_sync.rb +2 -2
- data/lib/pgsync/task.rb +6 -2
- data/lib/pgsync/utils.rb +4 -0
- data/lib/pgsync/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: 2005fe5d8c3aa978ebb5f85d2076e81ee1022564382a6401437c5c683a4968a2
|
4
|
+
data.tar.gz: 333ac51419e6e6ee8091a14ee78e4e8d1aa7559bdbd13384a27352f35641e9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a90323a6a4d2829c0e62c2d3d78245e9978a1c051da7c0913ce1f9a91a4f01bd0a6d80d14d2dbc49b63a0943c492e71d0191a458d3a2e16f0480c59078b7ee4
|
7
|
+
data.tar.gz: 8d9fa803daf091baa26afc26eba40bdc720b5836651c101bd53ce0e24f9fa9179f49577b61426e1a3315a5bb7fd90c815bfab54a40fb90376756c10392cccef4
|
data/CHANGELOG.md
CHANGED
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. You can also install it with [Homebrew](#homebrew). 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) or [Docker](#docker). If installation fails, you may need to install [dependencies](#dependencies).
|
23
23
|
|
24
24
|
## Setup
|
25
25
|
|
@@ -347,14 +347,27 @@ Bundler.with_unbundled_env do
|
|
347
347
|
end
|
348
348
|
```
|
349
349
|
|
350
|
-
##
|
350
|
+
## Additional Installation Methods
|
351
351
|
|
352
|
-
|
352
|
+
### Homebrew
|
353
|
+
|
354
|
+
With Homebrew, you can use:
|
353
355
|
|
354
356
|
```sh
|
355
357
|
brew install ankane/brew/pgsync
|
356
358
|
```
|
357
359
|
|
360
|
+
### Docker
|
361
|
+
|
362
|
+
Get the [Docker image](https://hub.docker.com/r/ankane/pgsync) with:
|
363
|
+
|
364
|
+
```sh
|
365
|
+
docker pull ankane/pgsync
|
366
|
+
alias pgsync="docker run --rm ankane/pgsync"
|
367
|
+
```
|
368
|
+
|
369
|
+
This will give you the `pgsync` command.
|
370
|
+
|
358
371
|
## Dependencies
|
359
372
|
|
360
373
|
If installation fails, your system may be missing Ruby or libpq.
|
@@ -362,7 +375,7 @@ If installation fails, your system may be missing Ruby or libpq.
|
|
362
375
|
On Mac, run:
|
363
376
|
|
364
377
|
```sh
|
365
|
-
brew install
|
378
|
+
brew install libpq
|
366
379
|
```
|
367
380
|
|
368
381
|
On Ubuntu, run:
|
data/lib/pgsync/schema_sync.rb
CHANGED
@@ -62,8 +62,10 @@ module PgSync
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
# --if-exists introduced in Postgres 9.4
|
66
|
+
# not ideal, but simpler than trying to parse version
|
67
|
+
def supports_if_exists?
|
68
|
+
`pg_restore --help`.include?("--if-exists")
|
67
69
|
rescue Errno::ENOENT
|
68
70
|
raise Error, "pg_restore not found"
|
69
71
|
end
|
@@ -80,7 +82,7 @@ module PgSync
|
|
80
82
|
|
81
83
|
def restore_command
|
82
84
|
cmd = ["pg_restore", "--verbose", "--no-owner", "--no-acl", "--clean"]
|
83
|
-
cmd << "--if-exists" if
|
85
|
+
cmd << "--if-exists" if supports_if_exists?
|
84
86
|
cmd.concat(["-d", @destination.url])
|
85
87
|
end
|
86
88
|
|
data/lib/pgsync/sync.rb
CHANGED
@@ -8,7 +8,7 @@ module PgSync
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def perform
|
11
|
-
started_at =
|
11
|
+
started_at = monotonic_time
|
12
12
|
|
13
13
|
args = @arguments
|
14
14
|
opts = @options
|
@@ -129,7 +129,7 @@ module PgSync
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def log_completed(started_at)
|
132
|
-
time =
|
132
|
+
time = monotonic_time - started_at
|
133
133
|
message = "Completed in #{time.round(1)}s"
|
134
134
|
log colorize(message, :green)
|
135
135
|
end
|
data/lib/pgsync/table_sync.rb
CHANGED
@@ -189,11 +189,11 @@ module PgSync
|
|
189
189
|
log message.sub(":spinner", "⠋")
|
190
190
|
end
|
191
191
|
|
192
|
-
started_at[task] =
|
192
|
+
started_at[task] = monotonic_time
|
193
193
|
end
|
194
194
|
|
195
195
|
finish = lambda do |task, i, result|
|
196
|
-
time = (
|
196
|
+
time = (monotonic_time - started_at[task]).round(1)
|
197
197
|
|
198
198
|
success = result[:status] == "success"
|
199
199
|
|
data/lib/pgsync/task.rb
CHANGED
@@ -88,7 +88,7 @@ module PgSync
|
|
88
88
|
|
89
89
|
copy_to_command = "COPY (SELECT #{copy_fields} FROM #{quoted_table}#{sql_clause}) TO STDOUT"
|
90
90
|
if opts[:in_batches]
|
91
|
-
raise Error, "
|
91
|
+
raise Error, "Primary key required for --in-batches" if primary_key.empty?
|
92
92
|
primary_key = primary_key.first
|
93
93
|
|
94
94
|
destination.truncate(table) if opts[:truncate]
|
@@ -125,7 +125,11 @@ module PgSync
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
elsif !opts[:truncate] && (opts[:overwrite] || opts[:preserve] || !sql_clause.empty?)
|
128
|
-
|
128
|
+
if primary_key.empty?
|
129
|
+
raise Error, "Primary key required for --overwrite" if opts[:overwrite]
|
130
|
+
raise Error, "Primary key required for --preserve" if opts[:preserve]
|
131
|
+
raise Error, "Primary key required to sync specific rows"
|
132
|
+
end
|
129
133
|
|
130
134
|
# create a temp table
|
131
135
|
temp_table = "pgsync_#{rand(1_000_000_000)}"
|
data/lib/pgsync/utils.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.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: 2022-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|