Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ CI_start_postgres() {

swap_postgres_and_supabase_admin() {
run_sql <<'EOSQL'
alter database postgres connection limit 0;
select pg_terminate_backend(pid) from pg_stat_activity where backend_type = 'client backend' and pid != pg_backend_pid();
EOSQL
run_sql <<'EOSQL'
set statement_timeout = '300s';
begin;
create role supabase_tmp superuser;
Expand Down Expand Up @@ -509,6 +513,8 @@ begin
end
$$;

alter database postgres connection limit -1;

set session authorization supabase_admin;
drop role supabase_tmp;
commit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ cleanup() {
echo "Removing SUPERUSER grant from postgres"
run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"

echo "Resetting postgres database connection limit"
run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"

if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
echo "Unmounting data disk from ${MOUNT_POINT}"
umount $MOUNT_POINT
Expand Down
Loading