pgsync 0.3.7 → 0.3.8

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
  SHA1:
3
- metadata.gz: 68da22be015e5ff66ecc722c7e2cf19a91b77b3c
4
- data.tar.gz: 76498a3252a89668dc9b1e9f65dd152dedc4a727
3
+ metadata.gz: 50eb1d7496a1a6025abd64cb19087781c87deed7
4
+ data.tar.gz: 6f5c579ff553997d664bc142f91524b2263bf622
5
5
  SHA512:
6
- metadata.gz: 71f0e8b384f7a07706e6ad796c407f212cd0eb1dfe04bebffb278e0208e26e755a3352ef1ffd8d7681d868818df30312297d9fd60a5373048524236cdf2d6238
7
- data.tar.gz: cdae25c85d546e866cd1a8558ab1c76bd548ed0a8d41ff049644e2cf29661e5f565a803f69a848217f482163aa4c3e49bc1680098f45fcbdb125ae443be50040
6
+ metadata.gz: c814c85dc2e5d4f9eab683954b0a9473d693e4fa0299b52c75e1525f380380630956d2c50bb0a3212e62eb053bfe4391a108bcb97b4ae51fc3e275b0f1258df7
7
+ data.tar.gz: 482f1923f915f5123f334b92d0ce2a3444892ed314994aec73b5b8c551ead29dc365e21275b3ec257d48f5c1d4aa0b922db1bcb11f0ccea6478bfeae8ce631bc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.8
2
+
3
+ - Added Windows support
4
+ - Added `random_string` and `random_number` replacement options
5
+ - Improved performance of `--in-batches` for large tables
6
+
1
7
  # 0.3.7
2
8
 
3
9
  - Fixed non-lowercase tables and columns
data/README.md CHANGED
@@ -166,6 +166,8 @@ Options for replacement are:
166
166
  - random_date
167
167
  - random_time
168
168
  - random_ip
169
+ - random_string
170
+ - random_number
169
171
  - untouched
170
172
 
171
173
  ## Multiple Databases
@@ -198,6 +200,14 @@ pgsync large_table --in-batches
198
200
 
199
201
  The script will resume where it left off when run again, making it great for backfills.
200
202
 
203
+ ## Foreign Keys
204
+
205
+ By default, tables are copied in parallel. If you use foreign keys, this can cause violations. You can specify tables to be copied serially with:
206
+
207
+ ```sh
208
+ pgsync group1 --debug
209
+ ```
210
+
201
211
  ## Reference
202
212
 
203
213
  Help
@@ -1,3 +1,3 @@
1
1
  module PgSync
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
data/lib/pgsync.rb CHANGED
@@ -10,6 +10,7 @@ require "fileutils"
10
10
  require "tempfile"
11
11
  require "cgi"
12
12
  require "shellwords"
13
+ require "thread" # windows only
13
14
 
14
15
  module URI
15
16
  class POSTGRESQL < Generic
@@ -26,7 +27,7 @@ module PgSync
26
27
  $stdout.sync = true
27
28
  @exit = false
28
29
  @arguments, @options = parse_args(args)
29
- @mutex = MultiProcessing::Mutex.new
30
+ @mutex = windows? ? Mutex.new : MultiProcessing::Mutex.new
30
31
  end
31
32
 
32
33
  # TODO clean up this mess
@@ -190,11 +191,11 @@ module PgSync
190
191
 
191
192
  to_connection.exec("TRUNCATE #{quote_ident(table)} CASCADE") if opts[:truncate]
192
193
 
193
- from_max_id = max_id(from_connection, table, primary_key, sql_clause)
194
- to_max_id = max_id(to_connection, table, primary_key, sql_clause) + 1
194
+ from_max_id = max_id(from_connection, table, primary_key)
195
+ to_max_id = max_id(to_connection, table, primary_key) + 1
195
196
 
196
197
  if to_max_id == 1
197
- from_min_id = min_id(from_connection, table, primary_key, sql_clause)
198
+ from_min_id = min_id(from_connection, table, primary_key)
198
199
  to_max_id = from_min_id if from_min_id > 0
199
200
  end
200
201
 
@@ -465,6 +466,8 @@ Options:}
465
466
  "unique_secret" => "'secret' || #{table}.id",
466
467
  "random_ip" => "'127.0.0.1'",
467
468
  "random_letter" => "'A'",
469
+ "random_string" => "right(md5(random()::text),10)",
470
+ "random_number" => "(RANDOM() * 1000000)::int",
468
471
  "null" => "NULL",
469
472
  nil => "NULL"
470
473
  }
@@ -565,7 +568,9 @@ Options:}
565
568
  if @options[:debug] || @options[:in_batches]
566
569
  tables.each(&block)
567
570
  else
568
- Parallel.each(tables, &block)
571
+ options = {}
572
+ options[:in_threads] = 4 if windows?
573
+ Parallel.each(tables, options, &block)
569
574
  end
570
575
  end
571
576
 
@@ -669,5 +674,9 @@ Options:}
669
674
  time = Time.now - start_time
670
675
  log "Completed in #{time.round(1)}s"
671
676
  end
677
+
678
+ def windows?
679
+ Gem.win_platform?
680
+ end
672
681
  end
673
682
  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.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-30 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.6.11
151
+ rubygems_version: 2.6.13
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Sync Postgres data between databases