pgsync 0.6.7 → 0.6.8

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: 4af2ef537f2130fb3b60ce705c17dc0ea2292a6d12f074ac14dafdc18e5419e8
4
- data.tar.gz: 441442b39578dd09b4cbe22a9514f3eda59b7876a8d0c1541eda39631ac9a757
3
+ metadata.gz: 07f27052ca6f110b7b6ace2ad5b56399876ee1e3905dd0fc21f6c7d459ec84ca
4
+ data.tar.gz: 897b2b49d184ba7adf4610c4bb3bd779102982ee0f42d1592fb7b4f5bcf1a5fd
5
5
  SHA512:
6
- metadata.gz: '0357909b28157593f8fcc21678efa53c767454c41a2f858b577da9e802aa29d49ffd3f8f835554098d670d82b018e27d7299a091e41022fd1b98a7eb1529232a'
7
- data.tar.gz: acb5faf68e112427b406b03285d1bf2aa1c42034a186c8a37b617670037f06156e8e8f5dbb222b5fac3ce97e2b6a9d69014be9ca9c9395230c0139028c91e194
6
+ metadata.gz: ae0a54b59689868a51a212436d064ac59431cd5fe86606031f7f20797fd2e66effac1d2387a2531700b7bc62a6909d2dc1091700fccebbf6631972e901d46166
7
+ data.tar.gz: 847b20e665fa5184975177c193dc0bf74b1c368008db663d69ba526602508c7d18cae61330487e892e8b0faf799966e74c8f5c2d7ffc1a23067bffb3b61f0b45
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.6.8 (2021-09-21)
2
+
3
+ - Fixed error when schema missing in destination with `--schema-first` and `--schema-only`
4
+
1
5
  ## 0.6.7 (2021-04-26)
2
6
 
3
7
  - Fixed connection security for `--schema-first` and `--schema-only` - [more info](https://github.com/ankane/pgsync/issues/121)
@@ -68,6 +68,23 @@ module PgSync
68
68
  execute("TRUNCATE #{quote_ident_full(table)} CASCADE")
69
69
  end
70
70
 
71
+ def schemas
72
+ @schemas ||= begin
73
+ query = <<~SQL
74
+ SELECT
75
+ schema_name
76
+ FROM
77
+ information_schema.schemata
78
+ ORDER BY 1
79
+ SQL
80
+ execute(query).map { |row| row["schema_name"] }
81
+ end
82
+ end
83
+
84
+ def create_schema(schema)
85
+ execute("CREATE SCHEMA #{quote_ident(schema)}")
86
+ end
87
+
71
88
  def triggers(table)
72
89
  query = <<~SQL
73
90
  SELECT
@@ -24,6 +24,8 @@ module PgSync
24
24
  spinner.auto_spin
25
25
  end
26
26
 
27
+ create_schemas if specify_tables?
28
+
27
29
  # if spinner, capture lines to show on error
28
30
  lines = []
29
31
  success =
@@ -68,7 +70,7 @@ module PgSync
68
70
 
69
71
  def dump_command
70
72
  cmd = ["pg_dump", "-Fc", "--verbose", "--schema-only", "--no-owner", "--no-acl"]
71
- if !opts[:all_schemas] || opts[:tables] || opts[:groups] || args[0] || opts[:exclude] || opts[:schemas]
73
+ if specify_tables?
72
74
  @tasks.each do |task|
73
75
  cmd.concat(["-t", task.quoted_table])
74
76
  end
@@ -81,5 +83,18 @@ module PgSync
81
83
  cmd << "--if-exists" if Gem::Version.new(pg_restore_version) >= Gem::Version.new("9.4.0")
82
84
  cmd.concat(["-d", @destination.url])
83
85
  end
86
+
87
+ # pg_dump -t won't create schemas (even with -n)
88
+ # not ideal that this happens outside restore transaction
89
+ def create_schemas
90
+ schemas = @tasks.map { |t| t.table.schema }.uniq - @destination.schemas
91
+ schemas.sort.each do |schema|
92
+ @destination.create_schema(schema)
93
+ end
94
+ end
95
+
96
+ def specify_tables?
97
+ !opts[:all_schemas] || opts[:tables] || opts[:groups] || args[0] || opts[:exclude] || opts[:schemas]
98
+ end
84
99
  end
85
100
  end
@@ -1,3 +1,3 @@
1
1
  module PgSync
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
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.6.7
4
+ version: 0.6.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: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.2.3
113
+ rubygems_version: 3.2.22
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Sync Postgres data between databases