@@ -14,7 +14,7 @@ buildPgrxExtension_0_11_3 rec {
14
14
15
15
nativeBuildInputs = [ cargo ] ;
16
16
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" ] ;
18
18
CARGO = "${ cargo } /bin/cargo" ;
19
19
env = lib . optionalAttrs stdenv . isDarwin {
20
20
POSTGRES_LIB = "${ postgresql } /lib" ;
@@ -26,6 +26,31 @@ buildPgrxExtension_0_11_3 rec {
26
26
# to fix this a bit later.
27
27
doCheck = false ;
28
28
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
+
29
54
meta = with lib ; {
30
55
description = "JSON Schema Validation for PostgreSQL" ;
31
56
homepage = "https://github.com/supabase/${ pname } " ;
0 commit comments