diff --git a/nix/ext/wrappers/default.nix b/nix/ext/wrappers/default.nix index 0411c003c..db1e972f1 100644 --- a/nix/ext/wrappers/default.nix +++ b/nix/ext/wrappers/default.nix @@ -10,15 +10,12 @@ , jq }: -let - gitTags = builtins.fromJSON (builtins.readFile (builtins.fetchurl { - url = "https://api.github.com/repos/supabase/wrappers/tags"; - sha256 = "0pvavn0f8wnaszq4bmvjkadm6xbvf91rbhcmmgjasqajb69vskv9"; # Replace with actual hash - })); -in buildPgrxExtension_0_11_3 rec { pname = "supabase-wrappers"; version = "0.4.1"; + # update the following array when the wrappers version is updated + # required to ensure that extensions update scripts from previous versions are generated + previousVersions = ["0.4.0" "0.3.1" "0.3.0" "0.2.0" "0.1.19" "0.1.18" "0.1.17" "0.1.16" "0.1.15" "0.1.14" "0.1.12" "0.1.11" "0.1.10" "0.1.9" "0.1.8" "0.1.7" "0.1.6" "0.1.5" "0.1.4" "0.1.1" "0.1.0"]; inherit postgresql; src = fetchFromGitHub { owner = "supabase"; @@ -26,7 +23,7 @@ buildPgrxExtension_0_11_3 rec { rev = "v${version}"; hash = "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM="; }; - nativeBuildInputs = [ pkg-config cargo jq ]; + nativeBuildInputs = [ pkg-config cargo ]; buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [ darwin.apple_sdk.frameworks.CoreFoundation darwin.apple_sdk.frameworks.Security @@ -62,7 +59,7 @@ buildPgrxExtension_0_11_3 rec { preBuild = '' echo "Processing git tags..." - echo '${builtins.toJSON gitTags}' | ${jq}/bin/jq -r '.[].name' | sort -rV > git_tags.txt + echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt ''; postInstall = '' @@ -71,10 +68,9 @@ buildPgrxExtension_0_11_3 rec { sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql" if [ -f "$sql_file" ]; then - while read -r tag; do - tag_version=$(echo "$tag" | sed 's/^v//') - if [ "$(printf '%s\n' "$tag_version" "$current_version" | sort -V | head -n1)" = "$tag_version" ] && [ "$tag_version" != "$current_version" ]; then - new_file="$out/share/postgresql/extension/wrappers--$tag_version--$current_version.sql" + while read -r previous_version; do + if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then + new_file="$out/share/postgresql/extension/wrappers--$previous_version--$current_version.sql" echo "Creating $new_file" cp "$sql_file" "$new_file" fi