Skip to content

Commit 4719445

Browse files
committed
Merge remote-tracking branch 'origin/release/15.6-lw12' into bs/migrations
2 parents ec38d14 + 6acd4c3 commit 4719445

File tree

7 files changed

+84
-31
lines changed

7 files changed

+84
-31
lines changed

.github/workflows/ami-release-nix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- '.github/workflows/ami-release-nix.yml'
910
- 'common-nix.vars.pkr.hcl'
@@ -54,7 +55,7 @@ jobs:
5455
run: |
5556
packer init stage2-nix-psql.pkr.hcl
5657
GIT_SHA=${{github.sha}}
57-
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
58+
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
5859
5960
- name: Grab release version
6061
id: process_release_version

.github/workflows/dockerhub-release-15-6.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- ".github/workflows/dockerhub-release-15-6.yml"
910
- "common-nix.vars*"
11+
workflow_dispatch:
1012

1113
jobs:
1214
settings:

.github/workflows/nix-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
pull_request:
9+
workflow_dispatch:
810

911
permissions:
1012
contents: read
@@ -56,4 +58,4 @@ jobs:
5658
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
5759
base_nix bash -c "./workspace/docker/nix/build_nix.sh"
5860
name: build psql bundle on ${{ matrix.arch }}
59-
61+

