@@ -14,7 +14,10 @@ buildPgrxExtension_0_11_3 rec {
14
14
15
15
nativeBuildInputs = [ cargo ] ;
16
16
buildInputs = [ postgresql ] ;
17
-
17
+ # update the following array when the pg_jsonschema version is updated
18
+ # required to ensure that extensions update scripts from previous versions are generated
19
+
20
+ previousVersions = [ "0.3.0" "0.2.0" "0.1.4" "0.1.4" "0.1.2" "0.1.1" "0.1.0" ] ;
18
21
CARGO = "${ cargo } /bin/cargo" ;
19
22
env = lib . optionalAttrs stdenv . isDarwin {
20
23
POSTGRES_LIB = "${ postgresql } /lib" ;
@@ -26,6 +29,31 @@ buildPgrxExtension_0_11_3 rec {
26
29
# to fix this a bit later.
27
30
doCheck = false ;
28
31
32
+ preBuild = ''
33
+ echo "Processing git tags..."
34
+ echo '${ builtins . concatStringsSep "," previousVersions } ' | sed 's/,/\n/g' > git_tags.txt
35
+ '' ;
36
+
37
+ postInstall = ''
38
+ echo "Creating SQL files for previous versions..."
39
+ current_version="${ version } "
40
+ sql_file="$out/share/postgresql/extension/pg_jsonschema--$current_version.sql"
41
+
42
+ if [ -f "$sql_file" ]; then
43
+ while read -r previous_version; do
44
+ if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
45
+ new_file="$out/share/postgresql/extension/pg_jsonschema--$previous_version--$current_version.sql"
46
+ echo "Creating $new_file"
47
+ cp "$sql_file" "$new_file"
48
+ fi
49
+ done < git_tags.txt
50
+ else
51
+ echo "Warning: $sql_file not found"
52
+ fi
53
+ rm git_tags.txt
54
+ '' ;
55
+
56
+
29
57
meta = with lib ; {
30
58
description = "JSON Schema Validation for PostgreSQL" ;
31
59
homepage = "https://github.com/supabase/${ pname } " ;
0 commit comments