Skip to content

feat: test pg_upgrade compatibility with older extension versions#1897

Open
jfroche wants to merge 6 commits intodevelopfrom
feat/test-pg-upgrade-older-version
Open

feat: test pg_upgrade compatibility with older extension versions#1897
jfroche wants to merge 6 commits intodevelopfrom
feat/test-pg-upgrade-older-version

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Nov 6, 2025

Add test to verify that all extension versions from PostgreSQL 15 can successfully upgrade to PostgreSQL 17 using pg_upgrade.

The test now validates:

  • Each PG 15 extension version can be upgraded to PG 17
  • Extension update scripts are properly generated during upgrade
  • Version handling works correctly with and without update scripts
  • Final extension versions match expected values after upgrade

Summary by CodeRabbit

  • New Features

    • Unified PostgreSQL-version-aware packaging that produces SQL-only migration artifacts for older Postgres releases and includes them in final builds.
  • Tests

    • Broadened pg_upgrade 15→17 test coverage across many extensions; added a dedicated pg_stat_monitor test and standardized per-version upgrade flows. Test exports updated to include pg_partman and postgis.
  • Bug Fixes

    • Test cleanup now drops extensions with CASCADE to remove dependent objects.

@samrose samrose self-requested a review November 6, 2025 20:29
Copy link
Collaborator

@samrose samrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Will just need to test before we merge it

@jfroche jfroche marked this pull request as ready for review November 6, 2025 22:57
@jfroche jfroche requested review from a team as code owners November 6, 2025 22:57
@jfroche jfroche force-pushed the feat/test-pg-upgrade-older-version branch from 8acfa60 to f59c791 Compare November 7, 2025 16:33
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from f59c791 to 779090b Compare November 11, 2025 16:17
@yvan-sraka yvan-sraka self-assigned this Nov 11, 2025
@yvan-sraka yvan-sraka requested a review from samrose November 11, 2025 16:17
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch 2 times, most recently from 24d66bb to 164f401 Compare November 19, 2025 10:13
@yvan-sraka yvan-sraka marked this pull request as draft November 19, 2025 21:13
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 164f401 to 450b690 Compare November 21, 2025 10:38
@yvan-sraka yvan-sraka marked this pull request as ready for review November 21, 2025 13:03
@blacksmith-sh

This comment has been minimized.

@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from f6f9d9b to 9beb48a Compare November 25, 2025 16:11
@yvan-sraka yvan-sraka changed the base branch from develop to custom-github-runners November 25, 2025 16:11
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 9beb48a to 218357a Compare November 25, 2025 17:46
@jfroche jfroche force-pushed the custom-github-runners branch from c1c4fd7 to 9b659e4 Compare November 25, 2025 22:56
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch 2 times, most recently from 971248f to 84cfa8d Compare November 25, 2025 23:28
@yvan-sraka yvan-sraka force-pushed the custom-github-runners branch from efd8f49 to a5fc472 Compare November 26, 2025 09:02
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch 2 times, most recently from 39db71b to 29a4d56 Compare November 26, 2025 11:33
@yvan-sraka yvan-sraka force-pushed the custom-github-runners branch 2 times, most recently from 03dc754 to c159bb6 Compare December 1, 2025 10:01
@jfroche jfroche force-pushed the custom-github-runners branch 3 times, most recently from df5545b to b9294ee Compare December 2, 2025 21:26
@jfroche jfroche force-pushed the custom-github-runners branch 2 times, most recently from 182d513 to 1246b61 Compare December 8, 2025 13:43
Base automatically changed from custom-github-runners to develop December 8, 2025 17:15
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 29a4d56 to d36e133 Compare December 12, 2025 08:58
@jfroche jfroche force-pushed the feat/test-pg-upgrade-older-version branch from d36e133 to 423dd3d Compare January 16, 2026 19:14
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Replaces inline PostgreSQL major-version usage with a new pgVersion across multiple extension build scripts, adds logic to produce SQL-only artifacts for unsupported/older PostgreSQL versions, and introduces pgUpgrade-compatible filtering metadata. Many extension Nix files now generate or copy migration SQL for legacy versions. The test suite is expanded and refactored: tests gain system-derived pg15/pg17 configurations, new pg_upgrade loops that iterate 15-era extension versions, and a new NixOS runTest for pg_stat_monitor. Minor test utilities and exported extension lists were adjusted.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

nix, extensions, tests

Suggested reviewers

  • hunleyd
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding tests for pg_upgrade compatibility with older extension versions, which aligns with the substantial testing infrastructure added across multiple files.
Description check ✅ Passed The description provides a clear summary of what is being tested (PG 15 to PG 17 upgrades) and lists specific validation points, though it does not follow the repository's template structure with designated sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/test-pg-upgrade-older-version

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@nix/ext/pg_stat_monitor.nix`:
- Around line 20-29: latestVersion is computed from allVersionsList but packages
are built from pgUpgradeCompatibleVersions, causing a mismatch if the newest
supported version is not pgUpgradeCompatible; change the latestVersion
definition to derive from the pgUpgradeCompatible set (e.g. use lib.last on the
attrNames of pgUpgradeCompatibleVersions or on a sorted list of
pgUpgradeCompatible version keys) so latestVersion and packages come from the
same pg_upgrade-compatible collection (update the latestVersion variable to
reference pgUpgradeCompatibleVersions instead of allVersionsList).

In `@nix/ext/tests/pg_stat_monitor.nix`:
- Around line 190-191: The PostgresExtensionTest is being instantiated without
the computed lib_name, causing the constructor to default to extension_name;
update the PostgresExtensionTest(...) call that currently uses (server,
extension_name, versions, sql_test_directory, support_upgrade, ext_schema) so it
includes the computed lib_name argument (the variable lib_name) in the parameter
list passed to PostgresExtensionTest, ensuring subsequent uses (e.g.,
test.create_schema() and later references to lib_name) target the correct
library name.
🧹 Nitpick comments (2)
nix/ext/pg_jsonschema/default.nix (1)

96-96: Consider removing or making debug output explicit.

The find $out command appears to be debugging output that lists build artifacts. If intentional for troubleshooting, consider adding a comment explaining its purpose or wrapping it in an echo statement. If unintentional, it can be removed.

🔧 Suggested change if keeping for debugging
 postInstall = ''
-  find $out
+  # Debug: list build artifacts
+  echo "Build artifacts:" && find $out
   mv $out/lib/${pname}${postgresql.dlSuffix} $out/lib/${pname}-${version}${postgresql.dlSuffix}

Or remove if not needed:

 postInstall = ''
-  find $out
   mv $out/lib/${pname}${postgresql.dlSuffix} $out/lib/${pname}-${version}${postgresql.dlSuffix}
nix/ext/tests/pgsodium.nix (1)

197-223: Ensure pg_upgrade completes before checking update script.
switch-to-configuration can return before services are fully ready; the immediate check for update_extensions.sql can race and flip has_update_script to no. Consider waiting for postgresql.service (or postgresql-migrate.service) after each switch.

🔧 Suggested wait to reduce flakiness
           server.succeed(
             f"{pg15_configuration}/bin/switch-to-configuration test >&2"
           )
+          server.wait_for_unit("postgresql.service")
           test.drop_extension()
           test.install_extension(version)
           server.succeed(
             f"{pg17_configuration}/bin/switch-to-configuration test >&2"
           )
+          server.wait_for_unit("postgresql.service")
           has_update_script = server.succeed(
             "test -f /var/lib/postgresql/update_extensions.sql && echo 'yes' || echo 'no'"
           ).strip() == "yes"
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa78cb3 and 423dd3d.

📒 Files selected for processing (11)
  • nix/ext/pg_graphql/default.nix
  • nix/ext/pg_jsonschema/default.nix
  • nix/ext/pg_stat_monitor.nix
  • nix/ext/tests/default.nix
  • nix/ext/tests/lib.py
  • nix/ext/tests/pg_stat_monitor.nix
  • nix/ext/tests/pgmq.nix
  • nix/ext/tests/pgroonga.nix
  • nix/ext/tests/pgsodium.nix
  • nix/ext/tests/vault.nix
  • nix/ext/versions.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: nix-eval / eval
🔇 Additional comments (26)
nix/ext/tests/lib.py (1)

57-58: LGTM - CASCADE ensures clean teardown.

Adding CASCADE to the DROP EXTENSION command is appropriate for test cleanup, ensuring dependent objects (views, functions, etc.) are properly removed between test iterations. This aligns with the multi-version upgrade testing scenarios introduced in this PR.

nix/ext/pg_graphql/default.nix (3)

122-124: LGTM - Centralizing pgVersion improves maintainability.

Extracting pgVersion as a variable and using it consistently throughout the file is a good refactoring that aligns with the same pattern in pg_jsonschema/default.nix.


132-162: LGTM - SQL-only packages enable pg_upgrade for unsupported versions.

The buildUnsupported function correctly creates minimal SQL-only extension packages that pg_upgrade needs to reference old extension versions without requiring them to compile against the new PostgreSQL version. The approach of concatenating SQL files with semicolon separators is appropriate for this migration-only use case.


163-179: LGTM - Conditional inclusion of SQL-only packages for pg_upgrade.

The logic correctly:

  1. Filters versions incompatible with the current pgVersion
  2. Skips generating SQL-only packages for PG15 (no older versions to upgrade from)
  3. Includes SQL-only packages in the build environment for PG17+ to support pg_upgrade
nix/ext/tests/pgroonga.nix (2)

141-143: LGTM - Configuration path variables.

The explicit system and configuration path variables improve readability and provide clear references for switching between PG15 and PG17 configurations during upgrade testing.


196-221: LGTM - Comprehensive pg_upgrade test for all PG15 extension versions.

This test thoroughly validates the upgrade path by:

  1. Testing each PG15 extension version individually
  2. Handling both scenarios: with update scripts (upgrade to latest) and without (version preserved)
  3. Running pg_regress validation after each upgrade

The clean state reset (stopping postgres, removing data) between iterations ensures isolated test runs.

nix/ext/pg_jsonschema/default.nix (2)

78-80: LGTM - Consistent pgVersion usage in preCheck.

The pgVersion variable is used consistently for rsync paths and cargo pgrx initialization, matching the pattern established in pg_graphql/default.nix.


135-136: LGTM - Unsupported version handling for pg_upgrade.

The approach correctly:

  1. Identifies PG15-only versions that won't compile against PG17
  2. Only generates placeholders when building for PG17
  3. Copies SQL from the earliest supported version as a migration placeholder

Note: This differs from pg_graphql which concatenates source SQL files. The simpler copy approach here works because pg_jsonschema's SQL structure allows it.

Also applies to: 153-155

nix/ext/versions.json (1)

778-779: LGTM - Marking pg_stat_monitor 1.0 as pg_upgrade incompatible.

The pgUpgradeCompatible: false flag correctly excludes this PG15-only version from pg_upgrade testing. The field is properly consumed in nix/ext/pg_stat_monitor.nix (lines 21, 25-29) to filter out incompatible versions from both the version list and build packages. Version 2.1, which supports both PG15 and PG17, will be used for upgrade validation instead.

nix/ext/tests/pgmq.nix (2)

122-125: LGTM: system-derived pg15/pg17 configuration paths.

This keeps configuration switching consistent with other test files.


182-205: LGTM: pg_upgrade coverage across older PG15 extension versions.

The loop validates upgrade behavior and update-script handling in a clear, repeatable way.

nix/ext/tests/vault.nix (2)

149-151: LGTM: consistent pg15/pg17 configuration derivation.


206-233: LGTM: pg_upgrade loop validates older-version upgrades and regression coverage.

nix/ext/tests/default.nix (3)

153-155: LGTM: system-based pg15/pg17 configuration paths.


212-237: LGTM: pg_upgrade loop for older extension versions.


261-264: LGTM: extension list update (pg_partman, postgis).

nix/ext/tests/pg_stat_monitor.nix (2)

30-119: LGTM: dedicated pg_stat_monitor test harness with pg15/pg17 specialisation.


230-264: LGTM: conditional pg_regress skip when no update script is generated.

Clear rationale and targeted handling for schema divergence after pg_upgrade.

nix/ext/tests/pgsodium.nix (8)

50-51: LGTM: explicit psql_15/psql_17 bindings.
Keeps reuse consistent across service and migration configuration.


71-85: Verify peer auth mapping matches how tests connect.
With local all postgres ... map=postgres and no postgres root postgres entry, any psql -U postgres executed as root will fail. Please confirm the harness uses sudo -u postgres (or similar), or add a mapping if root needs to connect as postgres.

Optional fallback if root must connect as postgres
 identMap = ''
   root root supabase_admin
+  postgres root postgres
   postgres postgres postgres
 '';

94-94: LGTM: pg17 specialization uses psql_17.


108-109: LGTM: explicit old/new PostgreSQL packages for pg_upgrade.


136-151: LGTM: harness wiring with explicit config variables.


158-175: LGTM: PG15 upgrade/pg_regress coverage.


179-179: LGTM: switch uses pg17_configuration.


182-195: LGTM: PG17 regression and last-version checks.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 4993025 to f355ff2 Compare January 19, 2026 10:48
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/ext/pg_jsonschema/default.nix`:
- Around line 124-136: The unsupported-version detection is too narrow: replace
the filter that defines unsupportedVersionsItems (currently using
value.postgresql == [ "15" ]) with one that selects entries where the current
pgVersion is not listed (use !(builtins.elem pgVersion value.postgresql)), and
then set unsupportedVersions to lib.attrNames unsupportedVersionsItems (remove
the special-case if pgVersion == "17"). Update the variables
unsupportedVersionsItems and unsupportedVersions accordingly so all package
entries that don't support the current pgVersion are detected.
🧹 Nitpick comments (5)
nix/ext/tests/pgmq.nix (2)