.github/workflows/publish-nix-pgupgrade-scripts.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7-
- sam/nix-and-conventional-ami
7+
- release/*
88
paths:
9-
- '.github/workflows/publish-pgupgrade-scripts.yml'
9+
- '.github/workflows/publish-nix-pgupgrade-scripts.yml'
1010
- 'common-nix.vars.pkr.hcl'
1111
workflow_dispatch:
1212
inputs:
@@ -62,7 +62,7 @@ jobs:
6262

6363
publish-prod:
6464
runs-on: ubuntu-latest
65-
if: github.ref_name == 'develop'
65+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
6666

6767
steps:
6868
- name: Checkout Repo

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ EOF
176176
function patch_wrappers {
177177
local IS_NIX_UPGRADE=$1
178178

179+
WRAPPERS_ENABLED=$(run_sql -A -t -c "SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'wrappers');")
180+
if [ "$WRAPPERS_ENABLED" = "f" ]; then
181+
echo "Wrappers extension not enabled. Skipping."
182+
return
183+
fi
184+
179185
# This is a workaround for older versions of wrappers which don't have the expected
180186
# naming scheme, containing the version in their library's file name
181187
# e.g. wrappers-0.1.16.so, rather than wrappers.so
@@ -188,18 +194,20 @@ function patch_wrappers {
188194
# - new version: wrappers-0.1.18.so
189195
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
190196
if [ "$IS_NIX_UPGRADE" = "true" ]; then
191-
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
192-
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
193-
194-
find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
195-
if [ -f "$WRAPPERS_LIB_PATH" ]; then
196-
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
197-
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
198-
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
199-
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
197+
if [ -d "$PGLIBOLD" ]; then
198+
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
199+
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
200+
201+
find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
202+
if [ -f "$WRAPPERS_LIB_PATH" ]; then
203+
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
204+
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
205+
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
206+
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
207+
fi
200208
fi
201-
fi
202-
done
209+
done
210+
fi
203211
else
204212
if [ -d "$PGLIBOLD" ]; then
205213
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)

ansible/tasks/setup-postgrest.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
- name: PostgREST - system user
22
user: name=postgrest
33

4+
- name: PostgREST - add Postgres PPA gpg key
5+
apt_key:
6+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
7+
state: present
8+
9+
- name: PostgREST - add Postgres PPA
10+
apt_repository:
11+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
12+
state: present
13+
14+
- name: PostgREST - update apt cache
15+
apt:
16+
update_cache: yes
17+
418
# libpq is a C library that enables user programs to communicate with
519
# the PostgreSQL database server.
620
- name: PostgREST - system dependencies
@@ -9,9 +23,20 @@
923
- libpq5
1024
- libnuma-dev
1125

26+
- name: PostgREST - remove Postgres PPA gpg key
27+
apt_key:
28+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
29+
state: absent
30+
31+
- name: PostgREST - remove Postgres PPA
32+
apt_repository:
33+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
34+
state: absent
35+
1236
- name: postgis - ensure dependencies do not get autoremoved
1337
shell: |
1438
set -e
39+
apt-mark manual libpq5*
1540
apt-mark manual libnuma*
1641
apt-mark auto libnuma*-dev
1742

nix/ext/wrappers/default.nix

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,38 @@
77
, buildPgrxExtension_0_11_3
88
, cargo
99
, darwin
10+
, jq
1011
}:
1112

1213
buildPgrxExtension_0_11_3 rec {
1314
pname = "supabase-wrappers";
1415
version = "0.4.1";
16+
# update the following array when the wrappers version is updated
17+
# required to ensure that extensions update scripts from previous versions are generated
18+
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"];
1519
inherit postgresql;
16-
1720
src = fetchFromGitHub {
1821
owner = "supabase";
1922
repo = "wrappers";
2023
rev = "v${version}";
2124
hash = "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM=";
2225
};
23-
2426
nativeBuildInputs = [ pkg-config cargo ];
25-
26-
buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [
27+
buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [
2728
darwin.apple_sdk.frameworks.CoreFoundation
2829
darwin.apple_sdk.frameworks.Security
2930
darwin.apple_sdk.frameworks.SystemConfiguration
3031
];
31-
32-
# Needed to get openssl-sys to use pkg-config.
3332
OPENSSL_NO_VENDOR = 1;
3433

3534
CARGO="${cargo}/bin/cargo";
36-
3735
cargoLock = {
38-
#TODO when we move to newer versions this lockfile will need to be sourced
39-
# from ${src}/Cargo.lock
4036
lockFile = "${src}/Cargo.lock";
4137
outputHashes = {
4238
"clickhouse-rs-1.0.0-alpha.1" = "sha256-0zmoUo/GLyCKDLkpBsnLAyGs1xz6cubJhn+eVqMEMaw=";
4339
};
4440
};
4541
postPatch = "cp ${cargoLock.lockFile} Cargo.lock";
46-
4742
buildAndTestSubdir = "wrappers";
4843
buildFeatures = [
4944
"helloworld_fdw"
@@ -60,17 +55,37 @@ buildPgrxExtension_0_11_3 rec {
6055
"cognito_fdw"
6156
"wasm_fdw"
6257
];
63-
64-
# FIXME (aseipp): disable the tests since they try to install .control
65-
# files into the wrong spot, aside from that the one main test seems
66-
# to work, though
6758
doCheck = false;
6859

60+
preBuild = ''
61+
echo "Processing git tags..."
62+
echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt
63+
'';
64+
65+
postInstall = ''
66+
echo "Creating SQL files for previous versions..."
67+
current_version="${version}"
68+
sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql"
69+
70+
if [ -f "$sql_file" ]; then
71+
while read -r previous_version; do
72+
if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
73+
new_file="$out/share/postgresql/extension/wrappers--$previous_version--$current_version.sql"
74+
echo "Creating $new_file"
75+
cp "$sql_file" "$new_file"
76+
fi
77+
done < git_tags.txt
78+
else
79+
echo "Warning: $sql_file not found"
80+
fi
81+
rm git_tags.txt
82+
'';
83+
6984
meta = with lib; {
7085
description = "Various Foreign Data Wrappers (FDWs) for PostreSQL";
7186
homepage = "https://github.com/supabase/wrappers";
7287
maintainers = with maintainers; [ samrose ];
7388
platforms = postgresql.meta.platforms;
7489
license = licenses.postgresql;
7590
};
76-
}
91+
}

0 commit comments

Comments
 (0)