-
-
Notifications
You must be signed in to change notification settings - Fork 233
feat: test pg_upgrade compatibility with older extension versions #1897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7c36e1c
ef04f08
e17c866
99e8ac9
f3c8a91
1f23b21
8b80d82
3668755
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,9 +76,9 @@ let | |
|
|
||
| preCheck = '' | ||
| export PGRX_HOME=$(mktemp -d) | ||
| export NIX_PGLIBDIR=$PGRX_HOME/${lib.versions.major postgresql.version}/lib | ||
| ${lib.getExe pkgs.rsync} --chmod=ugo+w -a ${postgresql}/ ${postgresql.lib}/ $PGRX_HOME/${lib.versions.major postgresql.version}/ | ||
| cargo pgrx init --pg${lib.versions.major postgresql.version} $PGRX_HOME/${lib.versions.major postgresql.version}/bin/pg_config | ||
| export NIX_PGLIBDIR=$PGRX_HOME/${pgVersion}/lib | ||
| ${lib.getExe pkgs.rsync} --chmod=ugo+w -a ${postgresql}/ ${postgresql.lib}/ $PGRX_HOME/${pgVersion}/ | ||
| cargo pgrx init --pg${pgVersion} $PGRX_HOME/${pgVersion}/bin/pg_config | ||
| ''; | ||
|
|
||
| # Tests are disabled for specific versions because pgrx tests require | ||
|
|
@@ -93,11 +93,6 @@ let | |
| "0.3.3" | ||
| ]); | ||
|
|
||
| preBuild = '' | ||
| echo "Processing git tags..." | ||
| echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt | ||
| ''; | ||
|
|
||
| postInstall = '' | ||
| mv $out/lib/${pname}${postgresql.dlSuffix} $out/lib/${pname}-${version}${postgresql.dlSuffix} | ||
|
|
||
|
|
@@ -127,8 +122,9 @@ let | |
| }; | ||
| }; | ||
| allVersions = (builtins.fromJSON (builtins.readFile ../versions.json)).pg_jsonschema; | ||
| pgVersion = lib.versions.major postgresql.version; | ||
| supportedVersions = lib.filterAttrs ( | ||
| _: value: builtins.elem (lib.versions.major postgresql.version) value.postgresql | ||
| _: value: builtins.elem pgVersion value.postgresql | ||
| ) allVersions; | ||
| versions = lib.naturalSort (lib.attrNames supportedVersions); | ||
| latestVersion = lib.last versions; | ||
|
|
@@ -142,6 +138,8 @@ let | |
| ); | ||
| versionsBuilt = if latestOnly then [ latestVersion ] else versions; | ||
| numberOfVersionsBuilt = builtins.length versionsBuilt; | ||
| unsupportedVersionsItems = lib.filterAttrs (_: value: value.postgresql == [ "15" ]) allVersions; | ||
| unsupportedVersions = if pgVersion == "17" then lib.attrNames unsupportedVersionsItems else [ ]; | ||
| in | ||
| (pkgs.buildEnv { | ||
| name = pname; | ||
|
|
@@ -158,6 +156,10 @@ in | |
| }" | ||
| ) | ||
|
|
||
| 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 | ||
|
Comment on lines
+159
to
+161
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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
fiRepository: 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])])
PYRepository: 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
fiRepository: 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 -10Repository: supabase/postgres Length of output: 350 🏁 Script executed: #!/bin/bash
# Show the entire file to understand context
cat nix/ext/pg_jsonschema/default.nixRepository: 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
fiRepository: 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
If this is strictly for 🤖 Prompt for AI Agents |
||
|
|
||
| create_sql_files() { | ||
| PREVIOUS_VERSION="" | ||
| while IFS= read -r i; do | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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
💡 For code changes across multiple files, use
@coderabbitaiplan in an issue comment