© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
boeledi

type geography does not exist -- suddenly

Hi All,
I don't know what happened recently but in a Function, called via a trigger, I suddenly receive an error "type "geography" does not exist", while it worked a couple of days ago.

Just in case... here is the code extract.


CREATE TRIGGER tr_t_user_inserted
  AFTER INSERT ON auth.users
  FOR EACH ROW
  EXECUTE PROCEDURE fn_t_create_user_after_registration();

CREATE OR REPLACE FUNCTION fn_t_create_user_after_registration() RETURNS trigger AS $fn_t_create_user_after_registration$
  DECLARE
    uid bigint;
  BEGIN  
    -- create new record
    INSERT INTO public.t_user (user_id, email)
    VALUES (NEW.id, NEW.email) RETURNING id INTO uid;

    -- create a fake address
    INSERT INTO public.t_address (object_id, object_type, latitude, longitude)
    VALUES (uid, 'user', 0, 0);

    RETURN NEW;
  END;
$fn_t_create_user_after_registration$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION fn_t_address_geo_update_event() RETURNS trigger AS $fn_t_address_geo_update_event$
  BEGIN  
    UPDATE public.t_address SET 
      geog = ST_SetSRID(ST_MakePoint(NEW.longitude,NEW.latitude), 4326)::geography,      ----- WHERE THE PROBLEM IS
      updated_at = date_part('epoch'::text, now()) WHERE address_id=NEW.address_id;

        
    RETURN NULL;
  END;
$fn_t_address_geo_update_event$ LANGUAGE plpgsql;

CREATE TRIGGER tr_t_address_inserted
  AFTER INSERT ON t_address
  FOR EACH ROW
  EXECUTE PROCEDURE fn_t_address_geo_update_event();
CREATE TRIGGER tr_t_user_inserted
  AFTER INSERT ON auth.users
  FOR EACH ROW
  EXECUTE PROCEDURE fn_t_create_user_after_registration();

CREATE OR REPLACE FUNCTION fn_t_create_user_after_registration() RETURNS trigger AS $fn_t_create_user_after_registration$
  DECLARE
    uid bigint;
  BEGIN  
    -- create new record
    INSERT INTO public.t_user (user_id, email)
    VALUES (NEW.id, NEW.email) RETURNING id INTO uid;

    -- create a fake address
    INSERT INTO public.t_address (object_id, object_type, latitude, longitude)
    VALUES (uid, 'user', 0, 0);

    RETURN NEW;
  END;
$fn_t_create_user_after_registration$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION fn_t_address_geo_update_event() RETURNS trigger AS $fn_t_address_geo_update_event$
  BEGIN  
    UPDATE public.t_address SET 
      geog = ST_SetSRID(ST_MakePoint(NEW.longitude,NEW.latitude), 4326)::geography,      ----- WHERE THE PROBLEM IS
      updated_at = date_part('epoch'::text, now()) WHERE address_id=NEW.address_id;

        
    RETURN NULL;
  END;
$fn_t_address_geo_update_event$ LANGUAGE plpgsql;

CREATE TRIGGER tr_t_address_inserted
  AFTER INSERT ON t_address
  FOR EACH ROW
  EXECUTE PROCEDURE fn_t_address_geo_update_event();

Table t_address works perfectly in "regular" query and FUNCTION 'fn_t_create_user_after_registration' has been created with "SECURITY DEFINER" as type of security.

Could anyone please help me?

Many thanks in advance,
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Postgis query - function st_x(geography) does not exist
SupabaseSSupabase / help-and-questions
4y ago
Type "vector" does not exist
SupabaseSSupabase / help-and-questions
6mo ago
type "geometry" does not exist
SupabaseSSupabase / help-and-questions
13mo ago
ERROR: 42704: type "extensions.vector" does not exist
SupabaseSSupabase / help-and-questions
4mo ago