exwiw 0.4.7 → 0.4.9

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: 6bf23b63e169e4f28dceda8611fe1dc599ed3fba7565a063ac11d7e66e84816e
4
- data.tar.gz: 4768cb5990bc6bb534e38bf458d814ad7be4ff57cc4ecb02565aae245078a7d1
3
+ metadata.gz: b096127aa5a8f1a530af7967ac092c11ab7dd57a88ddb82697386d9ac1791e3d
4
+ data.tar.gz: 519ffff515c719d245bb32b9c1b0a64c6ff988502bc39a6af661962506f199be
5
5
  SHA512:
6
- metadata.gz: bd2b11ab17de73e205639bc917cdd4bff23a793caa282c23f1a987b3391a6bc1550e65078924f82c6e63bdc03c22a9e37b0b1977c2602f5fbe0940b68dd92c13
7
- data.tar.gz: 78681a8c80263454d9bcaef29282de2bf1853b478dd2025382b2a0e4dfe089ea14af8dd970cd0127c8ddf2b71f9a3306024959303052102592203487d387e5a7
6
+ metadata.gz: 141955fba03d98e9cddead32de182db1d4e116b2ef758723478528c552ff27eadd6f88ef96587c14c543caaebf16accaa88c62a0e0c84d65e0c3d0abee3d0574
7
+ data.tar.gz: 2f284c6753f957a58bbbaa4736a3fed95e55263b6b15b3434cefa70b0de0907fb3c12ce770c58c1cf94fe757ee962d5d27e1a97cff62221a9f756c2a99c70947
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.4.9] - 2026-06-11
6
+
7
+ ### Fixed
8
+
9
+ - PostgreSQL: schema dump now filters cloud-provider-managed extensions (`google_%`, `rds_%`, `aiven_%`) and wraps remaining `CREATE EXTENSION` statements in exception handling (`EXCEPTION WHEN feature_not_supported THEN NULL`), so dumps extracted from GCP Cloud SQL can be restored on AWS RDS without manual intervention.
10
+
11
+ ## [0.4.8] - 2026-06-11
12
+
13
+ ### Added
14
+
15
+ - PostgreSQL: schema dump now includes `CREATE EXTENSION IF NOT EXISTS` statements for user-installed extensions (e.g. `btree_gist`, `pgcrypto`, `uuid-ossp`). Extensions are emitted before any `CREATE TYPE` or `CREATE TABLE` definitions so the dump can be restored on a clean database without manually pre-installing extensions. Non-public schema extensions include a `SCHEMA` clause. ([#92](https://github.com/heyinc/exwiw/pull/92))
16
+
5
17
  ## [0.4.7] - 2026-06-10
6
18
 
7
19
  ### Fixed
@@ -52,6 +52,7 @@ module Exwiw
52
52
  raise "pg_dump failed (exit #{status.exitstatus}): #{stderr}"
53
53
  end
54
54
 
55
+ # Enums are prepended first, then extensions — so extensions end up at the top of the output.
55
56
  enum_types = query_enum_types(table_names)
56
57
  unless enum_types.empty?
57
58
  enum_ddl = DdlPostprocessor.create_type_enum_statements(enum_types)
@@ -59,6 +60,17 @@ module Exwiw
59
60
  stdout = enum_ddl + stdout
60
61
  end
61
62
 
63
+ extensions = query_extensions
64
+ unless extensions.empty?
65
+ ext_ddl = extensions.map do |extname, schema|
66
+ stmt = "CREATE EXTENSION IF NOT EXISTS #{connection.quote_ident(extname)}"
67
+ stmt += " SCHEMA #{connection.quote_ident(schema)}" unless schema == "public"
68
+ "DO $$ BEGIN #{stmt}; EXCEPTION WHEN feature_not_supported THEN NULL; END $$;"
69
+ end.join("\n") + "\n\n"
70
+ @logger.debug(" Found #{extensions.size} extension(s) to prepend.")
71
+ stdout = ext_ddl + stdout
72
+ end
73
+
62
74
  idempotent = stdout
63
75
  idempotent = DdlPostprocessor.add_if_not_exists_to_create_schema(idempotent)
64
76
  idempotent = DdlPostprocessor.add_if_not_exists_to_create_sequence(idempotent)
@@ -368,6 +380,20 @@ module Exwiw
368
380
  end
369
381
  end
370
382
 
383
+ private def query_extensions
384
+ sql = <<~SQL
385
+ SELECT e.extname, n.nspname
386
+ FROM pg_extension e
387
+ JOIN pg_namespace n ON n.oid = e.extnamespace
388
+ WHERE e.extname != 'plpgsql'
389
+ AND e.extname NOT LIKE 'google\\_%' ESCAPE '\\'
390
+ AND e.extname NOT LIKE 'rds\\_%' ESCAPE '\\'
391
+ AND e.extname NOT LIKE 'aiven\\_%' ESCAPE '\\'
392
+ ORDER BY e.extname
393
+ SQL
394
+ connection.exec(sql).map { |row| [row["extname"], row["nspname"]] }
395
+ end
396
+
371
397
  private def query_enum_types(table_names)
372
398
  return [] if table_names.empty?
373
399
 
data/lib/exwiw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.4.7"
4
+ VERSION = "0.4.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia