Skip to content

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Nov 6, 2025

pg_upgrade may generate an update_extensions.sql script to update extensions after a major version upgrade.
This PR modifies the extension tests to check for the presence of this script after upgrading PostgreSQL to version 17.
If the script exists, it is executed to ensure that the extensions are updated correctly.

Summary by CodeRabbit

  • Tests

    • Improved PostgreSQL extension upgrade tests to detect and conditionally run extension update scripts during major-version migrations.
    • Expanded test coverage by adding additional extensions to the upgrade matrix.
  • Documentation

    • Added clarifying comments in test configurations explaining why certain extensions need adapted checks or special dependency handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@jfroche jfroche marked this pull request as ready for review November 6, 2025 17:20
@jfroche jfroche requested review from a team as code owners November 6, 2025 17:20
@jfroche jfroche force-pushed the fix/nixos-test-update-after-pg-upgrade branch 2 times, most recently from 28b6e73 to 1a9394d Compare November 10, 2025 11:04
@yvan-sraka yvan-sraka force-pushed the fix/nixos-test-update-after-pg-upgrade branch from 1a9394d to cecd0ca Compare November 17, 2025 09:46
@yvan-sraka yvan-sraka self-assigned this Nov 17, 2025
@yvan-sraka yvan-sraka requested a review from samrose November 17, 2025 09:46
@yvan-sraka yvan-sraka force-pushed the fix/nixos-test-update-after-pg-upgrade branch 3 times, most recently from dbb2ab9 to 537ceef Compare November 21, 2025 10:37
@yvan-sraka yvan-sraka force-pushed the fix/nixos-test-update-after-pg-upgrade branch from 537ceef to d90c5b4 Compare December 12, 2025 17:43
@yvan-sraka yvan-sraka requested a review from a team as a code owner December 12, 2025 17:43
@yvan-sraka yvan-sraka changed the base branch from develop to update-nixpkgs December 12, 2025 17:43
@samrose samrose force-pushed the update-nixpkgs branch 3 times, most recently from 771718f to 4e32d5b Compare December 17, 2025 19:36
Base automatically changed from update-nixpkgs to develop January 16, 2026 00:23
@jfroche jfroche force-pushed the fix/nixos-test-update-after-pg-upgrade branch from d90c5b4 to 6a7a2c5 Compare January 16, 2026 18:15
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Walkthrough

Adds runtime detection of an update_extensions.sql script during the PostgreSQL 17 upgrade flow, conditionally runs it and adjusts extension-version assertions; inserts pg_partman and postgis into the test manifest; and adds explanatory comments for several extension tests.

Changes

Cohort / File(s) Summary
PostgreSQL 17 upgrade & extension manifest
nix/ext/tests/default.nix
Adds has_update_script check for /var/lib/postgresql/update_extensions.sql after switching to the 17 config; conditionally runs the update script and asserts extension versions from either versions["17"][-1] or the last_version recorded from 15; inserts pg_partman and postgis into the extension test manifest.
Extension-specific test notes
nix/ext/tests/http.nix, nix/ext/tests/pg_repack.nix, nix/ext/tests/pgrouting.nix
Adds non-functional comments explaining why the generic test is not used for these extensions: http (non-semver versions), pg_repack (no upgrade SQL/update path), pgrouting (requires PostGIS).

Sequence Diagram(s)

sequenceDiagram
  participant TestHarness as Test Harness
  participant FS as Filesystem
  participant PG as PostgreSQL 17

  TestHarness->>PG: switch to PG 17 configuration
  TestHarness->>FS: check /var/lib/postgresql/update_extensions.sql (has_update_script?)
  alt update script present
    TestHarness->>PG: run update_extensions.sql
    PG-->>TestHarness: extensions updated
    TestHarness->>TestHarness: assert versions == versions["17"][-1]
  else no update script
    TestHarness->>TestHarness: assert versions == last_version_from_15
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • samrose
  • LGUG2Z

Poem

🐰 I sniffed a script by moonlight bright,

Hopped between versions in the night,
If found, I nudge the upgrade through,
If not, I keep the_old_version true,
A carrot of tests, tidy and light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: handling pg_upgrade's update_extensions.sql script in extension tests.
Description check ✅ Passed The description clearly explains the purpose and scope of the changes, though it does not follow the template structure with explicit sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

jfroche and others added 4 commits January 19, 2026 12:35
…n the extension tests

pg_upgrade may generate an update_extensions.sql script to update extensions after a major version upgrade. 
This commit modifies the extension tests to check for the presence of this script after upgrading PostgreSQL to version 17. 
If the script exists, it is executed to ensure that the extensions are updated correctly.
Thanks to the improvement related to the generated pg_upgrade script, we can now reuse the generic postgres extension test for postgis.
This helps us identify why certain extensions do not use the generic tests.
Address CodeRabbit feedback to prevent race conditions when running
update scripts by ensuring PostgreSQL is fully ready before proceeding.
@yvan-sraka yvan-sraka force-pushed the fix/nixos-test-update-after-pg-upgrade branch from 6a7a2c5 to a31a691 Compare January 19, 2026 11:45
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