pgsync 0.7.4 → 0.8.1

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: bc4b2b6dcbfc310f47e5309a6e8b1f97498f57ff2984ed80ff95d9543904a364
4
- data.tar.gz: 330f54583496a39c3b6dacbbeaecbb478f016dfb6d4ca489291ba948c10b3498
3
+ metadata.gz: 7c19e7ffca9a1fa633d852e3a8462034fc9c376ae19230ab06cedc52e7bfe5d8
4
+ data.tar.gz: b4857744ee1501f9cef660b7ff1e20fbd69cde719edf3ae350cb9e148997204f
5
5
  SHA512:
6
- metadata.gz: 7c7fd83f3b69b6ed6289d71df0fdae65e5a24814eead69256a83fae5671079d19259839312e2fbd974654d8b374c23c9709efc59566af23208d6006526cef6cc
7
- data.tar.gz: 32015c26cc99e4c025a9ee824eaad65ba289164206348d4f5f3fa76bab3e2bcba8bedf695e135439125652c0d6a27bb8aacd14eab75ac970d24a3219554eb910
6
+ metadata.gz: 79a7d691465a579992e8191f7144e0e0991b649b080478aeb4853a8fea97b9ae9772fea34152cd642fc0d7cd060640797b043371a3f8e81e756c57f57bb442d8
7
+ data.tar.gz: b21286f1c75948283952ef80155b15f84af79a05f08197fd61aceafc84e15db867a5feb7403f451fe5395536367ec562b0ee6e38b6be613773085ffcaca5c9fa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.8.1 (2025-09-12)
2
+
3
+ - Fixed local destination detection when no host present with pg 1.6+
4
+
5
+ ## 0.8.0 (2024-07-10)
6
+
7
+ - Added Docker image for `linux/arm64`
8
+ - Fixed warning with Ruby 3.3
9
+ - Dropped support for Ruby < 2.7
10
+
1
11
  ## 0.7.4 (2023-03-06)
2
12
 
3
13
  - Fixed issue with slop 4.10.0
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2023 Andrew Kane
3
+ Copyright (c) 2015-2025 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
@@ -9,7 +9,7 @@ Sync data from one Postgres database to another (like `pg_dump`/`pg_restore`). D
9
9
 
10
10
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
11
11
 
