Skip to content

Commit 09b4c4f

Browse files
committed
fix(supabase): prevent a unhealthy status during the restart of the supabase stack
The error occurs because the event trigger function inserts into app_schema_version without schema qualification, failing due to missing table in the search_path used by Supabase realtime (which connects to the "postgres" database with a different schema context). Always create app_schema_version in public and updating the function’s insert statement to reference public.app_schema_version
1 parent 7c9b60d commit 09b4c4f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/postgresql/sql_postgresql.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ const char * const SQL_SETTINGS_LOAD_TABLE =
4343
"SELECT lower(tbl_name), lower(col_name), key, value FROM cloudsync_table_settings ORDER BY tbl_name;";
4444

4545
const char * const SQL_CREATE_SETTINGS_TABLE =
46-
"CREATE TABLE IF NOT EXISTS cloudsync_settings (key TEXT PRIMARY KEY NOT NULL, value TEXT);"
47-
"CREATE TABLE IF NOT EXISTS app_schema_version ("
46+
"CREATE TABLE IF NOT EXISTS cloudsync_settings (key TEXT PRIMARY KEY NOT NULL, value TEXT);"
47+
"CREATE TABLE IF NOT EXISTS public.app_schema_version ("
4848
"version BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY"
4949
");"
5050
"CREATE OR REPLACE FUNCTION bump_app_schema_version() "
5151
"RETURNS event_trigger AS $$ "
5252
"BEGIN "
53-
"INSERT INTO app_schema_version DEFAULT VALUES; "
53+
"INSERT INTO public.app_schema_version DEFAULT VALUES; "
5454
"END;"
5555
"$$ LANGUAGE plpgsql;"
5656
"DROP EVENT TRIGGER IF EXISTS app_schema_change;"

0 commit comments

Comments
 (0)