Skip to content

Commit a159471

Browse files
committed
fix: sql migration files for pg_jsonschema
1 parent 6acd4c3 commit a159471

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

nix/ext/pg_jsonschema.nix

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildPgrxExtension_0_11_3 rec {
1414

1515
nativeBuildInputs = [ cargo ];
1616
buildInputs = [ postgresql ];
17-
17+
previousVersions = ["0.3.0" "0.2.0" "0.1.4" "0.1.4" "0.1.2" "0.1.1" "0.1.0"];
1818
CARGO="${cargo}/bin/cargo";
1919
env = lib.optionalAttrs stdenv.isDarwin {
2020
POSTGRES_LIB = "${postgresql}/lib";
@@ -26,6 +26,31 @@ buildPgrxExtension_0_11_3 rec {
2626
# to fix this a bit later.
2727
doCheck = false;
2828

29+
preBuild = ''
30+
echo "Processing git tags..."
31+
echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt
32+
'';
33+
34+
postInstall = ''
35+
echo "Creating SQL files for previous versions..."
36+
current_version="${version}"
37+
sql_file="$out/share/postgresql/extension/pg_jsonschema--$current_version.sql"
38+
39+
if [ -f "$sql_file" ]; then
40+
while read -r previous_version; do
41+
if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
42+
new_file="$out/share/postgresql/extension/pg_jsonschema--$previous_version--$current_version.sql"
43+
echo "Creating $new_file"
44+
cp "$sql_file" "$new_file"
45+
fi
46+
done < git_tags.txt
47+
else
48+
echo "Warning: $sql_file not found"
49+
fi
50+
rm git_tags.txt
51+
'';
52+
53+
2954
meta = with lib; {
3055
description = "JSON Schema Validation for PostgreSQL";
3156
homepage = "https://github.com/supabase/${pname}";

0 commit comments

Comments
 (0)