12
- [![Build Status](https://github.com/ankane/pgsync/workflows/build/badge.svg?branch=master)](https://github.com/ankane/pgsync/actions)
12
+ [![Build Status](https://github.com/ankane/pgsync/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/pgsync/actions)
13
13
 
14
14
  ## Installation
15
15
 
@@ -27,6 +27,8 @@ You can also install it with Homebrew:
27
27
  brew install pgsync
28
28
  ```
29
29
 
30
+ Or [Docker](#docker).
31
+
30
32
  ## Setup
31
33
 
32
34
  In your project directory, run:
@@ -252,6 +254,8 @@ For extremely large, append-only tables, sync in batches.
252
254
  pgsync large_table --in-batches
253
255
  ```
254
256
 
257
+ Note: This requires the table to have a numeric, increasing primary key
258
+
255
259
  The script will resume where it left off when run again, making it great for backfills.
256
260
 
257
261
  ## Connection Security
@@ -367,11 +371,13 @@ Get the [Docker image](https://hub.docker.com/r/ankane/pgsync) with:
367
371
 
368
372
  ```sh
369
373
  docker pull ankane/pgsync
370
- alias pgsync="docker run -ti ankane/pgsync"
374
+ alias pgsync="docker run -ti --rm -v .:/conf -w /conf ankane/pgsync"
371
375
  ```
372
376
 
373
377
  This will give you the `pgsync` command.
374
378
 
379
+ For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires `--add-host=host.docker.internal:host-gateway`).
380
+
375
381
  ## Dependencies
376
382
 
377
383
  If installation fails, your system may be missing Ruby or libpq.
@@ -15,7 +15,12 @@ module PgSync
15
15
  end
16
16
 
17
17
  def local?
18
- !host || %w(localhost 127.0.0.1).include?(host)
18
+ socket? || %w(localhost 127.0.0.1).include?(host)
19
+ end
20
+
21
+ # host can be "/var/run/postgresql,/run/postgresql,/tmp" on Linux with pg 1.6+
22
+ def socket?
23
+ !host || host.split(",").all? { |v| v.start_with?("/") }
19
24
  end
20
25
 
21
26
  def host
@@ -104,7 +109,7 @@ module PgSync
104
109
  @conn ||= begin
105
110
  begin
106
111
  ENV["PGCONNECT_TIMEOUT"] ||= "3"
107
- if @url =~ /\Apostgres(ql)?:\/\//
112
+ if @url.start_with?("postgres://", "postgresql://")
108
113
  config = @url
109
114
  else
110
115
  config = {dbname: @url}
data/lib/pgsync/sync.rb CHANGED
@@ -124,7 +124,7 @@ module PgSync
124
124
  end
125
125
 
126
126
  def print_description(prefix, source)
127
- location = " on #{source.host}:#{source.port}" if source.host
127
+ location = " on #{source.host}:#{source.port}" if !source.socket?
128
128
  log "#{prefix}: #{source.dbname}#{location}"
129
129
  end
130
130
 
data/lib/pgsync/task.rb CHANGED
@@ -229,7 +229,7 @@ module PgSync
229
229
 
230
230
  # TODO better performance
231
231
  def rule_match?(table, column, rule)
232
- regex = Regexp.new('\A' + Regexp.escape(rule).gsub('\*','[^\.]*') + '\z')
232
+ regex = Regexp.new('\A' + Regexp.escape(rule).gsub('\*', '[^\.]*') + '\z')
233
233
  regex.match(column) || regex.match("#{table.name}.#{column}") || regex.match("#{table.schema}.#{table.name}.#{column}")
234
234
  end
235
235
 
@@ -72,7 +72,7 @@ module PgSync
72
72
 
73
73
  tables =
74
74
  if value.include?("*")
75
- regex = Regexp.new('\A' + Regexp.escape(value).gsub('\*','[^\.]*') + '\z')
75
+ regex = Regexp.new('\A' + Regexp.escape(value).gsub('\*', '[^\.]*') + '\z')
76
76
  shared_tables.select { |t| regex.match(t.full_name) || regex.match(t.name) }
77
77
  else
78
78
  [to_table(value)]
@@ -145,7 +145,7 @@ module PgSync
145
145
 
146
146
  to_arr(opts[:exclude]).each do |value|
147
147
  if value.include?("*")
148
- regex = Regexp.new('\A' + Regexp.escape(value).gsub('\*','[^\.]*') + '\z')
148
+ regex = Regexp.new('\A' + Regexp.escape(value).gsub('\*', '[^\.]*') + '\z')
149
149
  tables.reject! { |t| regex.match(t.full_name) || regex.match(t.name) }
150
150
  else
151
151
  tables -= [fully_resolve(to_table(value), error: false)].compact
@@ -1,3 +1,3 @@
1
1
  module PgSync
2
- VERSION = "0.7.4"
2
+ VERSION = "0.8.1"
3
3
  end
data/lib/pgsync.rb CHANGED
@@ -13,18 +13,18 @@ require "uri"
13
13
  require "yaml"
14
14
 
15
15
  # modules
16
- require "pgsync/utils"
17
- require "pgsync/client"
18
- require "pgsync/data_source"
19
- require "pgsync/init"
20
- require "pgsync/schema_sync"
21
- require "pgsync/sequence"
22
- require "pgsync/sync"
23
- require "pgsync/table"
24
- require "pgsync/table_sync"
25
- require "pgsync/task"
26
- require "pgsync/task_resolver"
27
- require "pgsync/version"
16
+ require_relative "pgsync/utils"
17
+ require_relative "pgsync/client"
18
+ require_relative "pgsync/data_source"
19
+ require_relative "pgsync/init"
20
+ require_relative "pgsync/schema_sync"
21
+ require_relative "pgsync/sequence"
22
+ require_relative "pgsync/sync"
23
+ require_relative "pgsync/table"
24
+ require_relative "pgsync/table_sync"
25
+ require_relative "pgsync/task"
26
+ require_relative "pgsync/task_resolver"
27
+ require_relative "pgsync/version"
28
28
 
29
29
  module PgSync
30
30
  class Error < StandardError; end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bigdecimal
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: parallel
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +79,6 @@ dependencies:
66
79
  - - ">="
67
80
  - !ruby/object:Gem::Version
68
81
  version: '0'
69
- description:
70
82
  email: andrew@ankane.org
71
83
  executables:
72
84
  - pgsync
@@ -95,7 +107,6 @@ homepage: https://github.com/ankane/pgsync
95
107
  licenses:
96
108
  - MIT
97
109
  metadata: {}
98
- post_install_message:
99
110
  rdoc_options: []
100
111
  require_paths:
101
112
  - lib
@@ -103,15 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
114
  requirements:
104
115
  - - ">="
105
116
  - !ruby/object:Gem::Version
106
- version: '2.5'
117
+ version: '2.7'
107
118
  required_rubygems_version: !ruby/object:Gem::Requirement
108
119
  requirements:
109
120
  - - ">="
110
121
  - !ruby/object:Gem::Version
111
122
  version: '0'
112
123
  requirements: []
113
- rubygems_version: 3.4.6
114
- signing_key:
124
+ rubygems_version: 3.6.9
115
125
  specification_version: 4
116
126
  summary: Sync Postgres data between databases
117
127
  test_files: []