48-48: Avoid duplicating pname in the test name.

Using name = pname avoids drift if the string changes later.

♻️ Proposed diff
-  name = "pgmq";
+  name = pname;

182-205: Consider validating functionality after each pg_upgrade iteration.

Right now the loop only checks versioning; adding the same after-create SQL + pg_regress step you already use elsewhere would catch runtime regressions for older versions.

🧪 Proposed diff
           else:
             # Otherwise, the version should match the version from postgresql 15
             test.assert_version_matches(version)
+
+          test.run_sql_file("${../../../ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql}")
+          test.check_pg_regress(Path("${psql_17}/lib/pgxs/src/test/regress/pg_regress"), "17", pg_regress_test_name)
nix/ext/pg_graphql/default.nix (1)

132-180: Guard SQL-only packaging against accidental inclusion of update scripts.

buildUnsupported concatenates every sql/*.sql. If upstream includes versioned update scripts, they’d be folded into the base install file, which can skew pg_upgrade results. Consider preferring a prebuilt pg_graphql--${version}.sql when present and otherwise concatenating a deterministic, filtered list. Please verify against the upstream sql/ layout.

🧩 Proposed diff
-      installPhase = ''
-        mkdir -p $out/share/postgresql/extension
-        for file in $src/sql/*.sql; do
-          filename=$(basename "$file")
-          if [[ "$filename" != "load_sql_config.sql" && "$filename" != "load_sql_context.sql" ]]; then
-            cat "$file"
-            echo ";"
-          fi
-        done > $out/share/postgresql/extension/${pname}--${version}.sql
-      '';
+      installPhase = ''
+        mkdir -p $out/share/postgresql/extension
+        if [[ -f "$src/sql/${pname}--${version}.sql" ]]; then
+          cp "$src/sql/${pname}--${version}.sql" \
+            $out/share/postgresql/extension/${pname}--${version}.sql
+        else
+          for file in $(ls $src/sql/*.sql | sort -V); do
+            filename=$(basename "$file")
+            if [[ "$filename" != "load_sql_config.sql" \
+               && "$filename" != "load_sql_context.sql" \
+               && "$filename" != *"--"* ]]; then
+              cat "$file"
+              echo ";"
+            fi
+          done > $out/share/postgresql/extension/${pname}--${version}.sql
+        fi
+      '';
nix/ext/pg_jsonschema/default.nix (2)

153-155: Confirm which SQL version should seed unsupported versions.

lib.head versions copies the oldest supported SQL into every unsupported version. If the goal is to align with the most recent supported schema, consider lib.last versions or a version-specific mapping. Please confirm the intended behavior.

♻️ Alternative if “latest” is intended
-    for v in ${lib.concatStringsSep " " unsupportedVersions}; do
-      cp $out/share/postgresql/extension/${pname}--${lib.head versions}.sql $out/share/postgresql/extension/${pname}--$v.sql
-    done
+    for v in ${lib.concatStringsSep " " unsupportedVersions}; do
+      cp $out/share/postgresql/extension/${pname}--${lib.last versions}.sql $out/share/postgresql/extension/${pname}--$v.sql
+    done

95-97: Consider dropping the debug find $out.

It’s noisy and slows logs without affecting outputs.

🧹 Proposed cleanup
-      postInstall = ''
-        find $out
+      postInstall = ''

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/ext/pg_jsonschema/default.nix`:
- Line 96: Remove the leftover debug command `find $out` from the build script
so it no longer prints the entire output tree during builds; locate the `find
$out` invocation (the standalone shell command) in the nix expression and delete
that line (or guard it behind a debug flag if you need it for local debugging)
so build logs are no longer cluttered.

@samrose samrose added this pull request to the merge queue Jan 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jan 27, 2026
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from e4e86f8 to dc1c6d0 Compare January 28, 2026 14:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@nix/ext/pg_graphql/default.nix`:
- Around line 163-175: The branching that builds unsupportedPackages compares
pgVersion (a string) to the number 15, so the check never matches; update the
condition in the unsupportedPackages assignment to compare strings (e.g., use if
pgVersion == "15" then ...) or otherwise coerce pgVersion to an integer before
comparing; adjust the existing conditional around unsupportedPackages (which
references pgVersion, unsupportedVersions, and buildUnsupported) so the PG15
branch is correctly taken when pgVersion is the string "15".

In `@nix/ext/tests/pgmq.nix`:
- Around line 182-206: The pg_upgrade subtest loop currently validates versions
with test.assert_version_matches(...) but never runs the actual regression
tests; add a call to test.check_pg_regress() after the upgrade handling (i.e.,
after the branch that runs /var/lib/postgresql/update_extensions.sql and after
the test.assert_version_matches(...) calls) so each upgraded state is validated;
locate the subtest "Test pg_upgrade from postgresql 15 to 17 with older
extension version" and insert test.check_pg_regress() once per iteration after
the version assertions.
🧹 Nitpick comments (3)
nix/ext/tests/pgsodium.nix (1)

50-51: Inconsistent system attribute access.

This file uses pkgs.system while other test files (pgroonga.nix, vault.nix, pgmq.nix, default.nix) use pkgs.stdenv.hostPlatform.system. While functionally equivalent in most scenarios, pkgs.stdenv.hostPlatform.system is the more explicit pattern and handles cross-compilation correctly.

♻️ Suggested fix for consistency
-  psql_15 = postgresqlWithExtension self.packages.${pkgs.system}.postgresql_15;
-  psql_17 = postgresqlWithExtension self.packages.${pkgs.system}.postgresql_17;
+  psql_15 = postgresqlWithExtension self.packages.${pkgs.stdenv.hostPlatform.system}.postgresql_15;
+  psql_17 = postgresqlWithExtension self.packages.${pkgs.stdenv.hostPlatform.system}.postgresql_17;
nix/ext/tests/default.nix (1)

247-272: Consider extracting the pg_upgrade test logic into a reusable method.

The pg_upgrade test block is duplicated across 5 test files (pgroonga.nix, pgsodium.nix, pgmq.nix, vault.nix, and default.nix) with only minor variations. Consider adding a method like check_pg_upgrade_path(pg15_config, pg17_config, ...) to lib.py to reduce duplication and ensure consistency.

nix/ext/pg_jsonschema/default.nix (1)

154-156: Consider using version-specific SQL content for unsupported versions.

This approach copies the same SQL file (from the first supported version) for all unsupported versions. This differs from pg_graphql's buildUnsupported approach which fetches the actual source for each unsupported version.

While this works for pg_upgrade to recognize the extension exists, the migration scripts generated by create_sql_files (e.g., 0.1.0--0.1.1.sql) would contain identical/incorrect content since the base files are copies.

If accurate migration paths are needed beyond testing, consider adopting the buildUnsupported pattern from pg_graphql that fetches actual SQL content for each version.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/ext/pg_graphql/default.nix`:
- Around line 156-161: Fix the typo in the package metadata by updating the
meta.description value in the meta attribute set (symbol: meta and key:
description) to spell "PostgreSQL" correctly instead of "PostreSQL"; locate the
description string in the meta block (the description = "GraphQL support for
PostreSQL"; line) and change it to "GraphQL support for PostgreSQL".

Comment on lines +156 to +161
meta = with lib; {
description = "GraphQL support for PostreSQL";
homepage = "https://github.com/supabase/${pname}";
license = licenses.postgresql;
inherit (postgresql.meta) platforms;
};
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in meta description.

"PostreSQL" should be "PostgreSQL".

Suggested fix
       meta = with lib; {
-        description = "GraphQL support for PostreSQL";
+        description = "GraphQL support for PostgreSQL";
         homepage = "https://github.com/supabase/${pname}";
         license = licenses.postgresql;
         inherit (postgresql.meta) platforms;
       };
🤖 Prompt for AI Agents
In `@nix/ext/pg_graphql/default.nix` around lines 156 - 161, Fix the typo in the
package metadata by updating the meta.description value in the meta attribute
set (symbol: meta and key: description) to spell "PostgreSQL" correctly instead
of "PostreSQL"; locate the description string in the meta block (the description
= "GraphQL support for PostreSQL"; line) and change it to "GraphQL support for
PostgreSQL".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny typo, I suggest we fix it in another PR:

postgres on git develop
> rg Postre
README.md
201:| [pg_graphql](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | [1.5.11](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | GraphQL support for PostreSQL |
235:| [pg_graphql](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | [1.5.11](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | GraphQL support for PostreSQL |
268:| [pg_graphql](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | [1.5.11](https://github.com/supabase/pg_graphql/archive/v1.5.11.tar.gz) | GraphQL support for PostreSQL |

nix/ext/wrappers/default.nix
161:          description = "Various Foreign Data Wrappers (FDWs) for PostreSQL";

nix/ext/pg_graphql/default.nix
99:          description = "GraphQL support for PostreSQL";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yvan-sraka, sounds good! That makes sense to address the typo across all files in a dedicated PR since it appears in multiple places.

Would you like me to create a GitHub issue to track this typo fix? I can open one that lists all 5 occurrences across the codebase (README.md, nix/ext/wrappers/default.nix, and nix/ext/pg_graphql/default.nix) to make it easier to address them all at once.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can open a new PR that fix it, that would be even better ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yvan-sraka, I'll create a PR to fix the typo across all files! Let me plan those changes.

Task: Fix typo "PostreSQL" → "PostgreSQL" across codebase

  • Fix 3 occurrences in README.md
  • Fix 1 occurrence in nix/ext/wrappers/default.nix
  • Fix 1 occurrence in nix/ext/pg_graphql/default.nix
  • Create PR with title "fix: correct typo PostreSQL → PostgreSQL"

💡 For code changes across multiple files, use @coderabbitai plan in an issue comment

@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 66d2f75 to ff3e694 Compare February 3, 2026 17:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@nix/ext/pg_jsonschema/default.nix`:
- Around line 154-156: The loop that copies SQL for unsupportedVersions assumes
every unsupported version is older than lib.head versions (oldest supported)
which is fragile; update the logic in the for loop handling unsupportedVersions
to either (A) assert at runtime that every v in unsupportedVersions is <=
lib.head versions (e.g. fail early if any unsupported version is newer than
lib.head versions) or (B) generate/build proper SQL fixtures for each
unsupported version instead of copying ${lib.head versions}.sql; locate the loop
using the symbols unsupportedVersions, versions, lib.head and pname and
implement one of these fixes and include a clear error message if you choose the
assertion approach.

In `@nix/ext/tests/pgroonga.nix`:
- Around line 196-221: After each call that switches PostgreSQL configuration
via f"{...}/bin/switch-to-configuration test" (the two occurrences before
calling test.drop_extension()/test.install_extension() and before checking for
update_extensions.sql), add an explicit
server.wait_for_unit("postgresql.service") to ensure the server is fully ready
to accept connections before invoking test.drop_extension(),
test.install_extension(), or running the update script; this mirrors the initial
setup wait and prevents flaky failures due to the database not being ready
immediately after switch-to-configuration.
🧹 Nitpick comments (1)
nix/ext/pg_graphql/default.nix (1)

132-155: Consider honoring explicit SQL load order when assembling SQL-only artifacts.

Concatenating sql/*.sql in glob order can be brittle if the repo relies on an explicit load order or inter-file dependencies. If a sql/load-order.txt exists, using it (with a fallback to a glob) makes the output deterministic and safer.

♻️ Possible adjustment to respect load-order.txt when present
-      installPhase = ''
-        mkdir -p $out/share/postgresql/extension
-        for file in $src/sql/*.sql; do
-          filename=$(basename "$file")
-          if [[ "$filename" != "load_sql_config.sql" && "$filename" != "load_sql_context.sql" ]]; then
-            cat "$file"
-            echo ";"
-          fi
-        done > $out/share/postgresql/extension/${pname}--${version}.sql
-      '';
+      installPhase = ''
+        mkdir -p $out/share/postgresql/extension
+        {
+          if [[ -f "$src/sql/load-order.txt" ]]; then
+            while IFS= read -r fname; do
+              file="$src/sql/$fname"
+              filename=$(basename "$file")
+              if [[ "$filename" != "load_sql_config.sql" && "$filename" != "load_sql_context.sql" ]]; then
+                cat "$file"
+                echo ";"
+              fi
+            done < "$src/sql/load-order.txt"
+          else
+            shopt -s nullglob
+            for file in "$src"/sql/*.sql; do
+              filename=$(basename "$file")
+              if [[ "$filename" != "load_sql_config.sql" && "$filename" != "load_sql_context.sql" ]]; then
+                cat "$file"
+                echo ";"
+              fi
+            done
+          fi
+        } > $out/share/postgresql/extension/${pname}--${version}.sql
+      '';

Comment on lines +154 to +156
for v in ${lib.concatStringsSep " " unsupportedVersions}; do
cp $out/share/postgresql/extension/${pname}--${lib.head versions}.sql $out/share/postgresql/extension/${pname}--$v.sql
done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# First, check if versions.json exists and examine it
echo "=== Checking versions.json ==="
if [ -f "nix/ext/versions.json" ]; then
    head -50 nix/ext/versions.json
else
    find . -name "versions.json" -type f 2>/dev/null | head -5
fi

Repository: supabase/postgres

Length of output: 1070


🏁 Script executed:

#!/bin/bash
set -euo pipefail
pg_version="${1:-17}"

python - "$pg_version" <<'PY'
import json, sys

pg = sys.argv[1]
with open("nix/ext/versions.json") as f:
    data = json.load(f)["pg_jsonschema"]

def vkey(v):
    return tuple(int(x) for x in v.split("."))

supported = sorted([v for v, m in data.items() if pg in m["postgresql"]], key=vkey)
unsupported = sorted([v for v, m in data.items() if pg not in m["postgresql"]], key=vkey)

print("pg_version:", pg)
print("supported:", supported)
print("unsupported:", unsupported)
print("oldest_supported:", supported[0] if supported else None)
print("unsupported_newer_than_oldest_supported:", [v for v in unsupported if supported and vkey(v) > vkey(supported[0])])
PY

Repository: supabase/postgres

Length of output: 214


🏁 Script executed:

#!/bin/bash
# Examine the default.nix file around lines 154-156
echo "=== Checking nix/ext/pg_jsonschema/default.nix ==="
if [ -f "nix/ext/pg_jsonschema/default.nix" ]; then
    sed -n '140,170p' nix/ext/pg_jsonschema/default.nix | cat -n
else
    find . -name "default.nix" -type f 2>/dev/null | grep pg_jsonschema | head -1
fi

Repository: supabase/postgres

Length of output: 1355


🏁 Script executed:

#!/bin/bash
# Get more context from default.nix
echo "=== Full context of pg_jsonschema/default.nix ==="
wc -l nix/ext/pg_jsonschema/default.nix
echo ""
echo "=== Looking for versions and unsupportedVersions definitions ==="
rg -n "versions\s*=" nix/ext/pg_jsonschema/default.nix | head -10
rg -n "unsupportedVersions\s*=" nix/ext/pg_jsonschema/default.nix | head -10

Repository: supabase/postgres

Length of output: 350


🏁 Script executed:

#!/bin/bash
# Show the entire file to understand context
cat nix/ext/pg_jsonschema/default.nix

Repository: supabase/postgres

Length of output: 6149


🏁 Script executed:

#!/bin/bash
# Check pg_graphql for comparison as mentioned in review
echo "=== Checking pg_graphql default.nix for comparison ==="
if [ -f "nix/ext/pg_graphql/default.nix" ]; then
    # Look for similar version handling
    rg -n -C 3 "unsupportedVersions|lib.head" nix/ext/pg_graphql/default.nix | head -30
fi

Repository: supabase/postgres

Length of output: 557


Code assumes unsupported versions are always older than the oldest supported version.

Currently this is true (for PG 17: unsupported are 0.1.0–0.3.1, oldest supported is 0.3.3), but the code makes a fragile assumption. If future versions break this invariant, copying ${lib.head versions}.sql to newer unsupported versions would use incorrect schema. Consider either:

  • Adding a runtime assertion that no unsupported version is newer than oldest supported, or
  • Following pg_graphql's approach and building SQL files for unsupported versions

If this is strictly for pg_upgrade compatibility with older schemas, the current approach is acceptable but should be documented.

🤖 Prompt for AI Agents
In `@nix/ext/pg_jsonschema/default.nix` around lines 154 - 156, The loop that
copies SQL for unsupportedVersions assumes every unsupported version is older
than lib.head versions (oldest supported) which is fragile; update the logic in
the for loop handling unsupportedVersions to either (A) assert at runtime that
every v in unsupportedVersions is <= lib.head versions (e.g. fail early if any
unsupported version is newer than lib.head versions) or (B) generate/build
proper SQL fixtures for each unsupported version instead of copying ${lib.head
versions}.sql; locate the loop using the symbols unsupportedVersions, versions,
lib.head and pname and implement one of these fixes and include a clear error
message if you choose the assertion approach.

Comment on lines 196 to 221
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider adding a wait for PostgreSQL readiness after configuration switches.

After switching configurations, the test immediately calls test.drop_extension() and test.install_extension(). While switch-to-configuration test is synchronous, PostgreSQL may not be ready to accept connections immediately after the service unit reaches "active" state.

Compare with the initial test setup (lines 154-155) which explicitly waits:

server.wait_for_unit("postgresql.service")

This could cause flaky test failures when the database isn't ready before the first SQL operation.

Proposed fix
          server.succeed(
            f"{pg15_configuration}/bin/switch-to-configuration test >&2"
          )
+         server.wait_for_unit("postgresql.service")
          test.drop_extension()
          test.install_extension(version)
          server.succeed(
            f"{pg17_configuration}/bin/switch-to-configuration test >&2"
          )
+         server.wait_for_unit("postgresql.service")
          has_update_script = server.succeed(
🤖 Prompt for AI Agents
In `@nix/ext/tests/pgroonga.nix` around lines 196 - 221, After each call that
switches PostgreSQL configuration via f"{...}/bin/switch-to-configuration test"
(the two occurrences before calling
test.drop_extension()/test.install_extension() and before checking for
update_extensions.sql), add an explicit
server.wait_for_unit("postgresql.service") to ensure the server is fully ready
to accept connections before invoking test.drop_extension(),
test.install_extension(), or running the update script; this mirrors the initial
setup wait and prevents flaky failures due to the database not being ready
immediately after switch-to-configuration.

@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch 5 times, most recently from 21c7206 to 9525c36 Compare February 13, 2026 08:45
jfroche and others added 6 commits February 18, 2026 00:18
Adds pg_upgrade compatibility testing in default.nix to verify that extension
versions from PostgreSQL 15 can successfully upgrade to PostgreSQL 17.

The test validates:
- Each PG 15 extension version can be upgraded to PG 17
- Extension update scripts are properly generated during upgrade
- Version handling works correctly with and without update scripts
- Final extension versions match expected values after upgrade
…e compatibility

When upgrading PostgreSQL versions, pg_upgrade needs access to old extension
SQL files to migrate from. This adds unsupported pg_graphql and pg_jsonschema
versions (those not compilable with current PostgreSQL) as SQL-only packages,
ensuring migration paths exist when upgrading from older PostgreSQL versions.
Implements custom test for pg_stat_monitor with special handling for version
2.1 schema differences between PostgreSQL 15 and 17. Version 1.0 is excluded
from pg_upgrade tests as it uses .sql.in template files that reference
MODULE_PATHNAME without proper processing for the target version.

Version 2.1 has different schemas on PostgreSQL 15 vs 17 despite sharing the
same version number. During pg_upgrade, the extension version remains 2.1
without schema migration since no update script is generated. The custom test
skips pg_regress validation after pg_upgrade when no update script is
generated, since schema mismatch is expected behavior.

Removes pg_stat_monitor from default extension test list and uses
pkgs.testers.runNixOSTest with consistent pkgs.pkgsLinux references for
cross-platform compatibility.
pgVersion is a string, so comparison should be string-to-string
instead of string-to-integer.
…mpatibility

Converts list-type shared_preload_libraries to comma-separated strings for
pg_upgrade --old-options and --new-options flags using lib.concatStringsSep.
Fixes Python f-string interpolation for psql_17 and orioledb_17 variables in
test scripts.

Skips upgrade path tests for pgsodium where supautils before-create.sql hook
enforces that only version 3.1.8 can be installed, preventing creation of
older versions needed for upgrade testing.
@yvan-sraka yvan-sraka force-pushed the feat/test-pg-upgrade-older-version branch from 9525c36 to 0a68954 Compare February 17, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments