-- -- PostgreSQL database dump -- \restrict jIaZyygk9Cg9Z4ELczVcfs8ceh7EIWutd6NCBTzG3dunNfjBgnAm5uGtlm0D4Zf -- Dumped from database version 17.6 -- Dumped by pg_dump version 17.6 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -- -- Name: _realtime; Type: SCHEMA; Schema: -; Owner: postgres -- CREATE SCHEMA _realtime; ALTER SCHEMA _realtime OWNER TO postgres; -- -- Name: auth; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA auth; ALTER SCHEMA auth OWNER TO supabase_admin; -- -- Name: extensions; Type: SCHEMA; Schema: -; Owner: postgres -- CREATE SCHEMA extensions; ALTER SCHEMA extensions OWNER TO postgres; -- -- Name: graphql; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA graphql; ALTER SCHEMA graphql OWNER TO supabase_admin; -- -- Name: graphql_public; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA graphql_public; ALTER SCHEMA graphql_public OWNER TO supabase_admin; -- -- Name: pg_net; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pg_net WITH SCHEMA extensions; -- -- Name: EXTENSION pg_net; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pg_net IS 'Async HTTP'; -- -- Name: pgbouncer; Type: SCHEMA; Schema: -; Owner: pgbouncer -- CREATE SCHEMA pgbouncer; ALTER SCHEMA pgbouncer OWNER TO pgbouncer; -- -- Name: realtime; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA realtime; ALTER SCHEMA realtime OWNER TO supabase_admin; -- -- Name: storage; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA storage; ALTER SCHEMA storage OWNER TO supabase_admin; -- -- Name: supabase_functions; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA supabase_functions; ALTER SCHEMA supabase_functions OWNER TO supabase_admin; -- -- Name: vault; Type: SCHEMA; Schema: -; Owner: supabase_admin -- CREATE SCHEMA vault; ALTER SCHEMA vault OWNER TO supabase_admin; -- -- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public; -- -- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST'; -- -- Name: citext; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public; -- -- Name: EXTENSION citext; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION citext IS 'data type for case-insensitive character strings'; -- -- Name: pg_graphql; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pg_graphql WITH SCHEMA graphql; -- -- Name: EXTENSION pg_graphql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pg_graphql IS 'pg_graphql: GraphQL support'; -- -- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA extensions; -- -- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; -- -- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; -- -- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; -- -- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA extensions; -- -- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; -- -- Name: supabase_vault; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA vault; -- -- Name: EXTENSION supabase_vault; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION supabase_vault IS 'Supabase Vault Extension'; -- -- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA extensions; -- -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)'; -- -- Name: aal_level; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.aal_level AS ENUM ( 'aal1', 'aal2', 'aal3' ); ALTER TYPE auth.aal_level OWNER TO supabase_auth_admin; -- -- Name: code_challenge_method; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.code_challenge_method AS ENUM ( 's256', 'plain' ); ALTER TYPE auth.code_challenge_method OWNER TO supabase_auth_admin; -- -- Name: factor_status; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.factor_status AS ENUM ( 'unverified', 'verified' ); ALTER TYPE auth.factor_status OWNER TO supabase_auth_admin; -- -- Name: factor_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.factor_type AS ENUM ( 'totp', 'webauthn', 'phone' ); ALTER TYPE auth.factor_type OWNER TO supabase_auth_admin; -- -- Name: oauth_authorization_status; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.oauth_authorization_status AS ENUM ( 'pending', 'approved', 'denied', 'expired' ); ALTER TYPE auth.oauth_authorization_status OWNER TO supabase_auth_admin; -- -- Name: oauth_client_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.oauth_client_type AS ENUM ( 'public', 'confidential' ); ALTER TYPE auth.oauth_client_type OWNER TO supabase_auth_admin; -- -- Name: oauth_registration_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.oauth_registration_type AS ENUM ( 'dynamic', 'manual' ); ALTER TYPE auth.oauth_registration_type OWNER TO supabase_auth_admin; -- -- Name: oauth_response_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.oauth_response_type AS ENUM ( 'code' ); ALTER TYPE auth.oauth_response_type OWNER TO supabase_auth_admin; -- -- Name: one_time_token_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin -- CREATE TYPE auth.one_time_token_type AS ENUM ( 'confirmation_token', 'reauthentication_token', 'recovery_token', 'email_change_token_new', 'email_change_token_current', 'phone_change_token' ); ALTER TYPE auth.one_time_token_type OWNER TO supabase_auth_admin; -- -- Name: commitment_log_source; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.commitment_log_source AS ENUM ( 'manual', 'auto' ); ALTER TYPE public.commitment_log_source OWNER TO supabase_admin; -- -- Name: determined_field_type; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.determined_field_type AS ENUM ( 'text', 'textarea', 'number', 'date', 'select', 'boolean' ); ALTER TYPE public.determined_field_type OWNER TO supabase_admin; -- -- Name: recurrence_exception_type; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.recurrence_exception_type AS ENUM ( 'cancel_session', 'reschedule_session', 'patient_missed', 'therapist_canceled', 'holiday_block' ); ALTER TYPE public.recurrence_exception_type OWNER TO supabase_admin; -- -- Name: recurrence_type; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.recurrence_type AS ENUM ( 'weekly', 'biweekly', 'monthly', 'yearly', 'custom_weekdays' ); ALTER TYPE public.recurrence_type OWNER TO supabase_admin; -- -- Name: status_agenda_serie; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.status_agenda_serie AS ENUM ( 'ativo', 'pausado', 'cancelado' ); ALTER TYPE public.status_agenda_serie OWNER TO supabase_admin; -- -- Name: status_evento_agenda; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.status_evento_agenda AS ENUM ( 'agendado', 'realizado', 'faltou', 'cancelado', 'remarcar' ); ALTER TYPE public.status_evento_agenda OWNER TO supabase_admin; -- -- Name: status_excecao_agenda; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.status_excecao_agenda AS ENUM ( 'pendente', 'ativo', 'arquivado' ); ALTER TYPE public.status_excecao_agenda OWNER TO supabase_admin; -- -- Name: tipo_evento_agenda; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.tipo_evento_agenda AS ENUM ( 'sessao', 'bloqueio' ); ALTER TYPE public.tipo_evento_agenda OWNER TO supabase_admin; -- -- Name: tipo_excecao_agenda; Type: TYPE; Schema: public; Owner: supabase_admin -- CREATE TYPE public.tipo_excecao_agenda AS ENUM ( 'bloqueio', 'horario_extra' ); ALTER TYPE public.tipo_excecao_agenda OWNER TO supabase_admin; -- -- Name: action; Type: TYPE; Schema: realtime; Owner: supabase_admin -- CREATE TYPE realtime.action AS ENUM ( 'INSERT', 'UPDATE', 'DELETE', 'TRUNCATE', 'ERROR' ); ALTER TYPE realtime.action OWNER TO supabase_admin; -- -- Name: equality_op; Type: TYPE; Schema: realtime; Owner: supabase_admin -- CREATE TYPE realtime.equality_op AS ENUM ( 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in' ); ALTER TYPE realtime.equality_op OWNER TO supabase_admin; -- -- Name: user_defined_filter; Type: TYPE; Schema: realtime; Owner: supabase_admin -- CREATE TYPE realtime.user_defined_filter AS ( column_name text, op realtime.equality_op, value text ); ALTER TYPE realtime.user_defined_filter OWNER TO supabase_admin; -- -- Name: wal_column; Type: TYPE; Schema: realtime; Owner: supabase_admin -- CREATE TYPE realtime.wal_column AS ( name text, type_name text, type_oid oid, value jsonb, is_pkey boolean, is_selectable boolean ); ALTER TYPE realtime.wal_column OWNER TO supabase_admin; -- -- Name: wal_rls; Type: TYPE; Schema: realtime; Owner: supabase_admin -- CREATE TYPE realtime.wal_rls AS ( wal jsonb, is_rls_enabled boolean, subscription_ids uuid[], errors text[] ); ALTER TYPE realtime.wal_rls OWNER TO supabase_admin; -- -- Name: buckettype; Type: TYPE; Schema: storage; Owner: supabase_storage_admin -- CREATE TYPE storage.buckettype AS ENUM ( 'STANDARD', 'ANALYTICS', 'VECTOR' ); ALTER TYPE storage.buckettype OWNER TO supabase_storage_admin; -- -- Name: email(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin -- CREATE FUNCTION auth.email() RETURNS text LANGUAGE sql STABLE AS $$ select coalesce( nullif(current_setting('request.jwt.claim.email', true), ''), (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'email') )::text $$; ALTER FUNCTION auth.email() OWNER TO supabase_auth_admin; -- -- Name: FUNCTION email(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON FUNCTION auth.email() IS 'Deprecated. Use auth.jwt() -> ''email'' instead.'; -- -- Name: jwt(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin -- CREATE FUNCTION auth.jwt() RETURNS jsonb LANGUAGE sql STABLE AS $$ select coalesce( nullif(current_setting('request.jwt.claim', true), ''), nullif(current_setting('request.jwt.claims', true), '') )::jsonb $$; ALTER FUNCTION auth.jwt() OWNER TO supabase_auth_admin; -- -- Name: role(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin -- CREATE FUNCTION auth.role() RETURNS text LANGUAGE sql STABLE AS $$ select coalesce( nullif(current_setting('request.jwt.claim.role', true), ''), (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role') )::text $$; ALTER FUNCTION auth.role() OWNER TO supabase_auth_admin; -- -- Name: FUNCTION role(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON FUNCTION auth.role() IS 'Deprecated. Use auth.jwt() -> ''role'' instead.'; -- -- Name: uid(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin -- CREATE FUNCTION auth.uid() RETURNS uuid LANGUAGE sql STABLE AS $$ select coalesce( nullif(current_setting('request.jwt.claim.sub', true), ''), (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub') )::uuid $$; ALTER FUNCTION auth.uid() OWNER TO supabase_auth_admin; -- -- Name: FUNCTION uid(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON FUNCTION auth.uid() IS 'Deprecated. Use auth.jwt() -> ''sub'' instead.'; -- -- Name: grant_pg_cron_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.grant_pg_cron_access() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN IF EXISTS ( SELECT FROM pg_event_trigger_ddl_commands() AS ev JOIN pg_extension AS ext ON ev.objid = ext.oid WHERE ext.extname = 'pg_cron' ) THEN grant usage on schema cron to postgres with grant option; alter default privileges in schema cron grant all on tables to postgres with grant option; alter default privileges in schema cron grant all on functions to postgres with grant option; alter default privileges in schema cron grant all on sequences to postgres with grant option; alter default privileges for user supabase_admin in schema cron grant all on sequences to postgres with grant option; alter default privileges for user supabase_admin in schema cron grant all on tables to postgres with grant option; alter default privileges for user supabase_admin in schema cron grant all on functions to postgres with grant option; grant all privileges on all tables in schema cron to postgres with grant option; revoke all on table cron.job from postgres; grant select on table cron.job to postgres with grant option; END IF; END; $$; ALTER FUNCTION extensions.grant_pg_cron_access() OWNER TO supabase_admin; -- -- Name: FUNCTION grant_pg_cron_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin -- COMMENT ON FUNCTION extensions.grant_pg_cron_access() IS 'Grants access to pg_cron'; -- -- Name: grant_pg_graphql_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.grant_pg_graphql_access() RETURNS event_trigger LANGUAGE plpgsql AS $_$ DECLARE func_is_graphql_resolve bool; BEGIN func_is_graphql_resolve = ( SELECT n.proname = 'resolve' FROM pg_event_trigger_ddl_commands() AS ev LEFT JOIN pg_catalog.pg_proc AS n ON ev.objid = n.oid ); IF func_is_graphql_resolve THEN -- Update public wrapper to pass all arguments through to the pg_graphql resolve func DROP FUNCTION IF EXISTS graphql_public.graphql; create or replace function graphql_public.graphql( "operationName" text default null, query text default null, variables jsonb default null, extensions jsonb default null ) returns jsonb language sql as $$ select graphql.resolve( query := query, variables := coalesce(variables, '{}'), "operationName" := "operationName", extensions := extensions ); $$; -- This hook executes when `graphql.resolve` is created. That is not necessarily the last -- function in the extension so we need to grant permissions on existing entities AND -- update default permissions to any others that are created after `graphql.resolve` grant usage on schema graphql to postgres, anon, authenticated, service_role; grant select on all tables in schema graphql to postgres, anon, authenticated, service_role; grant execute on all functions in schema graphql to postgres, anon, authenticated, service_role; grant all on all sequences in schema graphql to postgres, anon, authenticated, service_role; alter default privileges in schema graphql grant all on tables to postgres, anon, authenticated, service_role; alter default privileges in schema graphql grant all on functions to postgres, anon, authenticated, service_role; alter default privileges in schema graphql grant all on sequences to postgres, anon, authenticated, service_role; -- Allow postgres role to allow granting usage on graphql and graphql_public schemas to custom roles grant usage on schema graphql_public to postgres with grant option; grant usage on schema graphql to postgres with grant option; END IF; END; $_$; ALTER FUNCTION extensions.grant_pg_graphql_access() OWNER TO supabase_admin; -- -- Name: FUNCTION grant_pg_graphql_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin -- COMMENT ON FUNCTION extensions.grant_pg_graphql_access() IS 'Grants access to pg_graphql'; -- -- Name: grant_pg_net_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.grant_pg_net_access() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN IF EXISTS ( SELECT 1 FROM pg_event_trigger_ddl_commands() AS ev JOIN pg_extension AS ext ON ev.objid = ext.oid WHERE ext.extname = 'pg_net' ) THEN GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; END IF; END; $$; ALTER FUNCTION extensions.grant_pg_net_access() OWNER TO supabase_admin; -- -- Name: FUNCTION grant_pg_net_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin -- COMMENT ON FUNCTION extensions.grant_pg_net_access() IS 'Grants access to pg_net'; -- -- Name: pgrst_ddl_watch(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.pgrst_ddl_watch() RETURNS event_trigger LANGUAGE plpgsql AS $$ DECLARE cmd record; BEGIN FOR cmd IN SELECT * FROM pg_event_trigger_ddl_commands() LOOP IF cmd.command_tag IN ( 'CREATE SCHEMA', 'ALTER SCHEMA' , 'CREATE TABLE', 'CREATE TABLE AS', 'SELECT INTO', 'ALTER TABLE' , 'CREATE FOREIGN TABLE', 'ALTER FOREIGN TABLE' , 'CREATE VIEW', 'ALTER VIEW' , 'CREATE MATERIALIZED VIEW', 'ALTER MATERIALIZED VIEW' , 'CREATE FUNCTION', 'ALTER FUNCTION' , 'CREATE TRIGGER' , 'CREATE TYPE', 'ALTER TYPE' , 'CREATE RULE' , 'COMMENT' ) -- don't notify in case of CREATE TEMP table or other objects created on pg_temp AND cmd.schema_name is distinct from 'pg_temp' THEN NOTIFY pgrst, 'reload schema'; END IF; END LOOP; END; $$; ALTER FUNCTION extensions.pgrst_ddl_watch() OWNER TO supabase_admin; -- -- Name: pgrst_drop_watch(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.pgrst_drop_watch() RETURNS event_trigger LANGUAGE plpgsql AS $$ DECLARE obj record; BEGIN FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() LOOP IF obj.object_type IN ( 'schema' , 'table' , 'foreign table' , 'view' , 'materialized view' , 'function' , 'trigger' , 'type' , 'rule' ) AND obj.is_temporary IS false -- no pg_temp objects THEN NOTIFY pgrst, 'reload schema'; END IF; END LOOP; END; $$; ALTER FUNCTION extensions.pgrst_drop_watch() OWNER TO supabase_admin; -- -- Name: set_graphql_placeholder(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin -- CREATE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger LANGUAGE plpgsql AS $_$ DECLARE graphql_is_dropped bool; BEGIN graphql_is_dropped = ( SELECT ev.schema_name = 'graphql_public' FROM pg_event_trigger_dropped_objects() AS ev WHERE ev.schema_name = 'graphql_public' ); IF graphql_is_dropped THEN create or replace function graphql_public.graphql( "operationName" text default null, query text default null, variables jsonb default null, extensions jsonb default null ) returns jsonb language plpgsql as $$ DECLARE server_version float; BEGIN server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float); IF server_version >= 14 THEN RETURN jsonb_build_object( 'errors', jsonb_build_array( jsonb_build_object( 'message', 'pg_graphql extension is not enabled.' ) ) ); ELSE RETURN jsonb_build_object( 'errors', jsonb_build_array( jsonb_build_object( 'message', 'pg_graphql is only available on projects running Postgres 14 onwards.' ) ) ); END IF; END; $$; END IF; END; $_$; ALTER FUNCTION extensions.set_graphql_placeholder() OWNER TO supabase_admin; -- -- Name: FUNCTION set_graphql_placeholder(); Type: COMMENT; Schema: extensions; Owner: supabase_admin -- COMMENT ON FUNCTION extensions.set_graphql_placeholder() IS 'Reintroduces placeholder function for graphql_public.graphql'; -- -- Name: get_auth(text); Type: FUNCTION; Schema: pgbouncer; Owner: supabase_admin -- CREATE FUNCTION pgbouncer.get_auth(p_usename text) RETURNS TABLE(username text, password text) LANGUAGE plpgsql SECURITY DEFINER SET search_path TO '' AS $_$ begin raise debug 'PgBouncer auth request: %', p_usename; return query select rolname::text, case when rolvaliduntil < now() then null else rolpassword::text end from pg_authid where rolname=$1 and rolcanlogin; end; $_$; ALTER FUNCTION pgbouncer.get_auth(p_usename text) OWNER TO supabase_admin; -- -- Name: __rls_ping(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.__rls_ping() RETURNS text LANGUAGE sql STABLE AS $$ select 'ok'::text; $$; ALTER FUNCTION public.__rls_ping() OWNER TO supabase_admin; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: subscriptions; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.subscriptions ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid, plan_id uuid NOT NULL, status text DEFAULT 'active'::text NOT NULL, current_period_start timestamp with time zone, current_period_end timestamp with time zone, cancel_at_period_end boolean DEFAULT false NOT NULL, provider text DEFAULT 'manual'::text NOT NULL, provider_customer_id text, provider_subscription_id text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid, plan_key text, "interval" text, source text DEFAULT 'manual'::text NOT NULL, started_at timestamp with time zone DEFAULT now() NOT NULL, canceled_at timestamp with time zone, activated_at timestamp with time zone, past_due_since timestamp with time zone, suspended_at timestamp with time zone, suspended_reason text, cancelled_at timestamp with time zone, cancel_reason text, expired_at timestamp with time zone, CONSTRAINT subscriptions_interval_check CHECK (("interval" = ANY (ARRAY['month'::text, 'year'::text]))), CONSTRAINT subscriptions_owner_xor CHECK ((((tenant_id IS NOT NULL) AND (user_id IS NULL)) OR ((tenant_id IS NULL) AND (user_id IS NOT NULL)))), CONSTRAINT subscriptions_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'active'::text, 'past_due'::text, 'suspended'::text, 'cancelled'::text, 'expired'::text]))) ); ALTER TABLE public.subscriptions OWNER TO supabase_admin; -- -- Name: activate_subscription_from_intent(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) RETURNS public.subscriptions LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_intent record; v_sub public.subscriptions; v_days int; v_user_id uuid; v_plan_id uuid; v_target text; begin -- lê pela VIEW unificada select * into v_intent from public.subscription_intents where id = p_intent_id; if not found then raise exception 'Intent não encontrado: %', p_intent_id; end if; if v_intent.status <> 'paid' then raise exception 'Intent precisa estar paid para ativar assinatura'; end if; -- resolve target e plan_id via plans.key select p.id, p.target into v_plan_id, v_target from public.plans p where p.key = v_intent.plan_key limit 1; if v_plan_id is null then raise exception 'Plano não encontrado em plans.key = %', v_intent.plan_key; end if; v_target := lower(coalesce(v_target, '')); -- ✅ supervisor adicionado if v_target not in ('clinic', 'therapist', 'supervisor') then raise exception 'Target inválido em plans.target: %', v_target; end if; -- regra por target if v_target = 'clinic' then if v_intent.tenant_id is null then raise exception 'Intent sem tenant_id'; end if; else -- therapist ou supervisor: vinculado ao user v_user_id := v_intent.user_id; if v_user_id is null then v_user_id := v_intent.created_by_user_id; end if; end if; if v_target in ('therapist', 'supervisor') and v_user_id is null then raise exception 'Não foi possível determinar user_id para assinatura %.', v_target; end if; -- cancela assinatura ativa anterior if v_target = 'clinic' then update public.subscriptions set status = 'cancelled', cancelled_at = now() where tenant_id = v_intent.tenant_id and plan_id = v_plan_id and status = 'active'; else -- therapist ou supervisor update public.subscriptions set status = 'cancelled', cancelled_at = now() where user_id = v_user_id and plan_id = v_plan_id and status = 'active' and tenant_id is null; end if; -- duração do plano (30 dias para mensal) v_days := case when lower(coalesce(v_intent.interval, 'month')) = 'year' then 365 else 30 end; -- cria nova assinatura insert into public.subscriptions ( user_id, plan_id, status, started_at, expires_at, cancelled_at, activated_at, tenant_id, plan_key, interval, source, created_at, updated_at ) values ( case when v_target = 'clinic' then null else v_user_id end, v_plan_id, 'active', now(), now() + make_interval(days => v_days), null, now(), case when v_target = 'clinic' then v_intent.tenant_id else null end, v_intent.plan_key, v_intent.interval, 'manual', now(), now() ) returning * into v_sub; -- grava vínculo intent → subscription if v_target = 'clinic' then update public.subscription_intents_tenant set subscription_id = v_sub.id where id = p_intent_id; else update public.subscription_intents_personal set subscription_id = v_sub.id where id = p_intent_id; end if; return v_sub; end; $$; ALTER FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) OWNER TO supabase_admin; -- -- Name: admin_fix_plan_target(text, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_plan_id uuid; begin -- (opcional) restringe targets válidos if p_new_target not in ('clinic','therapist') then raise exception 'Target inválido: %', p_new_target using errcode='P0001'; end if; -- trava o plano select id into v_plan_id from public.plans where key = p_plan_key for update; if v_plan_id is null then raise exception 'Plano não encontrado: %', p_plan_key using errcode='P0001'; end if; -- segurança: não mexer se existe subscription if exists (select 1 from public.subscriptions s where s.plan_id = v_plan_id) then raise exception 'Plano % possui subscriptions. Migração bloqueada.', p_plan_key using errcode='P0001'; end if; -- liga bypass SOMENTE nesta transação perform set_config('app.plan_migration_bypass', '1', true); update public.plans set target = p_new_target where id = v_plan_id; end $$; ALTER FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) OWNER TO supabase_admin; -- -- Name: agenda_cfg_sync(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.agenda_cfg_sync() RETURNS trigger LANGUAGE plpgsql AS $$ begin if new.agenda_view_mode = 'custom' then new.usar_horario_admin_custom := true; new.admin_inicio_visualizacao := new.agenda_custom_start; new.admin_fim_visualizacao := new.agenda_custom_end; else new.usar_horario_admin_custom := false; end if; return new; end; $$; ALTER FUNCTION public.agenda_cfg_sync() OWNER TO supabase_admin; -- -- Name: agendador_dias_disponiveis(text, integer, integer); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) RETURNS TABLE(data date, tem_slots boolean) LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_owner_id uuid; v_antecedencia int; v_agora timestamptz; v_data date; v_data_inicio date; v_data_fim date; v_db_dow int; v_tem_slot boolean; BEGIN SELECT c.owner_id, c.antecedencia_minima_horas INTO v_owner_id, v_antecedencia FROM public.agendador_configuracoes c WHERE c.link_slug = p_slug AND c.ativo = true LIMIT 1; IF v_owner_id IS NULL THEN RETURN; END IF; v_agora := now(); v_data_inicio := make_date(p_ano, p_mes, 1); v_data_fim := (v_data_inicio + interval '1 month' - interval '1 day')::date; v_data := v_data_inicio; WHILE v_data <= v_data_fim LOOP v_db_dow := extract(dow from v_data::timestamp)::int; SELECT EXISTS ( SELECT 1 FROM public.agenda_online_slots s WHERE s.owner_id = v_owner_id AND s.weekday = v_db_dow AND s.enabled = true AND (v_data::text || ' ' || s.time::text)::timestamp AT TIME ZONE 'America/Sao_Paulo' >= v_agora + (v_antecedencia || ' hours')::interval ) INTO v_tem_slot; IF v_tem_slot THEN data := v_data; tem_slots := true; RETURN NEXT; END IF; v_data := v_data + 1; END LOOP; END; $$; ALTER FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) OWNER TO supabase_admin; -- -- Name: agendador_gerar_slug(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.agendador_gerar_slug() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE v_slug text; v_exists boolean; BEGIN -- só gera se ativou e não tem slug ainda IF NEW.ativo = true AND (NEW.link_slug IS NULL OR NEW.link_slug = '') THEN LOOP v_slug := lower(substring(replace(gen_random_uuid()::text, '-', ''), 1, 8)); SELECT EXISTS ( SELECT 1 FROM public.agendador_configuracoes WHERE link_slug = v_slug AND owner_id <> NEW.owner_id ) INTO v_exists; EXIT WHEN NOT v_exists; END LOOP; NEW.link_slug := v_slug; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.agendador_gerar_slug() OWNER TO supabase_admin; -- -- Name: agendador_slots_disponiveis(text, date); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) RETURNS TABLE(hora time without time zone, disponivel boolean) LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_owner_id uuid; v_duracao int; v_antecedencia int; v_agora timestamptz; v_db_dow int; v_slot time; v_slot_fim time; v_slot_ts timestamptz; v_ocupado boolean; -- loop de recorrências v_rule RECORD; v_rule_start_dow int; v_first_occ date; v_day_diff int; v_ex_type text; BEGIN SELECT c.owner_id, c.duracao_sessao_min, c.antecedencia_minima_horas INTO v_owner_id, v_duracao, v_antecedencia FROM public.agendador_configuracoes c WHERE c.link_slug = p_slug AND c.ativo = true LIMIT 1; IF v_owner_id IS NULL THEN RETURN; END IF; v_agora := now(); v_db_dow := extract(dow from p_data::timestamp)::int; FOR v_slot IN SELECT s.time FROM public.agenda_online_slots s WHERE s.owner_id = v_owner_id AND s.weekday = v_db_dow AND s.enabled = true ORDER BY s.time LOOP v_slot_fim := v_slot + (v_duracao || ' minutes')::interval; v_ocupado := false; -- ── Antecedência mínima ────────────────────────────────────────────────── v_slot_ts := (p_data::text || ' ' || v_slot::text)::timestamp AT TIME ZONE 'America/Sao_Paulo'; IF v_slot_ts < v_agora + (v_antecedencia || ' hours')::interval THEN v_ocupado := true; END IF; -- ── Eventos avulsos internos (agenda_eventos) ──────────────────────────── IF NOT v_ocupado THEN SELECT EXISTS ( SELECT 1 FROM public.agenda_eventos e WHERE e.owner_id = v_owner_id AND e.status::text NOT IN ('cancelado', 'faltou') AND (e.inicio_em AT TIME ZONE 'America/Sao_Paulo')::date = p_data AND (e.inicio_em AT TIME ZONE 'America/Sao_Paulo')::time < v_slot_fim AND (e.fim_em AT TIME ZONE 'America/Sao_Paulo')::time > v_slot ) INTO v_ocupado; END IF; -- ── Recorrências ativas (recurrence_rules) ─────────────────────────────── -- Loop explícito para evitar erros de tipo no cálculo do ciclo semanal IF NOT v_ocupado THEN FOR v_rule IN SELECT r.id, r.start_date::date AS start_date, r.end_date::date AS end_date, r.start_time::time AS start_time, r.end_time::time AS end_time, COALESCE(r.interval, 1)::int AS interval FROM public.recurrence_rules r WHERE r.owner_id = v_owner_id AND r.status = 'ativo' AND p_data >= r.start_date::date AND (r.end_date IS NULL OR p_data <= r.end_date::date) AND v_db_dow = ANY(r.weekdays) AND r.start_time::time < v_slot_fim AND r.end_time::time > v_slot LOOP -- Calcula a primeira ocorrência do dia-da-semana a partir do start_date v_rule_start_dow := extract(dow from v_rule.start_date)::int; v_first_occ := v_rule.start_date + (((v_db_dow - v_rule_start_dow + 7) % 7))::int; v_day_diff := (p_data - v_first_occ)::int; -- Ocorrência válida: diff >= 0 e divisível pelo ciclo semanal IF v_day_diff >= 0 AND v_day_diff % (7 * v_rule.interval) = 0 THEN -- Verifica se há exceção para esta data v_ex_type := NULL; SELECT ex.type INTO v_ex_type FROM public.recurrence_exceptions ex WHERE ex.recurrence_id = v_rule.id AND ex.original_date = p_data LIMIT 1; -- Sem exceção, ou exceção que não cancela → bloqueia o slot IF v_ex_type IS NULL OR v_ex_type NOT IN ( 'cancel_session', 'patient_missed', 'therapist_canceled', 'holiday_block', 'reschedule_session' ) THEN v_ocupado := true; EXIT; -- já basta uma regra que conflite END IF; END IF; END LOOP; END IF; -- ── Recorrências remarcadas para este dia (reschedule → new_date = p_data) ─ IF NOT v_ocupado THEN SELECT EXISTS ( SELECT 1 FROM public.recurrence_exceptions ex JOIN public.recurrence_rules r ON r.id = ex.recurrence_id WHERE r.owner_id = v_owner_id AND r.status = 'ativo' AND ex.type = 'reschedule_session' AND ex.new_date = p_data AND COALESCE(ex.new_start_time, r.start_time)::time < v_slot_fim AND COALESCE(ex.new_end_time, r.end_time)::time > v_slot ) INTO v_ocupado; END IF; -- ── Solicitações públicas pendentes ────────────────────────────────────── IF NOT v_ocupado THEN SELECT EXISTS ( SELECT 1 FROM public.agendador_solicitacoes sol WHERE sol.owner_id = v_owner_id AND sol.status = 'pendente' AND sol.data_solicitada = p_data AND sol.hora_solicitada = v_slot AND (sol.reservado_ate IS NULL OR sol.reservado_ate > v_agora) ) INTO v_ocupado; END IF; hora := v_slot; disponivel := NOT v_ocupado; RETURN NEXT; END LOOP; END; $$; ALTER FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) OWNER TO supabase_admin; -- -- Name: cancel_recurrence_from(uuid, date); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ BEGIN UPDATE public.recurrence_rules SET end_date = p_from_date - INTERVAL '1 day', open_ended = false, status = CASE WHEN p_from_date <= start_date THEN 'cancelado' ELSE status END, updated_at = now() WHERE id = p_recurrence_id; END; $$; ALTER FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) OWNER TO supabase_admin; -- -- Name: cancel_subscription(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.cancel_subscription(p_subscription_id uuid) RETURNS public.subscriptions LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_sub public.subscriptions; v_owner_type text; v_owner_ref uuid; begin select * into v_sub from public.subscriptions where id = p_subscription_id for update; if not found then raise exception 'Subscription não encontrada'; end if; if v_sub.status = 'canceled' then return v_sub; end if; if v_sub.tenant_id is not null then v_owner_type := 'clinic'; v_owner_ref := v_sub.tenant_id; elsif v_sub.user_id is not null then v_owner_type := 'therapist'; v_owner_ref := v_sub.user_id; else v_owner_type := null; v_owner_ref := null; end if; update public.subscriptions set status = 'canceled', cancel_at_period_end = false, updated_at = now() where id = p_subscription_id returning * into v_sub; insert into public.subscription_events( subscription_id, owner_id, owner_type, owner_ref, event_type, old_plan_id, new_plan_id, created_by, reason, source, metadata ) values ( v_sub.id, v_owner_ref, v_owner_type, v_owner_ref, 'canceled', v_sub.plan_id, v_sub.plan_id, auth.uid(), 'Cancelamento manual via admin', 'admin_panel', jsonb_build_object('previous_status', 'active') ); if v_owner_ref is not null then insert into public.entitlements_invalidation(owner_id, changed_at) values (v_owner_ref, now()) on conflict (owner_id) do update set changed_at = excluded.changed_at; end if; return v_sub; end; $$; ALTER FUNCTION public.cancel_subscription(p_subscription_id uuid) OWNER TO supabase_admin; -- -- Name: cancelar_eventos_serie(uuid, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone DEFAULT now()) RETURNS integer LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_count integer; BEGIN UPDATE public.agenda_eventos SET status = 'cancelado', updated_at = now() WHERE serie_id = p_serie_id AND inicio_em >= p_a_partir_de AND status NOT IN ('realizado', 'cancelado'); GET DIAGNOSTICS v_count = ROW_COUNT; RETURN v_count; END; $$; ALTER FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) OWNER TO supabase_admin; -- -- Name: FUNCTION cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone); Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) IS 'Cancela todos os eventos futuros de uma série a partir de p_a_partir_de (inclusive). Não cancela eventos já realizados.'; -- -- Name: change_subscription_plan(uuid, uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) RETURNS public.subscriptions LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_sub public.subscriptions; v_old_plan uuid; v_new_key text; v_owner_type text; v_owner_ref uuid; v_new_target text; v_sub_target text; begin select * into v_sub from public.subscriptions where id = p_subscription_id for update; if not found then raise exception 'Subscription não encontrada'; end if; v_old_plan := v_sub.plan_id; if v_old_plan = p_new_plan_id then return v_sub; end if; select key, target into v_new_key, v_new_target from public.plans where id = p_new_plan_id; if v_new_key is null then raise exception 'Plano não encontrado'; end if; v_new_target := lower(coalesce(v_new_target, '')); v_sub_target := case when v_sub.tenant_id is not null then 'clinic' else 'therapist' end; if v_new_target <> v_sub_target then raise exception 'Plano inválido para este tipo de assinatura. Assinatura é % e o plano é %.', v_sub_target, v_new_target using errcode = 'P0001'; end if; if v_sub.tenant_id is not null then v_owner_type := 'clinic'; v_owner_ref := v_sub.tenant_id; elsif v_sub.user_id is not null then v_owner_type := 'therapist'; v_owner_ref := v_sub.user_id; else v_owner_type := null; v_owner_ref := null; end if; update public.subscriptions set plan_id = p_new_plan_id, plan_key = v_new_key, updated_at = now() where id = p_subscription_id returning * into v_sub; insert into public.subscription_events( subscription_id, owner_id, owner_type, owner_ref, event_type, old_plan_id, new_plan_id, created_by, reason, source, metadata ) values ( v_sub.id, v_owner_ref, v_owner_type, v_owner_ref, 'plan_changed', v_old_plan, p_new_plan_id, auth.uid(), 'Plan change via DEV menu', 'dev_menu', jsonb_build_object( 'previous_plan', v_old_plan, 'new_plan', p_new_plan_id, 'new_plan_key', v_new_key, 'new_plan_target', v_new_target ) ); if v_owner_ref is not null then insert into public.entitlements_invalidation (owner_id, changed_at) values (v_owner_ref, now()) on conflict (owner_id) do update set changed_at = excluded.changed_at; end if; return v_sub; end; $$; ALTER FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) OWNER TO supabase_admin; -- -- Name: create_clinic_tenant(text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.create_clinic_tenant(p_name text) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_uid uuid; v_tenant uuid; v_name text; begin v_uid := auth.uid(); if v_uid is null then raise exception 'Not authenticated'; end if; v_name := nullif(trim(coalesce(p_name, '')), ''); if v_name is null then v_name := 'Clínica'; end if; insert into public.tenants (name, kind, created_at) values (v_name, 'clinic', now()) returning id into v_tenant; insert into public.tenant_members (tenant_id, user_id, role, status, created_at) values (v_tenant, v_uid, 'tenant_admin', 'active', now()); return v_tenant; end; $$; ALTER FUNCTION public.create_clinic_tenant(p_name text) OWNER TO supabase_admin; -- -- Name: create_patient_intake_request(text, text, text, text, text, boolean); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text DEFAULT NULL::text, p_phone text DEFAULT NULL::text, p_notes text DEFAULT NULL::text, p_consent boolean DEFAULT false) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ declare v_owner uuid; v_active boolean; v_expires timestamptz; v_max_uses int; v_uses int; v_id uuid; begin select owner_id, active, expires_at, max_uses, uses into v_owner, v_active, v_expires, v_max_uses, v_uses from public.patient_invites where token = p_token limit 1; if v_owner is null then raise exception 'Token inválido'; end if; if v_active is not true then raise exception 'Link desativado'; end if; if v_expires is not null and now() > v_expires then raise exception 'Link expirado'; end if; if v_max_uses is not null and v_uses >= v_max_uses then raise exception 'Limite de uso atingido'; end if; if p_name is null or length(trim(p_name)) = 0 then raise exception 'Nome é obrigatório'; end if; insert into public.patient_intake_requests (owner_id, token, name, email, phone, notes, consent, status) values (v_owner, p_token, trim(p_name), nullif(lower(trim(p_email)), ''), nullif(trim(p_phone), ''), nullif(trim(p_notes), ''), coalesce(p_consent, false), 'new') returning id into v_id; update public.patient_invites set uses = uses + 1 where token = p_token; return v_id; end; $$; ALTER FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean) OWNER TO supabase_admin; -- -- Name: create_patient_intake_request_v2(text, jsonb); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $_$ declare v_owner_id uuid; v_intake_id uuid; v_birth_raw text; v_birth date; begin select owner_id into v_owner_id from public.patient_invites where token = p_token; if v_owner_id is null then raise exception 'Token inválido ou expirado'; end if; v_birth_raw := nullif(trim(coalesce( p_payload->>'data_nascimento', '' )), ''); v_birth := case when v_birth_raw is null then null when v_birth_raw ~ '^\d{4}-\d{2}-\d{2}$' then v_birth_raw::date when v_birth_raw ~ '^\d{2}-\d{2}-\d{4}$' then to_date(v_birth_raw, 'DD-MM-YYYY') else null end; insert into public.patient_intake_requests ( owner_id, token, status, consent, nome_completo, email_principal, telefone, avatar_url, -- 🔥 AQUI data_nascimento, cpf, rg, genero, estado_civil, profissao, escolaridade, nacionalidade, naturalidade, cep, pais, cidade, estado, endereco, numero, complemento, bairro, observacoes, notas_internas, encaminhado_por, onde_nos_conheceu ) values ( v_owner_id, p_token, 'new', coalesce((p_payload->>'consent')::boolean, false), nullif(trim(p_payload->>'nome_completo'), ''), nullif(trim(p_payload->>'email_principal'), ''), nullif(regexp_replace(coalesce(p_payload->>'telefone',''), '\D', '', 'g'), ''), nullif(trim(p_payload->>'avatar_url'), ''), -- 🔥 AQUI v_birth, nullif(regexp_replace(coalesce(p_payload->>'cpf',''), '\D', '', 'g'), ''), nullif(trim(p_payload->>'rg'), ''), nullif(trim(p_payload->>'genero'), ''), nullif(trim(p_payload->>'estado_civil'), ''), nullif(trim(p_payload->>'profissao'), ''), nullif(trim(p_payload->>'escolaridade'), ''), nullif(trim(p_payload->>'nacionalidade'), ''), nullif(trim(p_payload->>'naturalidade'), ''), nullif(regexp_replace(coalesce(p_payload->>'cep',''), '\D', '', 'g'), ''), nullif(trim(p_payload->>'pais'), ''), nullif(trim(p_payload->>'cidade'), ''), nullif(trim(p_payload->>'estado'), ''), nullif(trim(p_payload->>'endereco'), ''), nullif(trim(p_payload->>'numero'), ''), nullif(trim(p_payload->>'complemento'), ''), nullif(trim(p_payload->>'bairro'), ''), nullif(trim(p_payload->>'observacoes'), ''), nullif(trim(p_payload->>'notas_internas'), ''), nullif(trim(p_payload->>'encaminhado_por'), ''), nullif(trim(p_payload->>'onde_nos_conheceu'), '') ) returning id into v_intake_id; return v_intake_id; end; $_$; ALTER FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) OWNER TO supabase_admin; -- -- Name: create_support_session(uuid, integer); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer DEFAULT 60) RETURNS json LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_admin_id uuid; v_role text; v_token text; v_expires timestamp with time zone; v_session support_sessions; BEGIN -- Verifica autenticação v_admin_id := auth.uid(); IF v_admin_id IS NULL THEN RAISE EXCEPTION 'Não autenticado.' USING ERRCODE = 'P0001'; END IF; -- Verifica role saas_admin SELECT role INTO v_role FROM public.profiles WHERE id = v_admin_id; IF v_role <> 'saas_admin' THEN RAISE EXCEPTION 'Acesso negado. Somente saas_admin pode criar sessões de suporte.' USING ERRCODE = 'P0002'; END IF; -- Valida TTL (1 a 120 minutos) IF p_ttl_minutes < 1 OR p_ttl_minutes > 120 THEN RAISE EXCEPTION 'TTL inválido. Use entre 1 e 120 minutos.' USING ERRCODE = 'P0003'; END IF; -- Valida tenant IF NOT EXISTS (SELECT 1 FROM public.tenants WHERE id = p_tenant_id) THEN RAISE EXCEPTION 'Tenant não encontrado.' USING ERRCODE = 'P0004'; END IF; -- Gera token único (64 chars hex, sem pgcrypto) v_token := replace(gen_random_uuid()::text, '-', '') || replace(gen_random_uuid()::text, '-', ''); v_expires := now() + (p_ttl_minutes || ' minutes')::interval; -- Insere sessão INSERT INTO public.support_sessions (tenant_id, admin_id, token, expires_at) VALUES (p_tenant_id, v_admin_id, v_token, v_expires) RETURNING * INTO v_session; RETURN json_build_object( 'token', v_session.token, 'expires_at', v_session.expires_at, 'session_id', v_session.id ); END; $$; ALTER FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer) OWNER TO supabase_admin; -- -- Name: current_member_id(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.current_member_id(p_tenant_id uuid) RETURNS uuid LANGUAGE sql STABLE AS $$ select tm.id from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() limit 1 $$; ALTER FUNCTION public.current_member_id(p_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: current_member_role(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.current_member_role(p_tenant_id uuid) RETURNS text LANGUAGE sql STABLE AS $$ select tm.role from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() limit 1 $$; ALTER FUNCTION public.current_member_role(p_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: delete_commitment_full(uuid, uuid); Type: FUNCTION; Schema: public; Owner: postgres -- CREATE FUNCTION public.delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid) RETURNS jsonb LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ declare v_is_native boolean; v_fields int := 0; v_logs int := 0; v_parent int := 0; begin if auth.uid() is null then raise exception 'Not authenticated'; end if; if not exists ( select 1 from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() and tm.status = 'active' ) then raise exception 'Not allowed'; end if; select dc.is_native into v_is_native from public.determined_commitments dc where dc.tenant_id = p_tenant_id and dc.id = p_commitment_id; if v_is_native is null then raise exception 'Commitment not found'; end if; if v_is_native = true then raise exception 'Cannot delete native commitment'; end if; delete from public.determined_commitment_fields where tenant_id = p_tenant_id and commitment_id = p_commitment_id; get diagnostics v_fields = row_count; delete from public.commitment_time_logs where tenant_id = p_tenant_id and commitment_id = p_commitment_id; get diagnostics v_logs = row_count; delete from public.determined_commitments where tenant_id = p_tenant_id and id = p_commitment_id; get diagnostics v_parent = row_count; if v_parent <> 1 then raise exception 'Parent not deleted (RLS/owner issue).'; end if; return jsonb_build_object( 'ok', true, 'deleted', jsonb_build_object( 'fields', v_fields, 'logs', v_logs, 'commitment', v_parent ) ); end; $$; ALTER FUNCTION public.delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid) OWNER TO postgres; -- -- Name: delete_determined_commitment(uuid, uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) RETURNS jsonb LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ declare v_is_native boolean; v_fields_deleted int := 0; v_logs_deleted int := 0; v_commitment_deleted int := 0; begin if auth.uid() is null then raise exception 'Not authenticated'; end if; if not exists ( select 1 from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() and tm.status = 'active' ) then raise exception 'Not allowed'; end if; select dc.is_native into v_is_native from public.determined_commitments dc where dc.tenant_id = p_tenant_id and dc.id = p_commitment_id; if v_is_native is null then raise exception 'Commitment not found for tenant'; end if; if v_is_native = true then raise exception 'Cannot delete native commitment'; end if; delete from public.determined_commitment_fields f where f.tenant_id = p_tenant_id and f.commitment_id = p_commitment_id; get diagnostics v_fields_deleted = row_count; delete from public.commitment_time_logs l where l.tenant_id = p_tenant_id and l.commitment_id = p_commitment_id; get diagnostics v_logs_deleted = row_count; delete from public.determined_commitments dc where dc.tenant_id = p_tenant_id and dc.id = p_commitment_id; get diagnostics v_commitment_deleted = row_count; if v_commitment_deleted <> 1 then raise exception 'Delete did not remove the commitment (tenant mismatch?)'; end if; return jsonb_build_object( 'ok', true, 'tenant_id', p_tenant_id, 'commitment_id', p_commitment_id, 'deleted', jsonb_build_object( 'fields', v_fields_deleted, 'logs', v_logs_deleted, 'commitment', v_commitment_deleted ) ); end; $$; ALTER FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) OWNER TO supabase_admin; -- -- Name: dev_list_auth_users(integer); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.dev_list_auth_users(p_limit integer DEFAULT 50) RETURNS TABLE(id uuid, email text, created_at timestamp with time zone) LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public', 'auth' AS $$ begin -- só saas_admin pode ver if not exists ( select 1 from public.profiles p where p.id = auth.uid() and p.role = 'saas_admin' ) then return; end if; return query select u.id, u.email, u.created_at from auth.users u order by u.created_at desc limit greatest(1, least(coalesce(p_limit, 50), 500)); end; $$; ALTER FUNCTION public.dev_list_auth_users(p_limit integer) OWNER TO supabase_admin; -- -- Name: dev_list_custom_users(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.dev_list_custom_users() RETURNS TABLE(user_id uuid, email text, created_at timestamp with time zone, global_role text, tenant_role text, tenant_id uuid, password_dev text, kind text) LANGUAGE sql SECURITY DEFINER SET search_path TO 'public' AS $$ with base as ( select u.id as user_id, lower(u.email) as email, u.created_at from auth.users u where lower(u.email) not in ( 'clinic@agenciapsi.com.br', 'therapist@agenciapsi.com.br', 'patient@agenciapsi.com.br', 'saas@agenciapsi.com.br' ) ), prof as ( select p.id, p.role as global_role from public.profiles p ), last_membership as ( select distinct on (tm.user_id) tm.user_id, tm.tenant_id, tm.role as tenant_role, tm.created_at from public.tenant_members tm where tm.status = 'active' order by tm.user_id, tm.created_at desc ) select b.user_id, b.email, b.created_at, pr.global_role, lm.tenant_role, lm.tenant_id, dc.password_dev, dc.kind from base b left join prof pr on pr.id = b.user_id left join last_membership lm on lm.user_id = b.user_id left join public.dev_user_credentials dc on lower(dc.email) = b.email order by b.created_at desc; $$; ALTER FUNCTION public.dev_list_custom_users() OWNER TO supabase_admin; -- -- Name: dev_list_intent_leads(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.dev_list_intent_leads() RETURNS TABLE(email text, last_intent_at timestamp with time zone, plan_key text, billing_interval text, status text, tenant_id uuid) LANGUAGE sql SECURITY DEFINER SET search_path TO 'public' AS $$ select lower(si.email) as email, max(si.created_at) as last_intent_at, (array_agg(si.plan_key order by si.created_at desc))[1] as plan_key, (array_agg(si.interval order by si.created_at desc))[1] as billing_interval, (array_agg(si.status order by si.created_at desc))[1] as status, (array_agg(si.tenant_id order by si.created_at desc))[1] as tenant_id from public.subscription_intents si where si.email is not null and not exists ( select 1 from auth.users au where lower(au.email) = lower(si.email) ) group by lower(si.email) order by max(si.created_at) desc; $$; ALTER FUNCTION public.dev_list_intent_leads() OWNER TO supabase_admin; -- -- Name: dev_public_debug_snapshot(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.dev_public_debug_snapshot() RETURNS TABLE(users_total integer, tenants_total integer, intents_new_total integer, latest_intents jsonb) LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $_$ declare v_latest jsonb; begin select jsonb_agg( jsonb_build_object( 'created_at', si.created_at, 'email_masked', regexp_replace(lower(si.email), '(^.).*(@.*$)', '\1***\2'), 'plan_key', si.plan_key, 'status', si.status ) order by si.created_at desc ) into v_latest from ( select si.* from public.subscription_intents si where si.email is not null order by si.created_at desc limit 5 ) si; return query select (select count(*)::int from auth.users) as users_total, (select count(*)::int from public.tenants) as tenants_total, (select count(*)::int from public.subscription_intents where status = 'new') as intents_new_total, coalesce(v_latest, '[]'::jsonb) as latest_intents; end; $_$; ALTER FUNCTION public.dev_public_debug_snapshot() OWNER TO supabase_admin; -- -- Name: ensure_personal_tenant(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.ensure_personal_tenant() RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_uid uuid; v_existing uuid; BEGIN v_uid := auth.uid(); IF v_uid IS NULL THEN RAISE EXCEPTION 'Not authenticated'; END IF; SELECT tm.tenant_id INTO v_existing FROM public.tenant_members tm JOIN public.tenants t ON t.id = tm.tenant_id WHERE tm.user_id = v_uid AND tm.status = 'active' AND t.kind IN ('therapist', 'saas') ORDER BY tm.created_at DESC LIMIT 1; IF v_existing IS NOT NULL THEN RETURN v_existing; END IF; RETURN public.provision_account_tenant(v_uid, 'therapist'); END; $$; ALTER FUNCTION public.ensure_personal_tenant() OWNER TO supabase_admin; -- -- Name: ensure_personal_tenant_for_user(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_uid uuid; v_existing uuid; v_tenant uuid; v_email text; v_name text; begin v_uid := p_user_id; if v_uid is null then raise exception 'Missing user id'; end if; -- só considera tenant pessoal (kind='saas') select tm.tenant_id into v_existing from public.tenant_members tm join public.tenants t on t.id = tm.tenant_id where tm.user_id = v_uid and tm.status = 'active' and t.kind = 'saas' order by tm.created_at desc limit 1; if v_existing is not null then return v_existing; end if; select email into v_email from auth.users where id = v_uid; v_name := coalesce(split_part(v_email, '@', 1), 'Conta'); insert into public.tenants (name, kind, created_at) values (v_name || ' (Pessoal)', 'saas', now()) returning id into v_tenant; insert into public.tenant_members (tenant_id, user_id, role, status, created_at) values (v_tenant, v_uid, 'tenant_admin', 'active', now()); return v_tenant; end; $$; ALTER FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) OWNER TO supabase_admin; -- -- Name: faq_votar(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.faq_votar(faq_id uuid) RETURNS void LANGUAGE sql SECURITY DEFINER AS $$ update public.saas_faq set votos = votos + 1, updated_at = now() where id = faq_id and ativo = true; $$; ALTER FUNCTION public.faq_votar(faq_id uuid) OWNER TO supabase_admin; -- -- Name: fix_all_subscription_mismatches(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.fix_all_subscription_mismatches() RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ declare r record; begin for r in select distinct s.user_id as owner_id from public.subscriptions s where s.status = 'active' and s.user_id is not null loop perform public.rebuild_owner_entitlements(r.owner_id); end loop; end; $$; ALTER FUNCTION public.fix_all_subscription_mismatches() OWNER TO supabase_admin; -- -- Name: fn_agenda_regras_semanais_no_overlap(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.fn_agenda_regras_semanais_no_overlap() RETURNS trigger LANGUAGE plpgsql AS $$ declare v_count int; begin if new.ativo is false then return new; end if; select count(*) into v_count from public.agenda_regras_semanais r where r.owner_id = new.owner_id and r.dia_semana = new.dia_semana and r.ativo is true and (tg_op = 'INSERT' or r.id <> new.id) and (new.hora_inicio < r.hora_fim and new.hora_fim > r.hora_inicio); if v_count > 0 then raise exception 'Janela sobreposta: já existe uma regra ativa nesse intervalo.'; end if; return new; end; $$; ALTER FUNCTION public.fn_agenda_regras_semanais_no_overlap() OWNER TO supabase_admin; -- -- Name: get_my_email(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.get_my_email() RETURNS text LANGUAGE sql SECURITY DEFINER SET search_path TO 'public', 'auth' AS $$ select lower(email) from auth.users where id = auth.uid(); $$; ALTER FUNCTION public.get_my_email() OWNER TO supabase_admin; -- -- Name: guard_account_type_immutable(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_account_type_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF OLD.account_type <> 'free' AND NEW.account_type IS DISTINCT FROM OLD.account_type THEN RAISE EXCEPTION 'account_type é imutável após escolha (atual: "%" para tentativa: "%"). Para mudar de perfil, crie uma nova conta.', OLD.account_type, NEW.account_type USING ERRCODE = 'P0001'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.guard_account_type_immutable() OWNER TO supabase_admin; -- -- Name: guard_locked_commitment(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_locked_commitment() RETURNS trigger LANGUAGE plpgsql AS $$ begin if (old.is_locked = true) then if (tg_op = 'DELETE') then raise exception 'Compromisso bloqueado não pode ser excluído.'; end if; if (tg_op = 'UPDATE') then if (new.active = false) then raise exception 'Compromisso bloqueado não pode ser desativado.'; end if; -- trava renomear (mantém o "Sessão" sempre igual) if (new.name is distinct from old.name) then raise exception 'Compromisso bloqueado não pode ser renomeado.'; end if; -- se quiser travar descrição também, descomente: -- if (new.description is distinct from old.description) then -- raise exception 'Compromisso bloqueado não pode alterar descrição.'; -- end if; end if; end if; return new; end; $$; ALTER FUNCTION public.guard_locked_commitment() OWNER TO supabase_admin; -- -- Name: guard_no_change_core_plan_key(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_no_change_core_plan_key() RETURNS trigger LANGUAGE plpgsql AS $$ begin if old.key in ('clinic_free','clinic_pro','therapist_free','therapist_pro') and new.key is distinct from old.key then raise exception 'Não é permitido alterar a key do plano padrão (%).', old.key using errcode = 'P0001'; end if; return new; end $$; ALTER FUNCTION public.guard_no_change_core_plan_key() OWNER TO supabase_admin; -- -- Name: guard_no_change_plan_target(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_no_change_plan_target() RETURNS trigger LANGUAGE plpgsql AS $$ declare v_bypass text; begin -- bypass controlado por sessão/transação: -- só passa se app.plan_migration_bypass = '1' v_bypass := current_setting('app.plan_migration_bypass', true); if v_bypass = '1' then return new; end if; -- comportamento original (bloqueia qualquer mudança) if new.target is distinct from old.target then raise exception 'Não é permitido alterar target do plano (%) de % para %.', old.key, old.target, new.target using errcode = 'P0001'; end if; return new; end $$; ALTER FUNCTION public.guard_no_change_plan_target() OWNER TO supabase_admin; -- -- Name: guard_no_delete_core_plans(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_no_delete_core_plans() RETURNS trigger LANGUAGE plpgsql AS $$ begin if old.key in ('clinic_free','clinic_pro','therapist_free','therapist_pro') then raise exception 'Plano padrão (%) não pode ser removido.', old.key using errcode = 'P0001'; end if; return old; end $$; ALTER FUNCTION public.guard_no_delete_core_plans() OWNER TO supabase_admin; -- -- Name: guard_patient_cannot_own_tenant(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_patient_cannot_own_tenant() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE v_account_type text; BEGIN SELECT account_type INTO v_account_type FROM public.profiles WHERE id = NEW.user_id; IF v_account_type = 'patient' AND NEW.role IN ('tenant_admin', 'therapist') THEN RAISE EXCEPTION 'Usuário com perfil "patient" não pode ser proprietário ou terapeuta de um tenant. Se tornou profissional? Crie uma nova conta.' USING ERRCODE = 'P0001'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.guard_patient_cannot_own_tenant() OWNER TO supabase_admin; -- -- Name: guard_tenant_kind_immutable(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.guard_tenant_kind_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF NEW.kind IS DISTINCT FROM OLD.kind THEN RAISE EXCEPTION 'tenants.kind é imutável após criação. Tentativa de alterar "%" para "%".', OLD.kind, NEW.kind USING ERRCODE = 'P0001'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.guard_tenant_kind_immutable() OWNER TO supabase_admin; -- -- Name: handle_new_user(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.handle_new_user() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ BEGIN INSERT INTO public.profiles (id, role, account_type) VALUES (NEW.id, 'portal_user', 'free') ON CONFLICT (id) DO NOTHING; RETURN NEW; END; $$; ALTER FUNCTION public.handle_new_user() OWNER TO supabase_admin; -- -- Name: handle_new_user_create_personal_tenant(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.handle_new_user_create_personal_tenant() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER AS $$ BEGIN -- Desabilitado. Tenant criado no onboarding via provision_account_tenant(). RETURN NEW; END; $$; ALTER FUNCTION public.handle_new_user_create_personal_tenant() OWNER TO supabase_admin; -- -- Name: has_feature(uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.owner_feature_entitlements e where e.owner_id = p_owner_id and e.feature_key = p_feature_key ); $$; ALTER FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) OWNER TO supabase_admin; -- -- Name: is_clinic_tenant(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.is_clinic_tenant(_tenant_id uuid) RETURNS boolean LANGUAGE sql STABLE AS $$ SELECT EXISTS ( SELECT 1 FROM public.tenants t WHERE t.id = _tenant_id AND t.kind IN ('clinic', 'clinic_coworking', 'clinic_reception', 'clinic_full') ); $$; ALTER FUNCTION public.is_clinic_tenant(_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: is_saas_admin(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.is_saas_admin() RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.saas_admins sa where sa.user_id = auth.uid() ); $$; ALTER FUNCTION public.is_saas_admin() OWNER TO supabase_admin; -- -- Name: is_tenant_admin(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.is_tenant_admin(p_tenant_id uuid) RETURNS boolean LANGUAGE sql STABLE SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ select exists ( select 1 from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() and tm.role = 'tenant_admin' and tm.status = 'active' ); $$; ALTER FUNCTION public.is_tenant_admin(p_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: is_tenant_member(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.is_tenant_member(_tenant_id uuid) RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.tenant_members m where m.tenant_id = _tenant_id and m.user_id = auth.uid() and m.status = 'active' ); $$; ALTER FUNCTION public.is_tenant_member(_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: is_therapist_tenant(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.is_therapist_tenant(_tenant_id uuid) RETURNS boolean LANGUAGE sql STABLE AS $$ SELECT EXISTS ( SELECT 1 FROM public.tenants t WHERE t.id = _tenant_id AND t.kind = 'therapist' ); $$; ALTER FUNCTION public.is_therapist_tenant(_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: jwt_email(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.jwt_email() RETURNS text LANGUAGE sql STABLE AS $$ select nullif(lower(current_setting('request.jwt.claim.email', true)), ''); $$; ALTER FUNCTION public.jwt_email() OWNER TO supabase_admin; -- -- Name: my_tenants(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.my_tenants() RETURNS TABLE(tenant_id uuid, role text, status text, kind text) LANGUAGE sql STABLE AS $$ select tm.tenant_id, tm.role, tm.status, t.kind from public.tenant_members tm join public.tenants t on t.id = tm.tenant_id where tm.user_id = auth.uid(); $$; ALTER FUNCTION public.my_tenants() OWNER TO supabase_admin; -- -- Name: on_new_user_seed_patient_groups(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.on_new_user_seed_patient_groups() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ BEGIN PERFORM public.seed_default_patient_groups(NEW.id); RETURN NEW; END; $$; ALTER FUNCTION public.on_new_user_seed_patient_groups() OWNER TO supabase_admin; -- -- Name: patients_validate_member_consistency(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.patients_validate_member_consistency() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE v_tenant_responsible uuid; v_tenant_therapist uuid; BEGIN -- responsible_member sempre deve existir e ser do tenant SELECT tenant_id INTO v_tenant_responsible FROM public.tenant_members WHERE id = NEW.responsible_member_id; IF v_tenant_responsible IS NULL THEN RAISE EXCEPTION 'Responsible member not found'; END IF; IF NEW.tenant_id IS NULL THEN RAISE EXCEPTION 'tenant_id is required'; END IF; IF v_tenant_responsible <> NEW.tenant_id THEN RAISE EXCEPTION 'Responsible member must belong to the same tenant'; END IF; -- therapist scope: therapist_member_id deve existir e ser do mesmo tenant IF NEW.patient_scope = 'therapist' THEN IF NEW.therapist_member_id IS NULL THEN RAISE EXCEPTION 'therapist_member_id is required when patient_scope=therapist'; END IF; SELECT tenant_id INTO v_tenant_therapist FROM public.tenant_members WHERE id = NEW.therapist_member_id; IF v_tenant_therapist IS NULL THEN RAISE EXCEPTION 'Therapist member not found'; END IF; IF v_tenant_therapist <> NEW.tenant_id THEN RAISE EXCEPTION 'Therapist member must belong to the same tenant'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.patients_validate_member_consistency() OWNER TO supabase_admin; -- -- Name: patients_validate_responsible_member_tenant(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.patients_validate_responsible_member_tenant() RETURNS trigger LANGUAGE plpgsql AS $$ declare m_tenant uuid; begin select tenant_id into m_tenant from public.tenant_members where id = new.responsible_member_id; if m_tenant is null then raise exception 'Responsible member not found'; end if; if new.tenant_id is null then raise exception 'tenant_id is required'; end if; if m_tenant <> new.tenant_id then raise exception 'Responsible member must belong to the same tenant'; end if; return new; end; $$; ALTER FUNCTION public.patients_validate_responsible_member_tenant() OWNER TO supabase_admin; -- -- Name: prevent_promoting_to_system(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.prevent_promoting_to_system() RETURNS trigger LANGUAGE plpgsql AS $$ begin if new.is_system = true and old.is_system is distinct from true then raise exception 'Não é permitido transformar um grupo comum em grupo do sistema.'; end if; return new; end; $$; ALTER FUNCTION public.prevent_promoting_to_system() OWNER TO supabase_admin; -- -- Name: prevent_saas_membership(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.prevent_saas_membership() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF EXISTS ( SELECT 1 FROM public.profiles WHERE id = NEW.user_id AND role = 'saas_admin' ) THEN RAISE EXCEPTION 'SaaS admin cannot belong to tenant'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.prevent_saas_membership() OWNER TO supabase_admin; -- -- Name: prevent_system_group_changes(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.prevent_system_group_changes() RETURNS trigger LANGUAGE plpgsql AS $$ begin -- Se for grupo do sistema, regras rígidas: if old.is_system = true then -- nunca pode deletar if tg_op = 'DELETE' then raise exception 'Grupos padrão do sistema não podem ser alterados ou excluídos.'; end if; if tg_op = 'UPDATE' then -- permite SOMENTE mudar tenant_id e/ou updated_at -- qualquer mudança de conteúdo permanece proibida if new.nome is distinct from old.nome or new.descricao is distinct from old.descricao or new.cor is distinct from old.cor or new.is_active is distinct from old.is_active or new.is_system is distinct from old.is_system or new.owner_id is distinct from old.owner_id or new.therapist_id is distinct from old.therapist_id or new.created_at is distinct from old.created_at then raise exception 'Grupos padrão do sistema não podem ser alterados ou excluídos.'; end if; -- chegou aqui: só tenant_id/updated_at mudaram -> ok return new; end if; end if; -- não-system: deixa passar if tg_op = 'DELETE' then return old; end if; return new; end; $$; ALTER FUNCTION public.prevent_system_group_changes() OWNER TO supabase_admin; -- -- Name: provision_account_tenant(uuid, text, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text DEFAULT NULL::text) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_tenant_id uuid; v_account_type text; v_name text; BEGIN IF p_kind NOT IN ('therapist', 'clinic_coworking', 'clinic_reception', 'clinic_full') THEN RAISE EXCEPTION 'kind inválido: "%". Use: therapist, clinic_coworking, clinic_reception, clinic_full.', p_kind USING ERRCODE = 'P0001'; END IF; v_account_type := CASE WHEN p_kind = 'therapist' THEN 'therapist' ELSE 'clinic' END; IF EXISTS ( SELECT 1 FROM public.tenant_members tm JOIN public.tenants t ON t.id = tm.tenant_id WHERE tm.user_id = p_user_id AND tm.role = 'tenant_admin' AND tm.status = 'active' AND t.kind = p_kind ) THEN RAISE EXCEPTION 'Usuário já possui um tenant do tipo "%".', p_kind USING ERRCODE = 'P0001'; END IF; v_name := COALESCE( NULLIF(TRIM(p_name), ''), ( SELECT COALESCE(NULLIF(TRIM(pr.full_name), ''), SPLIT_PART(au.email, '@', 1)) FROM public.profiles pr JOIN auth.users au ON au.id = pr.id WHERE pr.id = p_user_id ), 'Conta' ); INSERT INTO public.tenants (name, kind, created_at) VALUES (v_name, p_kind, now()) RETURNING id INTO v_tenant_id; INSERT INTO public.tenant_members (tenant_id, user_id, role, status, created_at) VALUES (v_tenant_id, p_user_id, 'tenant_admin', 'active', now()); UPDATE public.profiles SET account_type = v_account_type WHERE id = p_user_id; PERFORM public.seed_determined_commitments(v_tenant_id); RETURN v_tenant_id; END; $$; ALTER FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) OWNER TO supabase_admin; -- -- Name: FUNCTION provision_account_tenant(p_user_id uuid, p_kind text, p_name text); Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) IS 'Cria o tenant do tipo correto e atualiza account_type no profile. Chamar no onboarding após escolha/pagamento de plano therapist ou clinic. p_kind: therapist | clinic_coworking | clinic_reception | clinic_full'; -- -- Name: reactivate_subscription(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.reactivate_subscription(p_subscription_id uuid) RETURNS public.subscriptions LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_sub public.subscriptions; v_owner_type text; v_owner_ref uuid; begin select * into v_sub from public.subscriptions where id = p_subscription_id for update; if not found then raise exception 'Subscription não encontrada'; end if; if v_sub.status = 'active' then return v_sub; end if; if v_sub.tenant_id is not null then v_owner_type := 'clinic'; v_owner_ref := v_sub.tenant_id; elsif v_sub.user_id is not null then v_owner_type := 'therapist'; v_owner_ref := v_sub.user_id; else v_owner_type := null; v_owner_ref := null; end if; update public.subscriptions set status = 'active', cancel_at_period_end = false, updated_at = now() where id = p_subscription_id returning * into v_sub; insert into public.subscription_events( subscription_id, owner_id, owner_type, owner_ref, event_type, old_plan_id, new_plan_id, created_by, reason, source, metadata ) values ( v_sub.id, v_owner_ref, v_owner_type, v_owner_ref, 'reactivated', v_sub.plan_id, v_sub.plan_id, auth.uid(), 'Reativação manual via admin', 'admin_panel', jsonb_build_object('previous_status', 'canceled') ); if v_owner_ref is not null then insert into public.entitlements_invalidation(owner_id, changed_at) values (v_owner_ref, now()) on conflict (owner_id) do update set changed_at = excluded.changed_at; end if; return v_sub; end; $$; ALTER FUNCTION public.reactivate_subscription(p_subscription_id uuid) OWNER TO supabase_admin; -- -- Name: rebuild_owner_entitlements(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_plan_id uuid; begin -- Plano ativo do owner (owner = subscriptions.user_id) select s.plan_id into v_plan_id from public.subscriptions s where s.user_id = p_owner_id and s.status = 'active' order by s.created_at desc limit 1; -- Sempre zera entitlements do owner (rebuild) delete from public.owner_feature_entitlements e where e.owner_id = p_owner_id; -- Se não tem assinatura ativa, acabou if v_plan_id is null then return; end if; -- Recria entitlements esperados pelo plano insert into public.owner_feature_entitlements (owner_id, feature_key, sources, limits_list) select p_owner_id as owner_id, f.key as feature_key, array['plan'::text] as sources, '{}'::jsonb as limits_list from public.plan_features pf join public.features f on f.id = pf.feature_id where pf.plan_id = v_plan_id; end; $$; ALTER FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) OWNER TO supabase_admin; -- -- Name: revoke_support_session(text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.revoke_support_session(p_token text) RETURNS boolean LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_admin_id uuid; v_role text; BEGIN v_admin_id := auth.uid(); IF v_admin_id IS NULL THEN RAISE EXCEPTION 'Não autenticado.' USING ERRCODE = 'P0001'; END IF; SELECT role INTO v_role FROM public.profiles WHERE id = v_admin_id; IF v_role <> 'saas_admin' THEN RAISE EXCEPTION 'Acesso negado.' USING ERRCODE = 'P0002'; END IF; DELETE FROM public.support_sessions WHERE token = p_token AND admin_id = v_admin_id; RETURN FOUND; END; $$; ALTER FUNCTION public.revoke_support_session(p_token text) OWNER TO supabase_admin; -- -- Name: rotate_patient_invite_token(text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.rotate_patient_invite_token(p_new_token text) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ declare v_uid uuid; v_id uuid; begin -- pega o usuário logado v_uid := auth.uid(); if v_uid is null then raise exception 'Usuário não autenticado'; end if; -- desativa tokens antigos ativos do usuário update public.patient_invites set active = false where owner_id = v_uid and active = true; -- cria novo token insert into public.patient_invites (owner_id, token, active) values (v_uid, p_new_token, true) returning id into v_id; return v_id; end; $$; ALTER FUNCTION public.rotate_patient_invite_token(p_new_token text) OWNER TO supabase_admin; -- -- Name: saas_votar_doc(uuid, boolean); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) RETURNS jsonb LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_uid uuid := auth.uid(); v_voto_antigo boolean; begin if v_uid is null then raise exception 'Não autenticado'; end if; -- Verifica se já votou select util into v_voto_antigo from public.saas_doc_votos where doc_id = p_doc_id and user_id = v_uid; if found then -- Já votou igual → cancela o voto (toggle) if v_voto_antigo = p_util then delete from public.saas_doc_votos where doc_id = p_doc_id and user_id = v_uid; update public.saas_docs set votos_util = greatest(0, votos_util - (case when p_util then 1 else 0 end)), votos_nao_util = greatest(0, votos_nao_util - (case when not p_util then 1 else 0 end)), updated_at = now() where id = p_doc_id; return jsonb_build_object('acao', 'removido', 'util', null); else -- Mudou de voto update public.saas_doc_votos set util = p_util, updated_at = now() where doc_id = p_doc_id and user_id = v_uid; update public.saas_docs set votos_util = greatest(0, votos_util + (case when p_util then 1 else -1 end)), votos_nao_util = greatest(0, votos_nao_util + (case when not p_util then 1 else -1 end)), updated_at = now() where id = p_doc_id; return jsonb_build_object('acao', 'atualizado', 'util', p_util); end if; else -- Primeiro voto insert into public.saas_doc_votos (doc_id, user_id, util) values (p_doc_id, v_uid, p_util); update public.saas_docs set votos_util = votos_util + (case when p_util then 1 else 0 end), votos_nao_util = votos_nao_util + (case when not p_util then 1 else 0 end), updated_at = now() where id = p_doc_id; return jsonb_build_object('acao', 'registrado', 'util', p_util); end if; end; $$; ALTER FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) OWNER TO supabase_admin; -- -- Name: seed_determined_commitments(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.seed_determined_commitments(p_tenant_id uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_id uuid; begin -- Sessão (locked + sempre ativa) if not exists ( select 1 from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'session' ) then insert into public.determined_commitments (tenant_id, is_native, native_key, is_locked, active, name, description) values (p_tenant_id, true, 'session', true, true, 'Sessão', 'Sessão com paciente'); end if; -- Leitura if not exists ( select 1 from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'reading' ) then insert into public.determined_commitments (tenant_id, is_native, native_key, is_locked, active, name, description) values (p_tenant_id, true, 'reading', false, true, 'Leitura', 'Praticar leitura'); end if; -- Supervisão if not exists ( select 1 from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'supervision' ) then insert into public.determined_commitments (tenant_id, is_native, native_key, is_locked, active, name, description) values (p_tenant_id, true, 'supervision', false, true, 'Supervisão', 'Supervisão'); end if; -- Aula ✅ (corrigido) if not exists ( select 1 from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'class' ) then insert into public.determined_commitments (tenant_id, is_native, native_key, is_locked, active, name, description) values (p_tenant_id, true, 'class', false, false, 'Aula', 'Dar aula'); end if; -- Análise pessoal if not exists ( select 1 from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'analysis' ) then insert into public.determined_commitments (tenant_id, is_native, native_key, is_locked, active, name, description) values (p_tenant_id, true, 'analysis', false, true, 'Análise Pessoal', 'Minha análise pessoal'); end if; -- ------------------------------------------------------- -- Campos padrão (idempotentes por (commitment_id, key)) -- ------------------------------------------------------- -- Leitura select id into v_id from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'reading' limit 1; if v_id is not null then if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'book') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'book', 'Livro', 'text', false, 10); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'author') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'author', 'Autor', 'text', false, 20); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'notes') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'notes', 'Observação', 'textarea', false, 30); end if; end if; -- Supervisão select id into v_id from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'supervision' limit 1; if v_id is not null then if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'supervisor') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'supervisor', 'Supervisor', 'text', false, 10); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'topic') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'topic', 'Assunto', 'text', false, 20); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'notes') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'notes', 'Observação', 'textarea', false, 30); end if; end if; -- Aula select id into v_id from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'class' limit 1; if v_id is not null then if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'theme') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'theme', 'Tema', 'text', false, 10); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'group') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'group', 'Turma', 'text', false, 20); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'notes') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'notes', 'Observação', 'textarea', false, 30); end if; end if; -- Análise select id into v_id from public.determined_commitments where tenant_id = p_tenant_id and is_native = true and native_key = 'analysis' limit 1; if v_id is not null then if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'analyst') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'analyst', 'Analista', 'text', false, 10); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'focus') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'focus', 'Foco', 'text', false, 20); end if; if not exists (select 1 from public.determined_commitment_fields where commitment_id = v_id and key = 'notes') then insert into public.determined_commitment_fields (tenant_id, commitment_id, key, label, field_type, required, sort_order) values (p_tenant_id, v_id, 'notes', 'Observação', 'textarea', false, 30); end if; end if; end; $$; ALTER FUNCTION public.seed_determined_commitments(p_tenant_id uuid) OWNER TO supabase_admin; -- -- Name: set_insurance_plans_updated_at(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_insurance_plans_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION public.set_insurance_plans_updated_at() OWNER TO supabase_admin; -- -- Name: set_owner_id(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_owner_id() RETURNS trigger LANGUAGE plpgsql AS $$ begin if new.owner_id is null then new.owner_id := auth.uid(); end if; return new; end; $$; ALTER FUNCTION public.set_owner_id() OWNER TO supabase_admin; -- -- Name: set_services_updated_at(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_services_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION public.set_services_updated_at() OWNER TO supabase_admin; -- -- Name: set_tenant_feature_exception(uuid, text, boolean, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text DEFAULT NULL::text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ begin -- ✅ Só owner ou admin do tenant podem alterar features if not exists ( select 1 from public.tenant_members where tenant_id = p_tenant_id and user_id = auth.uid() and role in ('owner', 'admin') and status = 'active' ) then raise exception 'Acesso negado: apenas owner/admin pode alterar features do tenant.'; end if; insert into public.tenant_features (tenant_id, feature_key, enabled) values (p_tenant_id, p_feature_key, p_enabled) on conflict (tenant_id, feature_key) do update set enabled = excluded.enabled; insert into public.tenant_feature_exceptions_log ( tenant_id, feature_key, enabled, reason, created_by ) values ( p_tenant_id, p_feature_key, p_enabled, p_reason, auth.uid() ); end; $$; ALTER FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text) OWNER TO supabase_admin; -- -- Name: set_updated_at(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ begin new.updated_at = now(); return new; end; $$; ALTER FUNCTION public.set_updated_at() OWNER TO supabase_admin; -- -- Name: set_updated_at_recurrence(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.set_updated_at_recurrence() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION public.set_updated_at_recurrence() OWNER TO supabase_admin; -- -- Name: split_recurrence_at(uuid, date); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_old public.recurrence_rules; v_new_id uuid; BEGIN -- busca a regra original SELECT * INTO v_old FROM public.recurrence_rules WHERE id = p_recurrence_id; IF NOT FOUND THEN RAISE EXCEPTION 'recurrence_rule % não encontrada', p_recurrence_id; END IF; -- encerra a regra antiga na data anterior UPDATE public.recurrence_rules SET end_date = p_from_date - INTERVAL '1 day', open_ended = false, updated_at = now() WHERE id = p_recurrence_id; -- cria nova regra a partir de p_from_date INSERT INTO public.recurrence_rules ( tenant_id, owner_id, therapist_id, patient_id, determined_commitment_id, type, interval, weekdays, start_time, end_time, timezone, duration_min, start_date, end_date, max_occurrences, open_ended, modalidade, titulo_custom, observacoes, extra_fields, status ) SELECT tenant_id, owner_id, therapist_id, patient_id, determined_commitment_id, type, interval, weekdays, start_time, end_time, timezone, duration_min, p_from_date, v_old.end_date, v_old.max_occurrences, v_old.open_ended, modalidade, titulo_custom, observacoes, extra_fields, status FROM public.recurrence_rules WHERE id = p_recurrence_id RETURNING id INTO v_new_id; RETURN v_new_id; END; $$; ALTER FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) OWNER TO supabase_admin; -- -- Name: subscription_intents_view_insert(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.subscription_intents_view_insert() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_target text; v_plan_id uuid; begin select p.id, p.target into v_plan_id, v_target from public.plans p where p.key = new.plan_key; if v_plan_id is null then raise exception 'Plano inválido: plan_key=%', new.plan_key; end if; if lower(v_target) = 'clinic' then if new.tenant_id is null then raise exception 'Intenção clinic exige tenant_id.'; end if; insert into public.subscription_intents_tenant ( id, tenant_id, created_by_user_id, email, plan_id, plan_key, interval, amount_cents, currency, status, source, notes, created_at, paid_at ) values ( coalesce(new.id, gen_random_uuid()), new.tenant_id, new.created_by_user_id, new.email, v_plan_id, new.plan_key, coalesce(new.interval,'month'), new.amount_cents, coalesce(new.currency,'BRL'), coalesce(new.status,'pending'), coalesce(new.source,'manual'), new.notes, coalesce(new.created_at, now()), new.paid_at ); new.plan_target := 'clinic'; return new; end if; -- therapist ou supervisor → tabela personal if lower(v_target) in ('therapist', 'supervisor') then insert into public.subscription_intents_personal ( id, user_id, created_by_user_id, email, plan_id, plan_key, interval, amount_cents, currency, status, source, notes, created_at, paid_at ) values ( coalesce(new.id, gen_random_uuid()), new.user_id, new.created_by_user_id, new.email, v_plan_id, new.plan_key, coalesce(new.interval,'month'), new.amount_cents, coalesce(new.currency,'BRL'), coalesce(new.status,'pending'), coalesce(new.source,'manual'), new.notes, coalesce(new.created_at, now()), new.paid_at ); new.plan_target := lower(v_target); -- 'therapist' ou 'supervisor' return new; end if; raise exception 'Target de plano não suportado: %', v_target; end; $$; ALTER FUNCTION public.subscription_intents_view_insert() OWNER TO supabase_admin; -- -- Name: subscriptions_validate_scope(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.subscriptions_validate_scope() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE v_target text; BEGIN SELECT lower(p.target) INTO v_target FROM public.plans p WHERE p.id = NEW.plan_id; IF v_target IS NULL THEN RAISE EXCEPTION 'Plano inválido (target nulo).'; END IF; IF v_target = 'clinic' THEN IF NEW.tenant_id IS NULL THEN RAISE EXCEPTION 'Assinatura clinic exige tenant_id.'; END IF; IF NEW.user_id IS NOT NULL THEN RAISE EXCEPTION 'Assinatura clinic não pode ter user_id (XOR).'; END IF; ELSIF v_target IN ('therapist', 'supervisor') THEN -- supervisor é pessoal como therapist IF NEW.tenant_id IS NOT NULL THEN RAISE EXCEPTION 'Assinatura % não deve ter tenant_id.', v_target; END IF; IF NEW.user_id IS NULL THEN RAISE EXCEPTION 'Assinatura % exige user_id.', v_target; END IF; ELSIF v_target = 'patient' THEN IF NEW.tenant_id IS NOT NULL THEN RAISE EXCEPTION 'Assinatura patient não deve ter tenant_id.'; END IF; IF NEW.user_id IS NULL THEN RAISE EXCEPTION 'Assinatura patient exige user_id.'; END IF; ELSE RAISE EXCEPTION 'Target de plano inválido: %', v_target; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.subscriptions_validate_scope() OWNER TO supabase_admin; -- -- Name: sync_busy_mirror_agenda_eventos(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.sync_busy_mirror_agenda_eventos() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ declare clinic_tenant uuid; is_personal boolean; should_mirror boolean; begin -- Anti-recursão: espelho não espelha if (tg_op <> 'DELETE') then if new.mirror_of_event_id is not null then return new; end if; else if old.mirror_of_event_id is not null then return old; end if; end if; -- Define se é pessoal e se deve espelhar if (tg_op = 'DELETE') then is_personal := (old.tenant_id = old.owner_id); should_mirror := (old.visibility_scope in ('busy_only','private')); else is_personal := (new.tenant_id = new.owner_id); should_mirror := (new.visibility_scope in ('busy_only','private')); end if; -- Se não é pessoal, não faz nada if not is_personal then if (tg_op = 'DELETE') then return old; end if; return new; end if; -- DELETE: remove espelhos existentes if (tg_op = 'DELETE') then delete from public.agenda_eventos e where e.mirror_of_event_id = old.id and e.mirror_source = 'personal_busy_mirror'; return old; end if; -- INSERT/UPDATE: -- Se não deve espelhar, remove espelhos e sai if not should_mirror then delete from public.agenda_eventos e where e.mirror_of_event_id = new.id and e.mirror_source = 'personal_busy_mirror'; return new; end if; -- Para cada clínica onde o usuário é therapist active, cria/atualiza o "Ocupado" for clinic_tenant in select tm.tenant_id from public.tenant_members tm where tm.user_id = new.owner_id and tm.role = 'therapist' and tm.status = 'active' and tm.tenant_id <> new.owner_id loop insert into public.agenda_eventos ( tenant_id, owner_id, terapeuta_id, paciente_id, tipo, status, titulo, observacoes, inicio_em, fim_em, mirror_of_event_id, mirror_source, visibility_scope, created_at, updated_at ) values ( clinic_tenant, new.owner_id, new.owner_id, null, 'bloqueio'::public.tipo_evento_agenda, 'agendado'::public.status_evento_agenda, 'Ocupado', null, new.inicio_em, new.fim_em, new.id, 'personal_busy_mirror', 'public', now(), now() ) on conflict (tenant_id, mirror_of_event_id) where mirror_of_event_id is not null do update set owner_id = excluded.owner_id, terapeuta_id = excluded.terapeuta_id, tipo = excluded.tipo, status = excluded.status, titulo = excluded.titulo, observacoes = excluded.observacoes, inicio_em = excluded.inicio_em, fim_em = excluded.fim_em, updated_at = now(); end loop; -- Limpa espelhos de clínicas onde o vínculo therapist active não existe mais delete from public.agenda_eventos e where e.mirror_of_event_id = new.id and e.mirror_source = 'personal_busy_mirror' and not exists ( select 1 from public.tenant_members tm where tm.user_id = new.owner_id and tm.role = 'therapist' and tm.status = 'active' and tm.tenant_id = e.tenant_id ); return new; end; $$; ALTER FUNCTION public.sync_busy_mirror_agenda_eventos() OWNER TO supabase_admin; -- -- Name: tenant_accept_invite(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_accept_invite(p_token uuid) RETURNS jsonb LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public', 'auth' AS $$ declare v_uid uuid; v_email text; v_invite public.tenant_invites%rowtype; begin -- 1) precisa estar autenticado v_uid := auth.uid(); if v_uid is null then raise exception 'not_authenticated' using errcode = 'P0001'; end if; -- 2) pega email real do usuário logado sem depender do JWT claim select u.email into v_email from auth.users u where u.id = v_uid; if v_email is null or length(trim(v_email)) = 0 then raise exception 'missing_user_email' using errcode = 'P0001'; end if; -- 3) carrega o invite e trava linha (evita 2 aceites concorrentes) select * into v_invite from public.tenant_invites i where i.token = p_token for update; if not found then raise exception 'invite_not_found' using errcode = 'P0001'; end if; -- 4) validações de estado if v_invite.revoked_at is not null then raise exception 'invite_revoked' using errcode = 'P0001'; end if; if v_invite.accepted_at is not null then raise exception 'invite_already_accepted' using errcode = 'P0001'; end if; if v_invite.expires_at is not null and v_invite.expires_at <= now() then raise exception 'invite_expired' using errcode = 'P0001'; end if; -- 5) valida email (case-insensitive) if lower(trim(v_invite.email)) <> lower(trim(v_email)) then raise exception 'email_mismatch' using errcode = 'P0001'; end if; -- 6) consome o invite update public.tenant_invites set accepted_at = now(), accepted_by = v_uid where id = v_invite.id; -- 7) cria ou reativa o membership insert into public.tenant_members (tenant_id, user_id, role, status, created_at) values (v_invite.tenant_id, v_uid, v_invite.role, 'active', now()) on conflict (tenant_id, user_id) do update set role = excluded.role, status = 'active'; -- 8) retorno útil pro front (você já tenta ler tenant_id no AcceptInvitePage) return jsonb_build_object( 'ok', true, 'tenant_id', v_invite.tenant_id, 'role', v_invite.role ); end; $$; ALTER FUNCTION public.tenant_accept_invite(p_token uuid) OWNER TO supabase_admin; -- -- Name: tenant_members; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenant_members ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, user_id uuid NOT NULL, role text NOT NULL, status text DEFAULT 'active'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.tenant_members OWNER TO supabase_admin; -- -- Name: tenant_add_member_by_email(uuid, text, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text DEFAULT 'therapist'::text) RETURNS public.tenant_members LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public', 'auth' AS $$ declare v_target_uid uuid; v_member public.tenant_members%rowtype; v_is_admin boolean; v_email text; begin if p_tenant_id is null then raise exception 'tenant_id é obrigatório'; end if; v_email := lower(trim(coalesce(p_email, ''))); if v_email = '' then raise exception 'email é obrigatório'; end if; -- valida role permitida if p_role not in ('tenant_admin','therapist','secretary','patient') then raise exception 'role inválida: %', p_role; end if; -- apenas admin do tenant (role real no banco) select exists ( select 1 from public.tenant_members tm where tm.tenant_id = p_tenant_id and tm.user_id = auth.uid() and tm.role = 'tenant_admin' and coalesce(tm.status,'active') = 'active' ) into v_is_admin; if not v_is_admin then raise exception 'sem permissão: apenas admin da clínica pode adicionar membros'; end if; -- acha usuário pelo e-mail no Supabase Auth select u.id into v_target_uid from auth.users u where lower(u.email) = v_email limit 1; if v_target_uid is null then raise exception 'nenhum usuário encontrado com este e-mail'; end if; -- cria ou reativa membro insert into public.tenant_members (tenant_id, user_id, role, status) values (p_tenant_id, v_target_uid, p_role, 'active') on conflict (tenant_id, user_id) do update set role = excluded.role, status = 'active' returning * into v_member; return v_member; end; $$; ALTER FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text) OWNER TO supabase_admin; -- -- Name: tenant_feature_allowed(uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.v_tenant_entitlements v where v.tenant_id = p_tenant_id and v.feature_key = p_feature_key and coalesce(v.allowed, false) = true ); $$; ALTER FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) OWNER TO supabase_admin; -- -- Name: tenant_feature_enabled(uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) RETURNS boolean LANGUAGE sql STABLE AS $$ select coalesce( (select tf.enabled from public.tenant_features tf where tf.tenant_id = p_tenant_id and tf.feature_key = p_feature_key), false ); $$; ALTER FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) OWNER TO supabase_admin; -- -- Name: tenant_features_guard_with_plan(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_features_guard_with_plan() RETURNS trigger LANGUAGE plpgsql AS $$ declare v_allowed boolean; begin -- só valida quando está habilitando if new.enabled is distinct from true then return new; end if; -- permitido pelo plano do tenant? select exists ( select 1 from public.v_tenant_entitlements_full v where v.tenant_id = new.tenant_id and v.feature_key = new.feature_key and v.allowed = true ) into v_allowed; if not v_allowed then raise exception 'Feature % não permitida pelo plano atual do tenant %.', new.feature_key, new.tenant_id using errcode = 'P0001'; end if; return new; end; $$; ALTER FUNCTION public.tenant_features_guard_with_plan() OWNER TO supabase_admin; -- -- Name: tenant_has_feature(uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.v_tenant_entitlements e where e.tenant_id = _tenant_id and e.feature_key = _feature and e.allowed = true ) or exists ( select 1 from public.tenant_features tf where tf.tenant_id = _tenant_id and tf.feature_key = _feature and tf.enabled = true ); $$; ALTER FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) OWNER TO supabase_admin; -- -- Name: tenant_invite_member_by_email(uuid, text, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) RETURNS uuid LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public', 'auth' AS $$ declare v_email text; v_my_email text; v_token uuid; v_updated int; begin -- validações básicas if p_tenant_id is null then raise exception 'tenant_id inválido' using errcode = 'P0001'; end if; v_email := lower(trim(coalesce(p_email, ''))); if v_email = '' then raise exception 'Informe um email' using errcode = 'P0001'; end if; -- role permitido (ajuste se quiser) if p_role is null or p_role not in ('therapist', 'secretary') then raise exception 'Role inválido (use therapist/secretary)' using errcode = 'P0001'; end if; -- ✅ bloqueio: auto-convite v_my_email := public.get_my_email(); if v_my_email is not null and v_email = v_my_email then raise exception 'Você não pode convidar o seu próprio email.' using errcode = 'P0001'; end if; -- ✅ bloqueio: já é membro ativo do tenant if exists ( select 1 from tenant_members tm join auth.users au on au.id = tm.user_id where tm.tenant_id = p_tenant_id and tm.status = 'active' and lower(au.email) = v_email ) then raise exception 'Este email já está vinculado a esta clínica.' using errcode = 'P0001'; end if; -- ✅ permissão: só admin do tenant pode convidar if not exists ( select 1 from tenant_members me where me.tenant_id = p_tenant_id and me.user_id = auth.uid() and me.status = 'active' and me.role in ('tenant_admin','clinic_admin') ) then raise exception 'Sem permissão para convidar membros.' using errcode = 'P0001'; end if; -- Gera token (reenvio simples / regeneração) v_token := gen_random_uuid(); -- 1) tenta "regerar" um convite pendente existente (mesmo email) update tenant_invites set token = v_token, role = p_role, created_at = now(), expires_at = now() + interval '7 days', accepted_at = null, revoked_at = null where tenant_id = p_tenant_id and lower(email) = v_email and accepted_at is null and revoked_at is null; get diagnostics v_updated = row_count; -- 2) se não atualizou nada, cria convite novo if v_updated = 0 then insert into tenant_invites (tenant_id, email, role, token, created_at, expires_at) values (p_tenant_id, v_email, p_role, v_token, now(), now() + interval '7 days'); end if; return v_token; end; $$; ALTER FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) OWNER TO supabase_admin; -- -- Name: tenant_reactivate_member(uuid, uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ begin if auth.uid() is null then raise exception 'not_authenticated'; end if; if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; update public.tenant_members set status = 'active' where tenant_id = p_tenant_id and user_id = p_member_user_id; if not found then raise exception 'membership_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) OWNER TO supabase_admin; -- -- Name: tenant_remove_member(uuid, uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ declare v_role text; begin if auth.uid() is null then raise exception 'not_authenticated'; end if; if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; if p_member_user_id = auth.uid() then raise exception 'cannot_remove_self'; end if; -- pega role atual do membro (se não existir, erro) select role into v_role from public.tenant_members where tenant_id = p_tenant_id and user_id = p_member_user_id; if v_role is null then raise exception 'membership_not_found'; end if; -- trava: se for therapist, não pode remover com eventos futuros if v_role = 'therapist' then if exists ( select 1 from public.agenda_eventos e where e.owner_id = p_tenant_id and e.terapeuta_id = p_member_user_id and e.inicio_em >= now() and e.status::text not in ('cancelado','cancelled','canceled') limit 1 ) then raise exception 'cannot_remove_therapist_with_future_events'; end if; end if; update public.tenant_members set status = 'inactive' where tenant_id = p_tenant_id and user_id = p_member_user_id; if not found then raise exception 'membership_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) OWNER TO supabase_admin; -- -- Name: tenant_remove_member_soft(uuid, uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ begin if auth.uid() is null then raise exception 'not_authenticated'; end if; if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; if p_member_user_id = auth.uid() then raise exception 'cannot_remove_self'; end if; update public.tenant_members set status = 'inactive' where tenant_id = p_tenant_id and user_id = p_member_user_id; if not found then raise exception 'membership_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) OWNER TO supabase_admin; -- -- Name: tenant_revoke_invite(uuid, text, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ declare v_email text; begin if auth.uid() is null then raise exception 'not_authenticated'; end if; if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; v_email := lower(trim(p_email)); update public.tenant_invites set revoked_at = now(), revoked_by = auth.uid() where tenant_id = p_tenant_id and lower(email) = v_email and role = p_role and accepted_at is null and revoked_at is null; if not found then raise exception 'invite_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) OWNER TO supabase_admin; -- -- Name: tenant_set_member_status(uuid, uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ begin if auth.uid() is null then raise exception 'not_authenticated'; end if; -- valida status (adapte aos seus valores reais) if p_new_status not in ('active','inactive','suspended','invited') then raise exception 'invalid_status: %', p_new_status; end if; if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; -- evita desativar a si mesmo (opcional) if p_member_user_id = auth.uid() and p_new_status <> 'active' then raise exception 'cannot_disable_self'; end if; update public.tenant_members set status = p_new_status where tenant_id = p_tenant_id and user_id = p_member_user_id; if not found then raise exception 'membership_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) OWNER TO supabase_admin; -- -- Name: tenant_update_member_role(uuid, uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' SET row_security TO 'off' AS $$ begin -- exige auth if auth.uid() is null then raise exception 'not_authenticated'; end if; -- valida role if p_new_role not in ('tenant_admin','therapist','secretary','patient') then raise exception 'invalid_role: %', p_new_role; end if; -- somente tenant_admin ativo pode alterar role if not public.is_tenant_admin(p_tenant_id) then raise exception 'not_allowed'; end if; -- evita o admin remover o próprio admin sem querer (opcional mas recomendado) if p_member_user_id = auth.uid() and p_new_role <> 'tenant_admin' then raise exception 'cannot_demote_self'; end if; update public.tenant_members set role = p_new_role where tenant_id = p_tenant_id and user_id = p_member_user_id; if not found then raise exception 'membership_not_found'; end if; end; $$; ALTER FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) OWNER TO supabase_admin; -- -- Name: toggle_plan(uuid); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.toggle_plan(owner uuid) RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $$ declare current_key text; new_key text; begin select p.key into current_key from subscriptions s join plans p on p.id = s.plan_id where s.owner_id = owner and s.status = 'active'; new_key := case when current_key = 'pro' then 'free' else 'pro' end; update subscriptions s set plan_id = p.id from plans p where p.key = new_key and s.owner_id = owner and s.status = 'active'; end; $$; ALTER FUNCTION public.toggle_plan(owner uuid) OWNER TO supabase_admin; -- -- Name: transition_subscription(uuid, text, text, jsonb); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text DEFAULT NULL::text, p_metadata jsonb DEFAULT NULL::jsonb) RETURNS public.subscriptions LANGUAGE plpgsql SECURITY DEFINER AS $$ declare v_sub public.subscriptions; v_uid uuid; v_is_allowed boolean := false; begin v_uid := auth.uid(); select * into v_sub from public.subscriptions where id = p_subscription_id; if not found then raise exception 'Assinatura não encontrada'; end if; -- ===================================================== -- 🔐 BLOCO DE AUTORIZAÇÃO -- ===================================================== -- 1) SaaS admin pode tudo if is_saas_admin() then v_is_allowed := true; end if; -- 2) Assinatura pessoal (therapist) if not v_is_allowed and v_sub.tenant_id is null and v_sub.user_id = v_uid then v_is_allowed := true; end if; -- 3) Assinatura de clinic (tenant) if not v_is_allowed and v_sub.tenant_id is not null then if exists ( select 1 from public.tenant_members tm where tm.tenant_id = v_sub.tenant_id and tm.user_id = v_uid and tm.status = 'active' and tm.role = 'tenant_admin' ) then v_is_allowed := true; end if; end if; if not v_is_allowed then raise exception 'Sem permissão para transicionar esta assinatura'; end if; -- ===================================================== -- 🧠 TRANSIÇÃO -- ===================================================== update public.subscriptions set status = p_to_status, updated_at = now(), cancelled_at = case when p_to_status = 'cancelled' then now() else cancelled_at end, suspended_at = case when p_to_status = 'suspended' then now() else suspended_at end, past_due_since = case when p_to_status = 'past_due' then now() else past_due_since end, expired_at = case when p_to_status = 'expired' then now() else expired_at end, activated_at = case when p_to_status = 'active' then now() else activated_at end where id = p_subscription_id returning * into v_sub; -- ===================================================== -- 🧾 EVENT LOG -- ===================================================== insert into public.subscription_events ( subscription_id, owner_id, event_type, created_at, created_by, source, reason, metadata, owner_type, owner_ref ) values ( v_sub.id, coalesce(v_sub.tenant_id, v_sub.user_id), 'status_changed', now(), v_uid, 'manual_transition', p_reason, p_metadata, case when v_sub.tenant_id is not null then 'tenant' else 'personal' end, coalesce(v_sub.tenant_id, v_sub.user_id) ); return v_sub; end; $$; ALTER FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb) OWNER TO supabase_admin; -- -- Name: update_payment_settings_updated_at(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.update_payment_settings_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION public.update_payment_settings_updated_at() OWNER TO supabase_admin; -- -- Name: update_professional_pricing_updated_at(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.update_professional_pricing_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION public.update_professional_pricing_updated_at() OWNER TO supabase_admin; -- -- Name: user_has_feature(uuid, text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.user_has_feature(_user_id uuid, _feature text) RETURNS boolean LANGUAGE sql STABLE AS $$ select exists ( select 1 from public.v_user_entitlements e where e.user_id = _user_id and e.feature_key = _feature and e.allowed = true ); $$; ALTER FUNCTION public.user_has_feature(_user_id uuid, _feature text) OWNER TO supabase_admin; -- -- Name: validate_support_session(text); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.validate_support_session(p_token text) RETURNS json LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'public' AS $$ DECLARE v_session support_sessions; BEGIN IF p_token IS NULL OR length(trim(p_token)) < 32 THEN RETURN json_build_object('valid', false, 'tenant_id', null); END IF; SELECT * INTO v_session FROM public.support_sessions WHERE token = p_token AND expires_at > now() LIMIT 1; IF NOT FOUND THEN RETURN json_build_object('valid', false, 'tenant_id', null); END IF; RETURN json_build_object( 'valid', true, 'tenant_id', v_session.tenant_id ); END; $$; ALTER FUNCTION public.validate_support_session(p_token text) OWNER TO supabase_admin; -- -- Name: whoami(); Type: FUNCTION; Schema: public; Owner: supabase_admin -- CREATE FUNCTION public.whoami() RETURNS TABLE(uid uuid, role text) LANGUAGE sql STABLE AS $$ select auth.uid() as uid, auth.role() as role; $$; ALTER FUNCTION public.whoami() OWNER TO supabase_admin; -- -- Name: apply_rls(jsonb, integer); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer DEFAULT (1024 * 1024)) RETURNS SETOF realtime.wal_rls LANGUAGE plpgsql AS $$ declare -- Regclass of the table e.g. public.notes entity_ regclass = (quote_ident(wal ->> 'schema') || '.' || quote_ident(wal ->> 'table'))::regclass; -- I, U, D, T: insert, update ... action realtime.action = ( case wal ->> 'action' when 'I' then 'INSERT' when 'U' then 'UPDATE' when 'D' then 'DELETE' else 'ERROR' end ); -- Is row level security enabled for the table is_rls_enabled bool = relrowsecurity from pg_class where oid = entity_; subscriptions realtime.subscription[] = array_agg(subs) from realtime.subscription subs where subs.entity = entity_; -- Subscription vars roles regrole[] = array_agg(distinct us.claims_role::text) from unnest(subscriptions) us; working_role regrole; claimed_role regrole; claims jsonb; subscription_id uuid; subscription_has_access bool; visible_to_subscription_ids uuid[] = '{}'; -- structured info for wal's columns columns realtime.wal_column[]; -- previous identity values for update/delete old_columns realtime.wal_column[]; error_record_exceeds_max_size boolean = octet_length(wal::text) > max_record_bytes; -- Primary jsonb output for record output jsonb; begin perform set_config('role', null, true); columns = array_agg( ( x->>'name', x->>'type', x->>'typeoid', realtime.cast( (x->'value') #>> '{}', coalesce( (x->>'typeoid')::regtype, -- null when wal2json version <= 2.4 (x->>'type')::regtype ) ), (pks ->> 'name') is not null, true )::realtime.wal_column ) from jsonb_array_elements(wal -> 'columns') x left join jsonb_array_elements(wal -> 'pk') pks on (x ->> 'name') = (pks ->> 'name'); old_columns = array_agg( ( x->>'name', x->>'type', x->>'typeoid', realtime.cast( (x->'value') #>> '{}', coalesce( (x->>'typeoid')::regtype, -- null when wal2json version <= 2.4 (x->>'type')::regtype ) ), (pks ->> 'name') is not null, true )::realtime.wal_column ) from jsonb_array_elements(wal -> 'identity') x left join jsonb_array_elements(wal -> 'pk') pks on (x ->> 'name') = (pks ->> 'name'); for working_role in select * from unnest(roles) loop -- Update `is_selectable` for columns and old_columns columns = array_agg( ( c.name, c.type_name, c.type_oid, c.value, c.is_pkey, pg_catalog.has_column_privilege(working_role, entity_, c.name, 'SELECT') )::realtime.wal_column ) from unnest(columns) c; old_columns = array_agg( ( c.name, c.type_name, c.type_oid, c.value, c.is_pkey, pg_catalog.has_column_privilege(working_role, entity_, c.name, 'SELECT') )::realtime.wal_column ) from unnest(old_columns) c; if action <> 'DELETE' and count(1) = 0 from unnest(columns) c where c.is_pkey then return next ( jsonb_build_object( 'schema', wal ->> 'schema', 'table', wal ->> 'table', 'type', action ), is_rls_enabled, -- subscriptions is already filtered by entity (select array_agg(s.subscription_id) from unnest(subscriptions) as s where claims_role = working_role), array['Error 400: Bad Request, no primary key'] )::realtime.wal_rls; -- The claims role does not have SELECT permission to the primary key of entity elsif action <> 'DELETE' and sum(c.is_selectable::int) <> count(1) from unnest(columns) c where c.is_pkey then return next ( jsonb_build_object( 'schema', wal ->> 'schema', 'table', wal ->> 'table', 'type', action ), is_rls_enabled, (select array_agg(s.subscription_id) from unnest(subscriptions) as s where claims_role = working_role), array['Error 401: Unauthorized'] )::realtime.wal_rls; else output = jsonb_build_object( 'schema', wal ->> 'schema', 'table', wal ->> 'table', 'type', action, 'commit_timestamp', to_char( ((wal ->> 'timestamp')::timestamptz at time zone 'utc'), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"' ), 'columns', ( select jsonb_agg( jsonb_build_object( 'name', pa.attname, 'type', pt.typname ) order by pa.attnum asc ) from pg_attribute pa join pg_type pt on pa.atttypid = pt.oid where attrelid = entity_ and attnum > 0 and pg_catalog.has_column_privilege(working_role, entity_, pa.attname, 'SELECT') ) ) -- Add "record" key for insert and update || case when action in ('INSERT', 'UPDATE') then jsonb_build_object( 'record', ( select jsonb_object_agg( -- if unchanged toast, get column name and value from old record coalesce((c).name, (oc).name), case when (c).name is null then (oc).value else (c).value end ) from unnest(columns) c full outer join unnest(old_columns) oc on (c).name = (oc).name where coalesce((c).is_selectable, (oc).is_selectable) and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64)) ) ) else '{}'::jsonb end -- Add "old_record" key for update and delete || case when action = 'UPDATE' then jsonb_build_object( 'old_record', ( select jsonb_object_agg((c).name, (c).value) from unnest(old_columns) c where (c).is_selectable and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64)) ) ) when action = 'DELETE' then jsonb_build_object( 'old_record', ( select jsonb_object_agg((c).name, (c).value) from unnest(old_columns) c where (c).is_selectable and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64)) and ( not is_rls_enabled or (c).is_pkey ) -- if RLS enabled, we can't secure deletes so filter to pkey ) ) else '{}'::jsonb end; -- Create the prepared statement if is_rls_enabled and action <> 'DELETE' then if (select 1 from pg_prepared_statements where name = 'walrus_rls_stmt' limit 1) > 0 then deallocate walrus_rls_stmt; end if; execute realtime.build_prepared_statement_sql('walrus_rls_stmt', entity_, columns); end if; visible_to_subscription_ids = '{}'; for subscription_id, claims in ( select subs.subscription_id, subs.claims from unnest(subscriptions) subs where subs.entity = entity_ and subs.claims_role = working_role and ( realtime.is_visible_through_filters(columns, subs.filters) or ( action = 'DELETE' and realtime.is_visible_through_filters(old_columns, subs.filters) ) ) ) loop if not is_rls_enabled or action = 'DELETE' then visible_to_subscription_ids = visible_to_subscription_ids || subscription_id; else -- Check if RLS allows the role to see the record perform -- Trim leading and trailing quotes from working_role because set_config -- doesn't recognize the role as valid if they are included set_config('role', trim(both '"' from working_role::text), true), set_config('request.jwt.claims', claims::text, true); execute 'execute walrus_rls_stmt' into subscription_has_access; if subscription_has_access then visible_to_subscription_ids = visible_to_subscription_ids || subscription_id; end if; end if; end loop; perform set_config('role', null, true); return next ( output, is_rls_enabled, visible_to_subscription_ids, case when error_record_exceeds_max_size then array['Error 413: Payload Too Large'] else '{}' end )::realtime.wal_rls; end if; end loop; perform set_config('role', null, true); end; $$; ALTER FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) OWNER TO supabase_admin; -- -- Name: broadcast_changes(text, text, text, text, text, record, record, text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text DEFAULT 'ROW'::text) RETURNS void LANGUAGE plpgsql AS $$ DECLARE -- Declare a variable to hold the JSONB representation of the row row_data jsonb := '{}'::jsonb; BEGIN IF level = 'STATEMENT' THEN RAISE EXCEPTION 'function can only be triggered for each row, not for each statement'; END IF; -- Check the operation type and handle accordingly IF operation = 'INSERT' OR operation = 'UPDATE' OR operation = 'DELETE' THEN row_data := jsonb_build_object('old_record', OLD, 'record', NEW, 'operation', operation, 'table', table_name, 'schema', table_schema); PERFORM realtime.send (row_data, event_name, topic_name); ELSE RAISE EXCEPTION 'Unexpected operation type: %', operation; END IF; EXCEPTION WHEN OTHERS THEN RAISE EXCEPTION 'Failed to process the row: %', SQLERRM; END; $$; ALTER FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) OWNER TO supabase_admin; -- -- Name: build_prepared_statement_sql(text, regclass, realtime.wal_column[]); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) RETURNS text LANGUAGE sql AS $$ /* Builds a sql string that, if executed, creates a prepared statement to tests retrive a row from *entity* by its primary key columns. Example select realtime.build_prepared_statement_sql('public.notes', '{"id"}'::text[], '{"bigint"}'::text[]) */ select 'prepare ' || prepared_statement_name || ' as select exists( select 1 from ' || entity || ' where ' || string_agg(quote_ident(pkc.name) || '=' || quote_nullable(pkc.value #>> '{}') , ' and ') || ' )' from unnest(columns) pkc where pkc.is_pkey group by entity $$; ALTER FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) OWNER TO supabase_admin; -- -- Name: cast(text, regtype); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime."cast"(val text, type_ regtype) RETURNS jsonb LANGUAGE plpgsql IMMUTABLE AS $$ declare res jsonb; begin execute format('select to_jsonb(%L::'|| type_::text || ')', val) into res; return res; end $$; ALTER FUNCTION realtime."cast"(val text, type_ regtype) OWNER TO supabase_admin; -- -- Name: check_equality_op(realtime.equality_op, regtype, text, text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) RETURNS boolean LANGUAGE plpgsql IMMUTABLE AS $$ /* Casts *val_1* and *val_2* as type *type_* and check the *op* condition for truthiness */ declare op_symbol text = ( case when op = 'eq' then '=' when op = 'neq' then '!=' when op = 'lt' then '<' when op = 'lte' then '<=' when op = 'gt' then '>' when op = 'gte' then '>=' when op = 'in' then '= any' else 'UNKNOWN OP' end ); res boolean; begin execute format( 'select %L::'|| type_::text || ' ' || op_symbol || ' ( %L::' || ( case when op = 'in' then type_::text || '[]' else type_::text end ) || ')', val_1, val_2) into res; return res; end; $$; ALTER FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) OWNER TO supabase_admin; -- -- Name: is_visible_through_filters(realtime.wal_column[], realtime.user_defined_filter[]); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) RETURNS boolean LANGUAGE sql IMMUTABLE AS $_$ /* Should the record be visible (true) or filtered out (false) after *filters* are applied */ select -- Default to allowed when no filters present $2 is null -- no filters. this should not happen because subscriptions has a default or array_length($2, 1) is null -- array length of an empty array is null or bool_and( coalesce( realtime.check_equality_op( op:=f.op, type_:=coalesce( col.type_oid::regtype, -- null when wal2json version <= 2.4 col.type_name::regtype ), -- cast jsonb to text val_1:=col.value #>> '{}', val_2:=f.value ), false -- if null, filter does not match ) ) from unnest(filters) f join unnest(columns) col on f.column_name = col.name; $_$; ALTER FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) OWNER TO supabase_admin; -- -- Name: list_changes(name, name, integer, integer); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) RETURNS SETOF realtime.wal_rls LANGUAGE sql SET log_min_messages TO 'fatal' AS $$ with pub as ( select concat_ws( ',', case when bool_or(pubinsert) then 'insert' else null end, case when bool_or(pubupdate) then 'update' else null end, case when bool_or(pubdelete) then 'delete' else null end ) as w2j_actions, coalesce( string_agg( realtime.quote_wal2json(format('%I.%I', schemaname, tablename)::regclass), ',' ) filter (where ppt.tablename is not null and ppt.tablename not like '% %'), '' ) w2j_add_tables from pg_publication pp left join pg_publication_tables ppt on pp.pubname = ppt.pubname where pp.pubname = publication group by pp.pubname limit 1 ), w2j as ( select x.*, pub.w2j_add_tables from pub, pg_logical_slot_get_changes( slot_name, null, max_changes, 'include-pk', 'true', 'include-transaction', 'false', 'include-timestamp', 'true', 'include-type-oids', 'true', 'format-version', '2', 'actions', pub.w2j_actions, 'add-tables', pub.w2j_add_tables ) x ) select xyz.wal, xyz.is_rls_enabled, xyz.subscription_ids, xyz.errors from w2j, realtime.apply_rls( wal := w2j.data::jsonb, max_record_bytes := max_record_bytes ) xyz(wal, is_rls_enabled, subscription_ids, errors) where w2j.w2j_add_tables <> '' and xyz.subscription_ids[1] is not null $$; ALTER FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) OWNER TO supabase_admin; -- -- Name: quote_wal2json(regclass); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.quote_wal2json(entity regclass) RETURNS text LANGUAGE sql IMMUTABLE STRICT AS $$ select ( select string_agg('' || ch,'') from unnest(string_to_array(nsp.nspname::text, null)) with ordinality x(ch, idx) where not (x.idx = 1 and x.ch = '"') and not ( x.idx = array_length(string_to_array(nsp.nspname::text, null), 1) and x.ch = '"' ) ) || '.' || ( select string_agg('' || ch,'') from unnest(string_to_array(pc.relname::text, null)) with ordinality x(ch, idx) where not (x.idx = 1 and x.ch = '"') and not ( x.idx = array_length(string_to_array(nsp.nspname::text, null), 1) and x.ch = '"' ) ) from pg_class pc join pg_namespace nsp on pc.relnamespace = nsp.oid where pc.oid = entity $$; ALTER FUNCTION realtime.quote_wal2json(entity regclass) OWNER TO supabase_admin; -- -- Name: send(jsonb, text, text, boolean); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean DEFAULT true) RETURNS void LANGUAGE plpgsql AS $$ DECLARE generated_id uuid; final_payload jsonb; BEGIN BEGIN -- Generate a new UUID for the id generated_id := gen_random_uuid(); -- Check if payload has an 'id' key, if not, add the generated UUID IF payload ? 'id' THEN final_payload := payload; ELSE final_payload := jsonb_set(payload, '{id}', to_jsonb(generated_id)); END IF; -- Set the topic configuration EXECUTE format('SET LOCAL realtime.topic TO %L', topic); -- Attempt to insert the message INSERT INTO realtime.messages (id, payload, event, topic, private, extension) VALUES (generated_id, final_payload, event, topic, private, 'broadcast'); EXCEPTION WHEN OTHERS THEN -- Capture and notify the error RAISE WARNING 'ErrorSendingBroadcastMessage: %', SQLERRM; END; END; $$; ALTER FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) OWNER TO supabase_admin; -- -- Name: subscription_check_filters(); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.subscription_check_filters() RETURNS trigger LANGUAGE plpgsql AS $$ /* Validates that the user defined filters for a subscription: - refer to valid columns that the claimed role may access - values are coercable to the correct column type */ declare col_names text[] = coalesce( array_agg(c.column_name order by c.ordinal_position), '{}'::text[] ) from information_schema.columns c where format('%I.%I', c.table_schema, c.table_name)::regclass = new.entity and pg_catalog.has_column_privilege( (new.claims ->> 'role'), format('%I.%I', c.table_schema, c.table_name)::regclass, c.column_name, 'SELECT' ); filter realtime.user_defined_filter; col_type regtype; in_val jsonb; begin for filter in select * from unnest(new.filters) loop -- Filtered column is valid if not filter.column_name = any(col_names) then raise exception 'invalid column for filter %', filter.column_name; end if; -- Type is sanitized and safe for string interpolation col_type = ( select atttypid::regtype from pg_catalog.pg_attribute where attrelid = new.entity and attname = filter.column_name ); if col_type is null then raise exception 'failed to lookup type for column %', filter.column_name; end if; -- Set maximum number of entries for in filter if filter.op = 'in'::realtime.equality_op then in_val = realtime.cast(filter.value, (col_type::text || '[]')::regtype); if coalesce(jsonb_array_length(in_val), 0) > 100 then raise exception 'too many values for `in` filter. Maximum 100'; end if; else -- raises an exception if value is not coercable to type perform realtime.cast(filter.value, col_type); end if; end loop; -- Apply consistent order to filters so the unique constraint on -- (subscription_id, entity, filters) can't be tricked by a different filter order new.filters = coalesce( array_agg(f order by f.column_name, f.op, f.value), '{}' ) from unnest(new.filters) f; return new; end; $$; ALTER FUNCTION realtime.subscription_check_filters() OWNER TO supabase_admin; -- -- Name: to_regrole(text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin -- CREATE FUNCTION realtime.to_regrole(role_name text) RETURNS regrole LANGUAGE sql IMMUTABLE AS $$ select role_name::regrole $$; ALTER FUNCTION realtime.to_regrole(role_name text) OWNER TO supabase_admin; -- -- Name: topic(); Type: FUNCTION; Schema: realtime; Owner: supabase_realtime_admin -- CREATE FUNCTION realtime.topic() RETURNS text LANGUAGE sql STABLE AS $$ select nullif(current_setting('realtime.topic', true), '')::text; $$; ALTER FUNCTION realtime.topic() OWNER TO supabase_realtime_admin; -- -- Name: can_insert_object(text, text, uuid, jsonb); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.can_insert_object(bucketid text, name text, owner uuid, metadata jsonb) RETURNS void LANGUAGE plpgsql AS $$ BEGIN INSERT INTO "storage"."objects" ("bucket_id", "name", "owner", "metadata") VALUES (bucketid, name, owner, metadata); -- hack to rollback the successful insert RAISE sqlstate 'PT200' using message = 'ROLLBACK', detail = 'rollback successful insert'; END $$; ALTER FUNCTION storage.can_insert_object(bucketid text, name text, owner uuid, metadata jsonb) OWNER TO supabase_storage_admin; -- -- Name: enforce_bucket_name_length(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.enforce_bucket_name_length() RETURNS trigger LANGUAGE plpgsql AS $$ begin if length(new.name) > 100 then raise exception 'bucket name "%" is too long (% characters). Max is 100.', new.name, length(new.name); end if; return new; end; $$; ALTER FUNCTION storage.enforce_bucket_name_length() OWNER TO supabase_storage_admin; -- -- Name: extension(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.extension(name text) RETURNS text LANGUAGE plpgsql AS $$ DECLARE _parts text[]; _filename text; BEGIN select string_to_array(name, '/') into _parts; select _parts[array_length(_parts,1)] into _filename; -- @todo return the last part instead of 2 return reverse(split_part(reverse(_filename), '.', 1)); END $$; ALTER FUNCTION storage.extension(name text) OWNER TO supabase_storage_admin; -- -- Name: filename(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.filename(name text) RETURNS text LANGUAGE plpgsql AS $$ DECLARE _parts text[]; BEGIN select string_to_array(name, '/') into _parts; return _parts[array_length(_parts,1)]; END $$; ALTER FUNCTION storage.filename(name text) OWNER TO supabase_storage_admin; -- -- Name: foldername(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.foldername(name text) RETURNS text[] LANGUAGE plpgsql AS $$ DECLARE _parts text[]; BEGIN select string_to_array(name, '/') into _parts; return _parts[1:array_length(_parts,1)-1]; END $$; ALTER FUNCTION storage.foldername(name text) OWNER TO supabase_storage_admin; -- -- Name: get_common_prefix(text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.get_common_prefix(p_key text, p_prefix text, p_delimiter text) RETURNS text LANGUAGE sql IMMUTABLE AS $$ SELECT CASE WHEN position(p_delimiter IN substring(p_key FROM length(p_prefix) + 1)) > 0 THEN left(p_key, length(p_prefix) + position(p_delimiter IN substring(p_key FROM length(p_prefix) + 1))) ELSE NULL END; $$; ALTER FUNCTION storage.get_common_prefix(p_key text, p_prefix text, p_delimiter text) OWNER TO supabase_storage_admin; -- -- Name: get_size_by_bucket(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.get_size_by_bucket() RETURNS TABLE(size bigint, bucket_id text) LANGUAGE plpgsql AS $$ BEGIN return query select sum((metadata->>'size')::int) as size, obj.bucket_id from "storage".objects as obj group by obj.bucket_id; END $$; ALTER FUNCTION storage.get_size_by_bucket() OWNER TO supabase_storage_admin; -- -- Name: list_multipart_uploads_with_delimiter(text, text, text, integer, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.list_multipart_uploads_with_delimiter(bucket_id text, prefix_param text, delimiter_param text, max_keys integer DEFAULT 100, next_key_token text DEFAULT ''::text, next_upload_token text DEFAULT ''::text) RETURNS TABLE(key text, id text, created_at timestamp with time zone) LANGUAGE plpgsql AS $_$ BEGIN RETURN QUERY EXECUTE 'SELECT DISTINCT ON(key COLLATE "C") * from ( SELECT CASE WHEN position($2 IN substring(key from length($1) + 1)) > 0 THEN substring(key from 1 for length($1) + position($2 IN substring(key from length($1) + 1))) ELSE key END AS key, id, created_at FROM storage.s3_multipart_uploads WHERE bucket_id = $5 AND key ILIKE $1 || ''%'' AND CASE WHEN $4 != '''' AND $6 = '''' THEN CASE WHEN position($2 IN substring(key from length($1) + 1)) > 0 THEN substring(key from 1 for length($1) + position($2 IN substring(key from length($1) + 1))) COLLATE "C" > $4 ELSE key COLLATE "C" > $4 END ELSE true END AND CASE WHEN $6 != '''' THEN id COLLATE "C" > $6 ELSE true END ORDER BY key COLLATE "C" ASC, created_at ASC) as e order by key COLLATE "C" LIMIT $3' USING prefix_param, delimiter_param, max_keys, next_key_token, bucket_id, next_upload_token; END; $_$; ALTER FUNCTION storage.list_multipart_uploads_with_delimiter(bucket_id text, prefix_param text, delimiter_param text, max_keys integer, next_key_token text, next_upload_token text) OWNER TO supabase_storage_admin; -- -- Name: list_objects_with_delimiter(text, text, text, integer, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.list_objects_with_delimiter(_bucket_id text, prefix_param text, delimiter_param text, max_keys integer DEFAULT 100, start_after text DEFAULT ''::text, next_token text DEFAULT ''::text, sort_order text DEFAULT 'asc'::text) RETURNS TABLE(name text, id uuid, metadata jsonb, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone) LANGUAGE plpgsql STABLE AS $_$ DECLARE v_peek_name TEXT; v_current RECORD; v_common_prefix TEXT; -- Configuration v_is_asc BOOLEAN; v_prefix TEXT; v_start TEXT; v_upper_bound TEXT; v_file_batch_size INT; -- Seek state v_next_seek TEXT; v_count INT := 0; -- Dynamic SQL for batch query only v_batch_query TEXT; BEGIN -- ======================================================================== -- INITIALIZATION -- ======================================================================== v_is_asc := lower(coalesce(sort_order, 'asc')) = 'asc'; v_prefix := coalesce(prefix_param, ''); v_start := CASE WHEN coalesce(next_token, '') <> '' THEN next_token ELSE coalesce(start_after, '') END; v_file_batch_size := LEAST(GREATEST(max_keys * 2, 100), 1000); -- Calculate upper bound for prefix filtering (bytewise, using COLLATE "C") IF v_prefix = '' THEN v_upper_bound := NULL; ELSIF right(v_prefix, 1) = delimiter_param THEN v_upper_bound := left(v_prefix, -1) || chr(ascii(delimiter_param) + 1); ELSE v_upper_bound := left(v_prefix, -1) || chr(ascii(right(v_prefix, 1)) + 1); END IF; -- Build batch query (dynamic SQL - called infrequently, amortized over many rows) IF v_is_asc THEN IF v_upper_bound IS NOT NULL THEN v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" >= $2 ' || 'AND o.name COLLATE "C" < $3 ORDER BY o.name COLLATE "C" ASC LIMIT $4'; ELSE v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" >= $2 ' || 'ORDER BY o.name COLLATE "C" ASC LIMIT $4'; END IF; ELSE IF v_upper_bound IS NOT NULL THEN v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" < $2 ' || 'AND o.name COLLATE "C" >= $3 ORDER BY o.name COLLATE "C" DESC LIMIT $4'; ELSE v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" < $2 ' || 'ORDER BY o.name COLLATE "C" DESC LIMIT $4'; END IF; END IF; -- ======================================================================== -- SEEK INITIALIZATION: Determine starting position -- ======================================================================== IF v_start = '' THEN IF v_is_asc THEN v_next_seek := v_prefix; ELSE -- DESC without cursor: find the last item in range IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_next_seek FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_prefix AND o.name COLLATE "C" < v_upper_bound ORDER BY o.name COLLATE "C" DESC LIMIT 1; ELSIF v_prefix <> '' THEN SELECT o.name INTO v_next_seek FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_prefix ORDER BY o.name COLLATE "C" DESC LIMIT 1; ELSE SELECT o.name INTO v_next_seek FROM storage.objects o WHERE o.bucket_id = _bucket_id ORDER BY o.name COLLATE "C" DESC LIMIT 1; END IF; IF v_next_seek IS NOT NULL THEN v_next_seek := v_next_seek || delimiter_param; ELSE RETURN; END IF; END IF; ELSE -- Cursor provided: determine if it refers to a folder or leaf IF EXISTS ( SELECT 1 FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" LIKE v_start || delimiter_param || '%' LIMIT 1 ) THEN -- Cursor refers to a folder IF v_is_asc THEN v_next_seek := v_start || chr(ascii(delimiter_param) + 1); ELSE v_next_seek := v_start || delimiter_param; END IF; ELSE -- Cursor refers to a leaf object IF v_is_asc THEN v_next_seek := v_start || delimiter_param; ELSE v_next_seek := v_start; END IF; END IF; END IF; -- ======================================================================== -- MAIN LOOP: Hybrid peek-then-batch algorithm -- Uses STATIC SQL for peek (hot path) and DYNAMIC SQL for batch -- ======================================================================== LOOP EXIT WHEN v_count >= max_keys; -- STEP 1: PEEK using STATIC SQL (plan cached, very fast) IF v_is_asc THEN IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_next_seek AND o.name COLLATE "C" < v_upper_bound ORDER BY o.name COLLATE "C" ASC LIMIT 1; ELSE SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_next_seek ORDER BY o.name COLLATE "C" ASC LIMIT 1; END IF; ELSE IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek AND o.name COLLATE "C" >= v_prefix ORDER BY o.name COLLATE "C" DESC LIMIT 1; ELSIF v_prefix <> '' THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek AND o.name COLLATE "C" >= v_prefix ORDER BY o.name COLLATE "C" DESC LIMIT 1; ELSE SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek ORDER BY o.name COLLATE "C" DESC LIMIT 1; END IF; END IF; EXIT WHEN v_peek_name IS NULL; -- STEP 2: Check if this is a FOLDER or FILE v_common_prefix := storage.get_common_prefix(v_peek_name, v_prefix, delimiter_param); IF v_common_prefix IS NOT NULL THEN -- FOLDER: Emit and skip to next folder (no heap access needed) name := rtrim(v_common_prefix, delimiter_param); id := NULL; updated_at := NULL; created_at := NULL; last_accessed_at := NULL; metadata := NULL; RETURN NEXT; v_count := v_count + 1; -- Advance seek past the folder range IF v_is_asc THEN v_next_seek := left(v_common_prefix, -1) || chr(ascii(delimiter_param) + 1); ELSE v_next_seek := v_common_prefix; END IF; ELSE -- FILE: Batch fetch using DYNAMIC SQL (overhead amortized over many rows) -- For ASC: upper_bound is the exclusive upper limit (< condition) -- For DESC: prefix is the inclusive lower limit (>= condition) FOR v_current IN EXECUTE v_batch_query USING _bucket_id, v_next_seek, CASE WHEN v_is_asc THEN COALESCE(v_upper_bound, v_prefix) ELSE v_prefix END, v_file_batch_size LOOP v_common_prefix := storage.get_common_prefix(v_current.name, v_prefix, delimiter_param); IF v_common_prefix IS NOT NULL THEN -- Hit a folder: exit batch, let peek handle it v_next_seek := v_current.name; EXIT; END IF; -- Emit file name := v_current.name; id := v_current.id; updated_at := v_current.updated_at; created_at := v_current.created_at; last_accessed_at := v_current.last_accessed_at; metadata := v_current.metadata; RETURN NEXT; v_count := v_count + 1; -- Advance seek past this file IF v_is_asc THEN v_next_seek := v_current.name || delimiter_param; ELSE v_next_seek := v_current.name; END IF; EXIT WHEN v_count >= max_keys; END LOOP; END IF; END LOOP; END; $_$; ALTER FUNCTION storage.list_objects_with_delimiter(_bucket_id text, prefix_param text, delimiter_param text, max_keys integer, start_after text, next_token text, sort_order text) OWNER TO supabase_storage_admin; -- -- Name: operation(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.operation() RETURNS text LANGUAGE plpgsql STABLE AS $$ BEGIN RETURN current_setting('storage.operation', true); END; $$; ALTER FUNCTION storage.operation() OWNER TO supabase_storage_admin; -- -- Name: protect_delete(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.protect_delete() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -- Check if storage.allow_delete_query is set to 'true' IF COALESCE(current_setting('storage.allow_delete_query', true), 'false') != 'true' THEN RAISE EXCEPTION 'Direct deletion from storage tables is not allowed. Use the Storage API instead.' USING HINT = 'This prevents accidental data loss from orphaned objects.', ERRCODE = '42501'; END IF; RETURN NULL; END; $$; ALTER FUNCTION storage.protect_delete() OWNER TO supabase_storage_admin; -- -- Name: search(text, text, integer, integer, integer, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.search(prefix text, bucketname text, limits integer DEFAULT 100, levels integer DEFAULT 1, offsets integer DEFAULT 0, search text DEFAULT ''::text, sortcolumn text DEFAULT 'name'::text, sortorder text DEFAULT 'asc'::text) RETURNS TABLE(name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb) LANGUAGE plpgsql STABLE AS $_$ DECLARE v_peek_name TEXT; v_current RECORD; v_common_prefix TEXT; v_delimiter CONSTANT TEXT := '/'; -- Configuration v_limit INT; v_prefix TEXT; v_prefix_lower TEXT; v_is_asc BOOLEAN; v_order_by TEXT; v_sort_order TEXT; v_upper_bound TEXT; v_file_batch_size INT; -- Dynamic SQL for batch query only v_batch_query TEXT; -- Seek state v_next_seek TEXT; v_count INT := 0; v_skipped INT := 0; BEGIN -- ======================================================================== -- INITIALIZATION -- ======================================================================== v_limit := LEAST(coalesce(limits, 100), 1500); v_prefix := coalesce(prefix, '') || coalesce(search, ''); v_prefix_lower := lower(v_prefix); v_is_asc := lower(coalesce(sortorder, 'asc')) = 'asc'; v_file_batch_size := LEAST(GREATEST(v_limit * 2, 100), 1000); -- Validate sort column CASE lower(coalesce(sortcolumn, 'name')) WHEN 'name' THEN v_order_by := 'name'; WHEN 'updated_at' THEN v_order_by := 'updated_at'; WHEN 'created_at' THEN v_order_by := 'created_at'; WHEN 'last_accessed_at' THEN v_order_by := 'last_accessed_at'; ELSE v_order_by := 'name'; END CASE; v_sort_order := CASE WHEN v_is_asc THEN 'asc' ELSE 'desc' END; -- ======================================================================== -- NON-NAME SORTING: Use path_tokens approach (unchanged) -- ======================================================================== IF v_order_by != 'name' THEN RETURN QUERY EXECUTE format( $sql$ WITH folders AS ( SELECT path_tokens[$1] AS folder FROM storage.objects WHERE objects.name ILIKE $2 || '%%' AND bucket_id = $3 AND array_length(objects.path_tokens, 1) <> $1 GROUP BY folder ORDER BY folder %s ) (SELECT folder AS "name", NULL::uuid AS id, NULL::timestamptz AS updated_at, NULL::timestamptz AS created_at, NULL::timestamptz AS last_accessed_at, NULL::jsonb AS metadata FROM folders) UNION ALL (SELECT path_tokens[$1] AS "name", id, updated_at, created_at, last_accessed_at, metadata FROM storage.objects WHERE objects.name ILIKE $2 || '%%' AND bucket_id = $3 AND array_length(objects.path_tokens, 1) = $1 ORDER BY %I %s) LIMIT $4 OFFSET $5 $sql$, v_sort_order, v_order_by, v_sort_order ) USING levels, v_prefix, bucketname, v_limit, offsets; RETURN; END IF; -- ======================================================================== -- NAME SORTING: Hybrid skip-scan with batch optimization -- ======================================================================== -- Calculate upper bound for prefix filtering IF v_prefix_lower = '' THEN v_upper_bound := NULL; ELSIF right(v_prefix_lower, 1) = v_delimiter THEN v_upper_bound := left(v_prefix_lower, -1) || chr(ascii(v_delimiter) + 1); ELSE v_upper_bound := left(v_prefix_lower, -1) || chr(ascii(right(v_prefix_lower, 1)) + 1); END IF; -- Build batch query (dynamic SQL - called infrequently, amortized over many rows) IF v_is_asc THEN IF v_upper_bound IS NOT NULL THEN v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" >= $2 ' || 'AND lower(o.name) COLLATE "C" < $3 ORDER BY lower(o.name) COLLATE "C" ASC LIMIT $4'; ELSE v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" >= $2 ' || 'ORDER BY lower(o.name) COLLATE "C" ASC LIMIT $4'; END IF; ELSE IF v_upper_bound IS NOT NULL THEN v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" < $2 ' || 'AND lower(o.name) COLLATE "C" >= $3 ORDER BY lower(o.name) COLLATE "C" DESC LIMIT $4'; ELSE v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' || 'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" < $2 ' || 'ORDER BY lower(o.name) COLLATE "C" DESC LIMIT $4'; END IF; END IF; -- Initialize seek position IF v_is_asc THEN v_next_seek := v_prefix_lower; ELSE -- DESC: find the last item in range first (static SQL) IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_prefix_lower AND lower(o.name) COLLATE "C" < v_upper_bound ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; ELSIF v_prefix_lower <> '' THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_prefix_lower ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; ELSE SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; END IF; IF v_peek_name IS NOT NULL THEN v_next_seek := lower(v_peek_name) || v_delimiter; ELSE RETURN; END IF; END IF; -- ======================================================================== -- MAIN LOOP: Hybrid peek-then-batch algorithm -- Uses STATIC SQL for peek (hot path) and DYNAMIC SQL for batch -- ======================================================================== LOOP EXIT WHEN v_count >= v_limit; -- STEP 1: PEEK using STATIC SQL (plan cached, very fast) IF v_is_asc THEN IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_next_seek AND lower(o.name) COLLATE "C" < v_upper_bound ORDER BY lower(o.name) COLLATE "C" ASC LIMIT 1; ELSE SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_next_seek ORDER BY lower(o.name) COLLATE "C" ASC LIMIT 1; END IF; ELSE IF v_upper_bound IS NOT NULL THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek AND lower(o.name) COLLATE "C" >= v_prefix_lower ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; ELSIF v_prefix_lower <> '' THEN SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek AND lower(o.name) COLLATE "C" >= v_prefix_lower ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; ELSE SELECT o.name INTO v_peek_name FROM storage.objects o WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1; END IF; END IF; EXIT WHEN v_peek_name IS NULL; -- STEP 2: Check if this is a FOLDER or FILE v_common_prefix := storage.get_common_prefix(lower(v_peek_name), v_prefix_lower, v_delimiter); IF v_common_prefix IS NOT NULL THEN -- FOLDER: Handle offset, emit if needed, skip to next folder IF v_skipped < offsets THEN v_skipped := v_skipped + 1; ELSE name := split_part(rtrim(v_common_prefix, v_delimiter), v_delimiter, levels); id := NULL; updated_at := NULL; created_at := NULL; last_accessed_at := NULL; metadata := NULL; RETURN NEXT; v_count := v_count + 1; END IF; -- Advance seek past the folder range IF v_is_asc THEN v_next_seek := lower(left(v_common_prefix, -1)) || chr(ascii(v_delimiter) + 1); ELSE v_next_seek := lower(v_common_prefix); END IF; ELSE -- FILE: Batch fetch using DYNAMIC SQL (overhead amortized over many rows) -- For ASC: upper_bound is the exclusive upper limit (< condition) -- For DESC: prefix_lower is the inclusive lower limit (>= condition) FOR v_current IN EXECUTE v_batch_query USING bucketname, v_next_seek, CASE WHEN v_is_asc THEN COALESCE(v_upper_bound, v_prefix_lower) ELSE v_prefix_lower END, v_file_batch_size LOOP v_common_prefix := storage.get_common_prefix(lower(v_current.name), v_prefix_lower, v_delimiter); IF v_common_prefix IS NOT NULL THEN -- Hit a folder: exit batch, let peek handle it v_next_seek := lower(v_current.name); EXIT; END IF; -- Handle offset skipping IF v_skipped < offsets THEN v_skipped := v_skipped + 1; ELSE -- Emit file name := split_part(v_current.name, v_delimiter, levels); id := v_current.id; updated_at := v_current.updated_at; created_at := v_current.created_at; last_accessed_at := v_current.last_accessed_at; metadata := v_current.metadata; RETURN NEXT; v_count := v_count + 1; END IF; -- Advance seek past this file IF v_is_asc THEN v_next_seek := lower(v_current.name) || v_delimiter; ELSE v_next_seek := lower(v_current.name); END IF; EXIT WHEN v_count >= v_limit; END LOOP; END IF; END LOOP; END; $_$; ALTER FUNCTION storage.search(prefix text, bucketname text, limits integer, levels integer, offsets integer, search text, sortcolumn text, sortorder text) OWNER TO supabase_storage_admin; -- -- Name: search_by_timestamp(text, text, integer, integer, text, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.search_by_timestamp(p_prefix text, p_bucket_id text, p_limit integer, p_level integer, p_start_after text, p_sort_order text, p_sort_column text, p_sort_column_after text) RETURNS TABLE(key text, name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb) LANGUAGE plpgsql STABLE AS $_$ DECLARE v_cursor_op text; v_query text; v_prefix text; BEGIN v_prefix := coalesce(p_prefix, ''); IF p_sort_order = 'asc' THEN v_cursor_op := '>'; ELSE v_cursor_op := '<'; END IF; v_query := format($sql$ WITH raw_objects AS ( SELECT o.name AS obj_name, o.id AS obj_id, o.updated_at AS obj_updated_at, o.created_at AS obj_created_at, o.last_accessed_at AS obj_last_accessed_at, o.metadata AS obj_metadata, storage.get_common_prefix(o.name, $1, '/') AS common_prefix FROM storage.objects o WHERE o.bucket_id = $2 AND o.name COLLATE "C" LIKE $1 || '%%' ), -- Aggregate common prefixes (folders) -- Both created_at and updated_at use MIN(obj_created_at) to match the old prefixes table behavior aggregated_prefixes AS ( SELECT rtrim(common_prefix, '/') AS name, NULL::uuid AS id, MIN(obj_created_at) AS updated_at, MIN(obj_created_at) AS created_at, NULL::timestamptz AS last_accessed_at, NULL::jsonb AS metadata, TRUE AS is_prefix FROM raw_objects WHERE common_prefix IS NOT NULL GROUP BY common_prefix ), leaf_objects AS ( SELECT obj_name AS name, obj_id AS id, obj_updated_at AS updated_at, obj_created_at AS created_at, obj_last_accessed_at AS last_accessed_at, obj_metadata AS metadata, FALSE AS is_prefix FROM raw_objects WHERE common_prefix IS NULL ), combined AS ( SELECT * FROM aggregated_prefixes UNION ALL SELECT * FROM leaf_objects ), filtered AS ( SELECT * FROM combined WHERE ( $5 = '' OR ROW( date_trunc('milliseconds', %I), name COLLATE "C" ) %s ROW( COALESCE(NULLIF($6, '')::timestamptz, 'epoch'::timestamptz), $5 ) ) ) SELECT split_part(name, '/', $3) AS key, name, id, updated_at, created_at, last_accessed_at, metadata FROM filtered ORDER BY COALESCE(date_trunc('milliseconds', %I), 'epoch'::timestamptz) %s, name COLLATE "C" %s LIMIT $4 $sql$, p_sort_column, v_cursor_op, p_sort_column, p_sort_order, p_sort_order ); RETURN QUERY EXECUTE v_query USING v_prefix, p_bucket_id, p_level, p_limit, p_start_after, p_sort_column_after; END; $_$; ALTER FUNCTION storage.search_by_timestamp(p_prefix text, p_bucket_id text, p_limit integer, p_level integer, p_start_after text, p_sort_order text, p_sort_column text, p_sort_column_after text) OWNER TO supabase_storage_admin; -- -- Name: search_v2(text, text, integer, integer, text, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.search_v2(prefix text, bucket_name text, limits integer DEFAULT 100, levels integer DEFAULT 1, start_after text DEFAULT ''::text, sort_order text DEFAULT 'asc'::text, sort_column text DEFAULT 'name'::text, sort_column_after text DEFAULT ''::text) RETURNS TABLE(key text, name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb) LANGUAGE plpgsql STABLE AS $$ DECLARE v_sort_col text; v_sort_ord text; v_limit int; BEGIN -- Cap limit to maximum of 1500 records v_limit := LEAST(coalesce(limits, 100), 1500); -- Validate and normalize sort_order v_sort_ord := lower(coalesce(sort_order, 'asc')); IF v_sort_ord NOT IN ('asc', 'desc') THEN v_sort_ord := 'asc'; END IF; -- Validate and normalize sort_column v_sort_col := lower(coalesce(sort_column, 'name')); IF v_sort_col NOT IN ('name', 'updated_at', 'created_at') THEN v_sort_col := 'name'; END IF; -- Route to appropriate implementation IF v_sort_col = 'name' THEN -- Use list_objects_with_delimiter for name sorting (most efficient: O(k * log n)) RETURN QUERY SELECT split_part(l.name, '/', levels) AS key, l.name AS name, l.id, l.updated_at, l.created_at, l.last_accessed_at, l.metadata FROM storage.list_objects_with_delimiter( bucket_name, coalesce(prefix, ''), '/', v_limit, start_after, '', v_sort_ord ) l; ELSE -- Use aggregation approach for timestamp sorting -- Not efficient for large datasets but supports correct pagination RETURN QUERY SELECT * FROM storage.search_by_timestamp( prefix, bucket_name, v_limit, levels, start_after, v_sort_ord, v_sort_col, sort_column_after ); END IF; END; $$; ALTER FUNCTION storage.search_v2(prefix text, bucket_name text, limits integer, levels integer, start_after text, sort_order text, sort_column text, sort_column_after text) OWNER TO supabase_storage_admin; -- -- Name: update_updated_at_column(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin -- CREATE FUNCTION storage.update_updated_at_column() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$; ALTER FUNCTION storage.update_updated_at_column() OWNER TO supabase_storage_admin; -- -- Name: http_request(); Type: FUNCTION; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE FUNCTION supabase_functions.http_request() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO 'supabase_functions' AS $$ DECLARE request_id bigint; payload jsonb; url text := TG_ARGV[0]::text; method text := TG_ARGV[1]::text; headers jsonb DEFAULT '{}'::jsonb; params jsonb DEFAULT '{}'::jsonb; timeout_ms integer DEFAULT 1000; BEGIN IF url IS NULL OR url = 'null' THEN RAISE EXCEPTION 'url argument is missing'; END IF; IF method IS NULL OR method = 'null' THEN RAISE EXCEPTION 'method argument is missing'; END IF; IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN headers = '{"Content-Type": "application/json"}'::jsonb; ELSE headers = TG_ARGV[2]::jsonb; END IF; IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN params = '{}'::jsonb; ELSE params = TG_ARGV[3]::jsonb; END IF; IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN timeout_ms = 1000; ELSE timeout_ms = TG_ARGV[4]::integer; END IF; CASE WHEN method = 'GET' THEN SELECT http_get INTO request_id FROM net.http_get( url, params, headers, timeout_ms ); WHEN method = 'POST' THEN payload = jsonb_build_object( 'old_record', OLD, 'record', NEW, 'type', TG_OP, 'table', TG_TABLE_NAME, 'schema', TG_TABLE_SCHEMA ); SELECT http_post INTO request_id FROM net.http_post( url, payload, params, headers, timeout_ms ); ELSE RAISE EXCEPTION 'method argument % is invalid', method; END CASE; INSERT INTO supabase_functions.hooks (hook_table_id, hook_name, request_id) VALUES (TG_RELID, TG_NAME, request_id); RETURN NEW; END $$; ALTER FUNCTION supabase_functions.http_request() OWNER TO supabase_functions_admin; -- -- Name: extensions; Type: TABLE; Schema: _realtime; Owner: supabase_admin -- CREATE TABLE _realtime.extensions ( id uuid NOT NULL, type text, settings jsonb, tenant_external_id text, inserted_at timestamp(0) without time zone NOT NULL, updated_at timestamp(0) without time zone NOT NULL ); ALTER TABLE _realtime.extensions OWNER TO supabase_admin; -- -- Name: schema_migrations; Type: TABLE; Schema: _realtime; Owner: supabase_admin -- CREATE TABLE _realtime.schema_migrations ( version bigint NOT NULL, inserted_at timestamp(0) without time zone ); ALTER TABLE _realtime.schema_migrations OWNER TO supabase_admin; -- -- Name: tenants; Type: TABLE; Schema: _realtime; Owner: supabase_admin -- CREATE TABLE _realtime.tenants ( id uuid NOT NULL, name text, external_id text, jwt_secret text, max_concurrent_users integer DEFAULT 200 NOT NULL, inserted_at timestamp(0) without time zone NOT NULL, updated_at timestamp(0) without time zone NOT NULL, max_events_per_second integer DEFAULT 100 NOT NULL, postgres_cdc_default text DEFAULT 'postgres_cdc_rls'::text, max_bytes_per_second integer DEFAULT 100000 NOT NULL, max_channels_per_client integer DEFAULT 100 NOT NULL, max_joins_per_second integer DEFAULT 500 NOT NULL, suspend boolean DEFAULT false, jwt_jwks jsonb, notify_private_alpha boolean DEFAULT false, private_only boolean DEFAULT false NOT NULL, migrations_ran integer DEFAULT 0, broadcast_adapter character varying(255) DEFAULT 'gen_rpc'::character varying, max_presence_events_per_second integer DEFAULT 1000, max_payload_size_in_kb integer DEFAULT 3000, CONSTRAINT jwt_secret_or_jwt_jwks_required CHECK (((jwt_secret IS NOT NULL) OR (jwt_jwks IS NOT NULL))) ); ALTER TABLE _realtime.tenants OWNER TO supabase_admin; -- -- Name: audit_log_entries; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.audit_log_entries ( instance_id uuid, id uuid NOT NULL, payload json, created_at timestamp with time zone, ip_address character varying(64) DEFAULT ''::character varying NOT NULL ); ALTER TABLE auth.audit_log_entries OWNER TO supabase_auth_admin; -- -- Name: TABLE audit_log_entries; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.audit_log_entries IS 'Auth: Audit trail for user actions.'; -- -- Name: flow_state; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.flow_state ( id uuid NOT NULL, user_id uuid, auth_code text, code_challenge_method auth.code_challenge_method, code_challenge text, provider_type text NOT NULL, provider_access_token text, provider_refresh_token text, created_at timestamp with time zone, updated_at timestamp with time zone, authentication_method text NOT NULL, auth_code_issued_at timestamp with time zone, invite_token text, referrer text, oauth_client_state_id uuid, linking_target_id uuid, email_optional boolean DEFAULT false NOT NULL ); ALTER TABLE auth.flow_state OWNER TO supabase_auth_admin; -- -- Name: TABLE flow_state; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.flow_state IS 'Stores metadata for all OAuth/SSO login flows'; -- -- Name: identities; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.identities ( provider_id text NOT NULL, user_id uuid NOT NULL, identity_data jsonb NOT NULL, provider text NOT NULL, last_sign_in_at timestamp with time zone, created_at timestamp with time zone, updated_at timestamp with time zone, email text GENERATED ALWAYS AS (lower((identity_data ->> 'email'::text))) STORED, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE auth.identities OWNER TO supabase_auth_admin; -- -- Name: TABLE identities; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.identities IS 'Auth: Stores identities associated to a user.'; -- -- Name: COLUMN identities.email; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.identities.email IS 'Auth: Email is a generated column that references the optional email property in the identity_data'; -- -- Name: instances; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.instances ( id uuid NOT NULL, uuid uuid, raw_base_config text, created_at timestamp with time zone, updated_at timestamp with time zone ); ALTER TABLE auth.instances OWNER TO supabase_auth_admin; -- -- Name: TABLE instances; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.instances IS 'Auth: Manages users across multiple sites.'; -- -- Name: mfa_amr_claims; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.mfa_amr_claims ( session_id uuid NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, authentication_method text NOT NULL, id uuid NOT NULL ); ALTER TABLE auth.mfa_amr_claims OWNER TO supabase_auth_admin; -- -- Name: TABLE mfa_amr_claims; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.mfa_amr_claims IS 'auth: stores authenticator method reference claims for multi factor authentication'; -- -- Name: mfa_challenges; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.mfa_challenges ( id uuid NOT NULL, factor_id uuid NOT NULL, created_at timestamp with time zone NOT NULL, verified_at timestamp with time zone, ip_address inet NOT NULL, otp_code text, web_authn_session_data jsonb ); ALTER TABLE auth.mfa_challenges OWNER TO supabase_auth_admin; -- -- Name: TABLE mfa_challenges; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.mfa_challenges IS 'auth: stores metadata about challenge requests made'; -- -- Name: mfa_factors; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.mfa_factors ( id uuid NOT NULL, user_id uuid NOT NULL, friendly_name text, factor_type auth.factor_type NOT NULL, status auth.factor_status NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, secret text, phone text, last_challenged_at timestamp with time zone, web_authn_credential jsonb, web_authn_aaguid uuid, last_webauthn_challenge_data jsonb ); ALTER TABLE auth.mfa_factors OWNER TO supabase_auth_admin; -- -- Name: TABLE mfa_factors; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.mfa_factors IS 'auth: stores metadata about factors'; -- -- Name: COLUMN mfa_factors.last_webauthn_challenge_data; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.mfa_factors.last_webauthn_challenge_data IS 'Stores the latest WebAuthn challenge data including attestation/assertion for customer verification'; -- -- Name: oauth_authorizations; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.oauth_authorizations ( id uuid NOT NULL, authorization_id text NOT NULL, client_id uuid NOT NULL, user_id uuid, redirect_uri text NOT NULL, scope text NOT NULL, state text, resource text, code_challenge text, code_challenge_method auth.code_challenge_method, response_type auth.oauth_response_type DEFAULT 'code'::auth.oauth_response_type NOT NULL, status auth.oauth_authorization_status DEFAULT 'pending'::auth.oauth_authorization_status NOT NULL, authorization_code text, created_at timestamp with time zone DEFAULT now() NOT NULL, expires_at timestamp with time zone DEFAULT (now() + '00:03:00'::interval) NOT NULL, approved_at timestamp with time zone, nonce text, CONSTRAINT oauth_authorizations_authorization_code_length CHECK ((char_length(authorization_code) <= 255)), CONSTRAINT oauth_authorizations_code_challenge_length CHECK ((char_length(code_challenge) <= 128)), CONSTRAINT oauth_authorizations_expires_at_future CHECK ((expires_at > created_at)), CONSTRAINT oauth_authorizations_nonce_length CHECK ((char_length(nonce) <= 255)), CONSTRAINT oauth_authorizations_redirect_uri_length CHECK ((char_length(redirect_uri) <= 2048)), CONSTRAINT oauth_authorizations_resource_length CHECK ((char_length(resource) <= 2048)), CONSTRAINT oauth_authorizations_scope_length CHECK ((char_length(scope) <= 4096)), CONSTRAINT oauth_authorizations_state_length CHECK ((char_length(state) <= 4096)) ); ALTER TABLE auth.oauth_authorizations OWNER TO supabase_auth_admin; -- -- Name: oauth_client_states; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.oauth_client_states ( id uuid NOT NULL, provider_type text NOT NULL, code_verifier text, created_at timestamp with time zone NOT NULL ); ALTER TABLE auth.oauth_client_states OWNER TO supabase_auth_admin; -- -- Name: TABLE oauth_client_states; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.oauth_client_states IS 'Stores OAuth states for third-party provider authentication flows where Supabase acts as the OAuth client.'; -- -- Name: oauth_clients; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.oauth_clients ( id uuid NOT NULL, client_secret_hash text, registration_type auth.oauth_registration_type NOT NULL, redirect_uris text NOT NULL, grant_types text NOT NULL, client_name text, client_uri text, logo_uri text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, client_type auth.oauth_client_type DEFAULT 'confidential'::auth.oauth_client_type NOT NULL, token_endpoint_auth_method text NOT NULL, CONSTRAINT oauth_clients_client_name_length CHECK ((char_length(client_name) <= 1024)), CONSTRAINT oauth_clients_client_uri_length CHECK ((char_length(client_uri) <= 2048)), CONSTRAINT oauth_clients_logo_uri_length CHECK ((char_length(logo_uri) <= 2048)), CONSTRAINT oauth_clients_token_endpoint_auth_method_check CHECK ((token_endpoint_auth_method = ANY (ARRAY['client_secret_basic'::text, 'client_secret_post'::text, 'none'::text]))) ); ALTER TABLE auth.oauth_clients OWNER TO supabase_auth_admin; -- -- Name: oauth_consents; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.oauth_consents ( id uuid NOT NULL, user_id uuid NOT NULL, client_id uuid NOT NULL, scopes text NOT NULL, granted_at timestamp with time zone DEFAULT now() NOT NULL, revoked_at timestamp with time zone, CONSTRAINT oauth_consents_revoked_after_granted CHECK (((revoked_at IS NULL) OR (revoked_at >= granted_at))), CONSTRAINT oauth_consents_scopes_length CHECK ((char_length(scopes) <= 2048)), CONSTRAINT oauth_consents_scopes_not_empty CHECK ((char_length(TRIM(BOTH FROM scopes)) > 0)) ); ALTER TABLE auth.oauth_consents OWNER TO supabase_auth_admin; -- -- Name: one_time_tokens; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.one_time_tokens ( id uuid NOT NULL, user_id uuid NOT NULL, token_type auth.one_time_token_type NOT NULL, token_hash text NOT NULL, relates_to text NOT NULL, created_at timestamp without time zone DEFAULT now() NOT NULL, updated_at timestamp without time zone DEFAULT now() NOT NULL, CONSTRAINT one_time_tokens_token_hash_check CHECK ((char_length(token_hash) > 0)) ); ALTER TABLE auth.one_time_tokens OWNER TO supabase_auth_admin; -- -- Name: refresh_tokens; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.refresh_tokens ( instance_id uuid, id bigint NOT NULL, token character varying(255), user_id character varying(255), revoked boolean, created_at timestamp with time zone, updated_at timestamp with time zone, parent character varying(255), session_id uuid ); ALTER TABLE auth.refresh_tokens OWNER TO supabase_auth_admin; -- -- Name: TABLE refresh_tokens; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.refresh_tokens IS 'Auth: Store of tokens used to refresh JWT tokens once they expire.'; -- -- Name: refresh_tokens_id_seq; Type: SEQUENCE; Schema: auth; Owner: supabase_auth_admin -- CREATE SEQUENCE auth.refresh_tokens_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE auth.refresh_tokens_id_seq OWNER TO supabase_auth_admin; -- -- Name: refresh_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: auth; Owner: supabase_auth_admin -- ALTER SEQUENCE auth.refresh_tokens_id_seq OWNED BY auth.refresh_tokens.id; -- -- Name: saml_providers; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.saml_providers ( id uuid NOT NULL, sso_provider_id uuid NOT NULL, entity_id text NOT NULL, metadata_xml text NOT NULL, metadata_url text, attribute_mapping jsonb, created_at timestamp with time zone, updated_at timestamp with time zone, name_id_format text, CONSTRAINT "entity_id not empty" CHECK ((char_length(entity_id) > 0)), CONSTRAINT "metadata_url not empty" CHECK (((metadata_url = NULL::text) OR (char_length(metadata_url) > 0))), CONSTRAINT "metadata_xml not empty" CHECK ((char_length(metadata_xml) > 0)) ); ALTER TABLE auth.saml_providers OWNER TO supabase_auth_admin; -- -- Name: TABLE saml_providers; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.saml_providers IS 'Auth: Manages SAML Identity Provider connections.'; -- -- Name: saml_relay_states; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.saml_relay_states ( id uuid NOT NULL, sso_provider_id uuid NOT NULL, request_id text NOT NULL, for_email text, redirect_to text, created_at timestamp with time zone, updated_at timestamp with time zone, flow_state_id uuid, CONSTRAINT "request_id not empty" CHECK ((char_length(request_id) > 0)) ); ALTER TABLE auth.saml_relay_states OWNER TO supabase_auth_admin; -- -- Name: TABLE saml_relay_states; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.saml_relay_states IS 'Auth: Contains SAML Relay State information for each Service Provider initiated login.'; -- -- Name: schema_migrations; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.schema_migrations ( version character varying(255) NOT NULL ); ALTER TABLE auth.schema_migrations OWNER TO supabase_auth_admin; -- -- Name: TABLE schema_migrations; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.schema_migrations IS 'Auth: Manages updates to the auth system.'; -- -- Name: sessions; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.sessions ( id uuid NOT NULL, user_id uuid NOT NULL, created_at timestamp with time zone, updated_at timestamp with time zone, factor_id uuid, aal auth.aal_level, not_after timestamp with time zone, refreshed_at timestamp without time zone, user_agent text, ip inet, tag text, oauth_client_id uuid, refresh_token_hmac_key text, refresh_token_counter bigint, scopes text, CONSTRAINT sessions_scopes_length CHECK ((char_length(scopes) <= 4096)) ); ALTER TABLE auth.sessions OWNER TO supabase_auth_admin; -- -- Name: TABLE sessions; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.sessions IS 'Auth: Stores session data associated to a user.'; -- -- Name: COLUMN sessions.not_after; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.sessions.not_after IS 'Auth: Not after is a nullable column that contains a timestamp after which the session should be regarded as expired.'; -- -- Name: COLUMN sessions.refresh_token_hmac_key; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.sessions.refresh_token_hmac_key IS 'Holds a HMAC-SHA256 key used to sign refresh tokens for this session.'; -- -- Name: COLUMN sessions.refresh_token_counter; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.sessions.refresh_token_counter IS 'Holds the ID (counter) of the last issued refresh token.'; -- -- Name: sso_domains; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.sso_domains ( id uuid NOT NULL, sso_provider_id uuid NOT NULL, domain text NOT NULL, created_at timestamp with time zone, updated_at timestamp with time zone, CONSTRAINT "domain not empty" CHECK ((char_length(domain) > 0)) ); ALTER TABLE auth.sso_domains OWNER TO supabase_auth_admin; -- -- Name: TABLE sso_domains; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.sso_domains IS 'Auth: Manages SSO email address domain mapping to an SSO Identity Provider.'; -- -- Name: sso_providers; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.sso_providers ( id uuid NOT NULL, resource_id text, created_at timestamp with time zone, updated_at timestamp with time zone, disabled boolean, CONSTRAINT "resource_id not empty" CHECK (((resource_id = NULL::text) OR (char_length(resource_id) > 0))) ); ALTER TABLE auth.sso_providers OWNER TO supabase_auth_admin; -- -- Name: TABLE sso_providers; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.sso_providers IS 'Auth: Manages SSO identity provider information; see saml_providers for SAML.'; -- -- Name: COLUMN sso_providers.resource_id; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.sso_providers.resource_id IS 'Auth: Uniquely identifies a SSO provider according to a user-chosen resource ID (case insensitive), useful in infrastructure as code.'; -- -- Name: users; Type: TABLE; Schema: auth; Owner: supabase_auth_admin -- CREATE TABLE auth.users ( instance_id uuid, id uuid NOT NULL, aud character varying(255), role character varying(255), email character varying(255), encrypted_password character varying(255), email_confirmed_at timestamp with time zone, invited_at timestamp with time zone, confirmation_token character varying(255), confirmation_sent_at timestamp with time zone, recovery_token character varying(255), recovery_sent_at timestamp with time zone, email_change_token_new character varying(255), email_change character varying(255), email_change_sent_at timestamp with time zone, last_sign_in_at timestamp with time zone, raw_app_meta_data jsonb, raw_user_meta_data jsonb, is_super_admin boolean, created_at timestamp with time zone, updated_at timestamp with time zone, phone text DEFAULT NULL::character varying, phone_confirmed_at timestamp with time zone, phone_change text DEFAULT ''::character varying, phone_change_token character varying(255) DEFAULT ''::character varying, phone_change_sent_at timestamp with time zone, confirmed_at timestamp with time zone GENERATED ALWAYS AS (LEAST(email_confirmed_at, phone_confirmed_at)) STORED, email_change_token_current character varying(255) DEFAULT ''::character varying, email_change_confirm_status smallint DEFAULT 0, banned_until timestamp with time zone, reauthentication_token character varying(255) DEFAULT ''::character varying, reauthentication_sent_at timestamp with time zone, is_sso_user boolean DEFAULT false NOT NULL, deleted_at timestamp with time zone, is_anonymous boolean DEFAULT false NOT NULL, CONSTRAINT users_email_change_confirm_status_check CHECK (((email_change_confirm_status >= 0) AND (email_change_confirm_status <= 2))) ); ALTER TABLE auth.users OWNER TO supabase_auth_admin; -- -- Name: TABLE users; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON TABLE auth.users IS 'Auth: Stores user login data within a secure schema.'; -- -- Name: COLUMN users.is_sso_user; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON COLUMN auth.users.is_sso_user IS 'Auth: Set this column to true when the account comes from SSO. These accounts can have duplicate emails.'; -- -- Name: agenda_bloqueios; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_bloqueios ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid, tipo text NOT NULL, titulo text NOT NULL, data_inicio date NOT NULL, data_fim date, hora_inicio time without time zone, hora_fim time without time zone, recorrente boolean DEFAULT false NOT NULL, dia_semana smallint, observacao text, origem text DEFAULT 'manual'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT agenda_bloqueios_tipo_check CHECK ((tipo = ANY (ARRAY['feriado_nacional'::text, 'feriado_municipal'::text, 'bloqueio'::text]))) ); ALTER TABLE public.agenda_bloqueios OWNER TO supabase_admin; -- -- Name: agenda_configuracoes; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_configuracoes ( owner_id uuid NOT NULL, duracao_padrao_minutos integer DEFAULT 50 NOT NULL, intervalo_padrao_minutos integer DEFAULT 0 NOT NULL, timezone text DEFAULT 'America/Sao_Paulo'::text NOT NULL, usar_horario_admin_custom boolean DEFAULT false NOT NULL, admin_inicio_visualizacao time without time zone, admin_fim_visualizacao time without time zone, admin_slot_visual_minutos integer DEFAULT 30 NOT NULL, online_ativo boolean DEFAULT false NOT NULL, online_min_antecedencia_horas integer DEFAULT 24 NOT NULL, online_max_dias_futuro integer DEFAULT 60 NOT NULL, online_cancelar_ate_horas integer DEFAULT 12 NOT NULL, online_reagendar_ate_horas integer DEFAULT 12 NOT NULL, online_limite_agendamentos_futuros integer DEFAULT 1 NOT NULL, online_modo text DEFAULT 'automatico'::text NOT NULL, online_buffer_antes_min integer DEFAULT 0 NOT NULL, online_buffer_depois_min integer DEFAULT 0 NOT NULL, online_modalidade text DEFAULT 'ambos'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, usar_granularidade_custom boolean DEFAULT false NOT NULL, granularidade_min integer, setup_concluido boolean DEFAULT false NOT NULL, setup_concluido_em timestamp with time zone, agenda_view_mode text DEFAULT 'full_24h'::text NOT NULL, agenda_custom_start time without time zone, agenda_custom_end time without time zone, session_duration_min integer DEFAULT 50 NOT NULL, session_break_min integer DEFAULT 10 NOT NULL, pausas_semanais jsonb DEFAULT '[]'::jsonb NOT NULL, setup_clinica_concluido boolean DEFAULT false NOT NULL, setup_clinica_concluido_em timestamp with time zone, tenant_id uuid, jornada_igual_todos boolean DEFAULT true, slot_mode text DEFAULT 'fixed'::text NOT NULL, CONSTRAINT agenda_configuracoes_admin_slot_visual_minutos_check CHECK ((admin_slot_visual_minutos = ANY (ARRAY[5, 10, 15, 20, 30, 60]))), CONSTRAINT agenda_configuracoes_check CHECK (((usar_horario_admin_custom = false) OR ((admin_inicio_visualizacao IS NOT NULL) AND (admin_fim_visualizacao IS NOT NULL) AND (admin_fim_visualizacao > admin_inicio_visualizacao)))), CONSTRAINT agenda_configuracoes_duracao_padrao_minutos_check CHECK (((duracao_padrao_minutos >= 10) AND (duracao_padrao_minutos <= 240))), CONSTRAINT agenda_configuracoes_granularidade_min_check CHECK (((granularidade_min IS NULL) OR (granularidade_min = ANY (ARRAY[5, 10, 15, 20, 30, 45, 50, 60])))), CONSTRAINT agenda_configuracoes_intervalo_padrao_minutos_check CHECK (((intervalo_padrao_minutos >= 0) AND (intervalo_padrao_minutos <= 120))), CONSTRAINT agenda_configuracoes_online_buffer_antes_min_check CHECK (((online_buffer_antes_min >= 0) AND (online_buffer_antes_min <= 120))), CONSTRAINT agenda_configuracoes_online_buffer_depois_min_check CHECK (((online_buffer_depois_min >= 0) AND (online_buffer_depois_min <= 120))), CONSTRAINT agenda_configuracoes_online_cancelar_ate_horas_check CHECK (((online_cancelar_ate_horas >= 0) AND (online_cancelar_ate_horas <= 720))), CONSTRAINT agenda_configuracoes_online_limite_agendamentos_futuros_check CHECK (((online_limite_agendamentos_futuros >= 1) AND (online_limite_agendamentos_futuros <= 10))), CONSTRAINT agenda_configuracoes_online_max_dias_futuro_check CHECK (((online_max_dias_futuro >= 1) AND (online_max_dias_futuro <= 365))), CONSTRAINT agenda_configuracoes_online_min_antecedencia_horas_check CHECK (((online_min_antecedencia_horas >= 0) AND (online_min_antecedencia_horas <= 720))), CONSTRAINT agenda_configuracoes_online_modalidade_check CHECK ((online_modalidade = ANY (ARRAY['online'::text, 'presencial'::text, 'ambos'::text]))), CONSTRAINT agenda_configuracoes_online_modo_check CHECK ((online_modo = ANY (ARRAY['automatico'::text, 'aprovacao'::text]))), CONSTRAINT agenda_configuracoes_online_reagendar_ate_horas_check CHECK (((online_reagendar_ate_horas >= 0) AND (online_reagendar_ate_horas <= 720))), CONSTRAINT agenda_configuracoes_slot_mode_chk CHECK ((slot_mode = ANY (ARRAY['fixed'::text, 'dynamic'::text]))), CONSTRAINT session_break_min_chk CHECK (((session_break_min >= 0) AND (session_break_min <= 60))), CONSTRAINT session_duration_min_chk CHECK (((session_duration_min >= 10) AND (session_duration_min <= 240))) ); ALTER TABLE public.agenda_configuracoes OWNER TO supabase_admin; -- -- Name: agenda_eventos; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_eventos ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tipo public.tipo_evento_agenda DEFAULT 'sessao'::public.tipo_evento_agenda NOT NULL, status public.status_evento_agenda DEFAULT 'agendado'::public.status_evento_agenda NOT NULL, titulo text, observacoes text, inicio_em timestamp with time zone NOT NULL, fim_em timestamp with time zone NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, terapeuta_id uuid, tenant_id uuid NOT NULL, visibility_scope text DEFAULT 'public'::text NOT NULL, mirror_of_event_id uuid, mirror_source text, patient_id uuid, determined_commitment_id uuid, link_online text, titulo_custom text, extra_fields jsonb, recurrence_id uuid, recurrence_date date, modalidade text DEFAULT 'presencial'::text, price numeric(10,2), billing_contract_id uuid, billed boolean DEFAULT false NOT NULL, services_customized boolean DEFAULT false NOT NULL, insurance_plan_id uuid, insurance_guide_number text, insurance_value numeric(10,2), insurance_plan_service_id uuid, CONSTRAINT agenda_eventos_check CHECK ((fim_em > inicio_em)) ); ALTER TABLE public.agenda_eventos OWNER TO supabase_admin; -- -- Name: COLUMN agenda_eventos.price; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.agenda_eventos.price IS 'Valor da sessão em BRL. Preenchido automaticamente pela tabela professional_pricing do profissional.'; -- -- Name: agenda_excecoes; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_excecoes ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, data date NOT NULL, hora_inicio time without time zone, hora_fim time without time zone, tipo public.tipo_excecao_agenda NOT NULL, motivo text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, status public.status_excecao_agenda DEFAULT 'ativo'::public.status_excecao_agenda NOT NULL, fonte text DEFAULT 'manual'::text NOT NULL, aplicavel_online boolean DEFAULT true NOT NULL, tenant_id uuid NOT NULL, CONSTRAINT agenda_excecoes_check CHECK ((((hora_inicio IS NULL) AND (hora_fim IS NULL)) OR ((hora_inicio IS NOT NULL) AND (hora_fim IS NOT NULL) AND (hora_fim > hora_inicio)))), CONSTRAINT agenda_excecoes_fonte_check CHECK ((fonte = ANY (ARRAY['manual'::text, 'feriado_google'::text, 'sistema'::text]))) ); ALTER TABLE public.agenda_excecoes OWNER TO supabase_admin; -- -- Name: agenda_online_slots; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_online_slots ( id bigint NOT NULL, owner_id uuid NOT NULL, weekday integer NOT NULL, "time" time without time zone NOT NULL, enabled boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid NOT NULL, CONSTRAINT agenda_online_slots_weekday_check CHECK ((weekday = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6]))) ); ALTER TABLE public.agenda_online_slots OWNER TO supabase_admin; -- -- Name: agenda_online_slots_id_seq; Type: SEQUENCE; Schema: public; Owner: supabase_admin -- CREATE SEQUENCE public.agenda_online_slots_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.agenda_online_slots_id_seq OWNER TO supabase_admin; -- -- Name: agenda_online_slots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: supabase_admin -- ALTER SEQUENCE public.agenda_online_slots_id_seq OWNED BY public.agenda_online_slots.id; -- -- Name: agenda_regras_semanais; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_regras_semanais ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, dia_semana smallint NOT NULL, hora_inicio time without time zone NOT NULL, hora_fim time without time zone NOT NULL, modalidade text DEFAULT 'ambos'::text NOT NULL, ativo boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid NOT NULL, CONSTRAINT agenda_regras_semanais_check CHECK ((hora_fim > hora_inicio)), CONSTRAINT agenda_regras_semanais_dia_semana_check CHECK (((dia_semana >= 0) AND (dia_semana <= 6))), CONSTRAINT agenda_regras_semanais_modalidade_check CHECK (((modalidade = ANY (ARRAY['online'::text, 'presencial'::text, 'ambos'::text])) OR (modalidade IS NULL))) ); ALTER TABLE public.agenda_regras_semanais OWNER TO supabase_admin; -- -- Name: agenda_slots_bloqueados_semanais; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_slots_bloqueados_semanais ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, dia_semana smallint NOT NULL, hora_inicio time without time zone NOT NULL, motivo text, ativo boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid NOT NULL, CONSTRAINT agenda_slots_bloqueados_semanais_dia_semana_check CHECK (((dia_semana >= 0) AND (dia_semana <= 6))) ); ALTER TABLE public.agenda_slots_bloqueados_semanais OWNER TO supabase_admin; -- -- Name: agenda_slots_regras; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agenda_slots_regras ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, dia_semana smallint NOT NULL, passo_minutos integer NOT NULL, offset_minutos integer DEFAULT 0 NOT NULL, buffer_antes_min integer DEFAULT 0 NOT NULL, buffer_depois_min integer DEFAULT 0 NOT NULL, min_antecedencia_horas integer DEFAULT 0 NOT NULL, ativo boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid NOT NULL, CONSTRAINT agenda_slots_regras_buffer_antes_min_check CHECK (((buffer_antes_min >= 0) AND (buffer_antes_min <= 240))), CONSTRAINT agenda_slots_regras_buffer_depois_min_check CHECK (((buffer_depois_min >= 0) AND (buffer_depois_min <= 240))), CONSTRAINT agenda_slots_regras_dia_semana_check CHECK (((dia_semana >= 0) AND (dia_semana <= 6))), CONSTRAINT agenda_slots_regras_min_antecedencia_horas_check CHECK (((min_antecedencia_horas >= 0) AND (min_antecedencia_horas <= 720))), CONSTRAINT agenda_slots_regras_offset_minutos_check CHECK (((offset_minutos >= 0) AND (offset_minutos <= 55))), CONSTRAINT agenda_slots_regras_passo_minutos_check CHECK (((passo_minutos >= 5) AND (passo_minutos <= 240))) ); ALTER TABLE public.agenda_slots_regras OWNER TO supabase_admin; -- -- Name: agendador_configuracoes; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agendador_configuracoes ( owner_id uuid NOT NULL, tenant_id uuid, ativo boolean DEFAULT false NOT NULL, link_slug text, imagem_fundo_url text, imagem_header_url text, logomarca_url text, cor_primaria text DEFAULT '#4b6bff'::text, nome_exibicao text, endereco text, botao_como_chegar_ativo boolean DEFAULT true NOT NULL, maps_url text, modo_aprovacao text DEFAULT 'aprovacao'::text NOT NULL, modalidade text DEFAULT 'presencial'::text NOT NULL, tipos_habilitados jsonb DEFAULT '["primeira", "retorno"]'::jsonb NOT NULL, duracao_sessao_min integer DEFAULT 50 NOT NULL, antecedencia_minima_horas integer DEFAULT 24 NOT NULL, prazo_resposta_horas integer DEFAULT 2 NOT NULL, reserva_horas integer DEFAULT 2 NOT NULL, pagamento_obrigatorio boolean DEFAULT false NOT NULL, pix_chave text, pix_countdown_minutos integer DEFAULT 20 NOT NULL, triagem_motivo boolean DEFAULT true NOT NULL, triagem_como_conheceu boolean DEFAULT false NOT NULL, verificacao_email boolean DEFAULT false NOT NULL, exigir_aceite_lgpd boolean DEFAULT true NOT NULL, mensagem_boas_vindas text, texto_como_se_preparar text, texto_termos_lgpd text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, pagamento_modo text DEFAULT 'sem_pagamento'::text NOT NULL, pagamento_metodos_visiveis text[] DEFAULT '{}'::text[] NOT NULL, CONSTRAINT agendador_configuracoes_antecedencia_check CHECK (((antecedencia_minima_horas >= 0) AND (antecedencia_minima_horas <= 720))), CONSTRAINT agendador_configuracoes_duracao_check CHECK (((duracao_sessao_min >= 10) AND (duracao_sessao_min <= 240))), CONSTRAINT agendador_configuracoes_modalidade_check CHECK ((modalidade = ANY (ARRAY['presencial'::text, 'online'::text, 'ambos'::text]))), CONSTRAINT agendador_configuracoes_modo_check CHECK ((modo_aprovacao = ANY (ARRAY['automatico'::text, 'aprovacao'::text]))), CONSTRAINT agendador_configuracoes_pix_countdown_check CHECK (((pix_countdown_minutos >= 5) AND (pix_countdown_minutos <= 120))), CONSTRAINT agendador_configuracoes_prazo_check CHECK (((prazo_resposta_horas >= 1) AND (prazo_resposta_horas <= 72))), CONSTRAINT agendador_configuracoes_reserva_check CHECK (((reserva_horas >= 1) AND (reserva_horas <= 48))) ); ALTER TABLE public.agendador_configuracoes OWNER TO supabase_admin; -- -- Name: COLUMN agendador_configuracoes.pagamento_modo; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.agendador_configuracoes.pagamento_modo IS 'sem_pagamento | pagar_na_hora | pix_antecipado'; -- -- Name: COLUMN agendador_configuracoes.pagamento_metodos_visiveis; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.agendador_configuracoes.pagamento_metodos_visiveis IS 'Métodos exibidos ao paciente quando pagamento_modo = pagar_na_hora. Ex: {pix, deposito, dinheiro, cartao, convenio}'; -- -- Name: agendador_solicitacoes; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.agendador_solicitacoes ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid, paciente_nome text NOT NULL, paciente_sobrenome text, paciente_email text NOT NULL, paciente_celular text, paciente_cpf text, tipo text NOT NULL, modalidade text NOT NULL, data_solicitada date NOT NULL, hora_solicitada time without time zone NOT NULL, reservado_ate timestamp with time zone, motivo text, como_conheceu text, pix_status text DEFAULT 'pendente'::text, pix_pago_em timestamp with time zone, status text DEFAULT 'pendente'::text NOT NULL, recusado_motivo text, autorizado_em timestamp with time zone, autorizado_por uuid, user_id uuid, patient_id uuid, evento_id uuid, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT agendador_sol_modalidade_check CHECK ((modalidade = ANY (ARRAY['presencial'::text, 'online'::text]))), CONSTRAINT agendador_sol_pix_check CHECK (((pix_status IS NULL) OR (pix_status = ANY (ARRAY['pendente'::text, 'pago'::text, 'expirado'::text])))), CONSTRAINT agendador_sol_status_check CHECK ((status = ANY (ARRAY['pendente'::text, 'autorizado'::text, 'recusado'::text, 'expirado'::text, 'convertido'::text]))), CONSTRAINT agendador_sol_tipo_check CHECK ((tipo = ANY (ARRAY['primeira'::text, 'retorno'::text, 'reagendar'::text]))) ); ALTER TABLE public.agendador_solicitacoes OWNER TO supabase_admin; -- -- Name: billing_contracts; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.billing_contracts ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid NOT NULL, patient_id uuid NOT NULL, type text NOT NULL, total_sessions integer, sessions_used integer DEFAULT 0, package_price numeric(10,2), amount numeric(10,2), billing_interval text, active_from timestamp with time zone DEFAULT now(), active_to timestamp with time zone, status text DEFAULT 'active'::text NOT NULL, created_at timestamp with time zone DEFAULT now(), CONSTRAINT billing_contracts_interval_chk CHECK (((billing_interval IS NULL) OR (billing_interval = ANY (ARRAY['monthly'::text, 'weekly'::text])))), CONSTRAINT billing_contracts_sess_used_chk CHECK (((sessions_used IS NULL) OR (sessions_used >= 0))), CONSTRAINT billing_contracts_status_chk CHECK ((status = ANY (ARRAY['active'::text, 'completed'::text, 'cancelled'::text]))), CONSTRAINT billing_contracts_total_sess_chk CHECK (((total_sessions IS NULL) OR (total_sessions > 0))), CONSTRAINT billing_contracts_type_chk CHECK ((type = ANY (ARRAY['per_session'::text, 'package'::text, 'subscription'::text]))) ); ALTER TABLE public.billing_contracts OWNER TO supabase_admin; -- -- Name: commitment_services; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.commitment_services ( id uuid DEFAULT gen_random_uuid() NOT NULL, commitment_id uuid NOT NULL, service_id uuid NOT NULL, quantity integer DEFAULT 1 NOT NULL, unit_price numeric(10,2) NOT NULL, discount_pct numeric(5,2) DEFAULT 0, discount_flat numeric(10,2) DEFAULT 0, final_price numeric(10,2) NOT NULL, created_at timestamp with time zone DEFAULT now(), CONSTRAINT commitment_services_disc_flat_chk CHECK ((discount_flat >= (0)::numeric)), CONSTRAINT commitment_services_disc_pct_chk CHECK (((discount_pct >= (0)::numeric) AND (discount_pct <= (100)::numeric))), CONSTRAINT commitment_services_final_price_chk CHECK ((final_price >= (0)::numeric)), CONSTRAINT commitment_services_quantity_chk CHECK ((quantity > 0)) ); ALTER TABLE public.commitment_services OWNER TO supabase_admin; -- -- Name: commitment_time_logs; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.commitment_time_logs ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, commitment_id uuid NOT NULL, calendar_event_id uuid, source public.commitment_log_source DEFAULT 'manual'::public.commitment_log_source NOT NULL, started_at timestamp with time zone NOT NULL, ended_at timestamp with time zone NOT NULL, minutes integer NOT NULL, created_by uuid, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.commitment_time_logs OWNER TO supabase_admin; -- -- Name: current_tenant_id; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.current_tenant_id AS SELECT current_setting('request.jwt.claim.tenant_id'::text, true) AS current_setting; ALTER VIEW public.current_tenant_id OWNER TO supabase_admin; -- -- Name: determined_commitment_fields; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.determined_commitment_fields ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, commitment_id uuid NOT NULL, key text NOT NULL, label text NOT NULL, field_type public.determined_field_type DEFAULT 'text'::public.determined_field_type NOT NULL, required boolean DEFAULT false NOT NULL, sort_order integer DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.determined_commitment_fields OWNER TO supabase_admin; -- -- Name: determined_commitments; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.determined_commitments ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, created_by uuid, is_native boolean DEFAULT false NOT NULL, native_key text, is_locked boolean DEFAULT false NOT NULL, active boolean DEFAULT true NOT NULL, name text NOT NULL, description text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, bg_color text, text_color text ); ALTER TABLE public.determined_commitments OWNER TO supabase_admin; -- -- Name: dev_user_credentials; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.dev_user_credentials ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid, email text NOT NULL, password_dev text NOT NULL, kind text DEFAULT 'custom'::text NOT NULL, note text, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.dev_user_credentials OWNER TO supabase_admin; -- -- Name: entitlements_invalidation; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.entitlements_invalidation ( owner_id uuid NOT NULL, changed_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.entitlements_invalidation OWNER TO supabase_admin; -- -- Name: features; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.features ( id uuid DEFAULT gen_random_uuid() NOT NULL, key text NOT NULL, description text, created_at timestamp with time zone DEFAULT now() NOT NULL, descricao text DEFAULT ''::text NOT NULL, name text DEFAULT ''::text NOT NULL ); ALTER TABLE public.features OWNER TO supabase_admin; -- -- Name: COLUMN features.descricao; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.features.descricao IS 'Descrição humana da feature (exibição no admin e documentação).'; -- -- Name: feriados; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.feriados ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid, owner_id uuid, tipo text DEFAULT 'municipal'::text NOT NULL, nome text NOT NULL, data date NOT NULL, cidade text, estado text, observacao text, bloqueia_sessoes boolean DEFAULT false NOT NULL, criado_em timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT feriados_tipo_check CHECK ((tipo = ANY (ARRAY['municipal'::text, 'personalizado'::text]))) ); ALTER TABLE public.feriados OWNER TO supabase_admin; -- -- Name: financial_exceptions; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.financial_exceptions ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid, tenant_id uuid NOT NULL, exception_type text NOT NULL, charge_mode text NOT NULL, charge_value numeric(10,2), charge_pct numeric(5,2), min_hours_notice integer, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now(), CONSTRAINT financial_exceptions_charge_chk CHECK ((charge_mode = ANY (ARRAY['none'::text, 'full'::text, 'fixed_fee'::text, 'percentage'::text]))), CONSTRAINT financial_exceptions_type_chk CHECK ((exception_type = ANY (ARRAY['patient_no_show'::text, 'patient_cancellation'::text, 'professional_cancellation'::text]))) ); ALTER TABLE public.financial_exceptions OWNER TO supabase_admin; -- -- Name: insurance_plan_services; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.insurance_plan_services ( id uuid DEFAULT gen_random_uuid() NOT NULL, insurance_plan_id uuid NOT NULL, name text NOT NULL, value numeric(10,2) NOT NULL, active boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.insurance_plan_services OWNER TO supabase_admin; -- -- Name: insurance_plans; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.insurance_plans ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid NOT NULL, name text NOT NULL, notes text, default_value numeric(10,2), active boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.insurance_plans OWNER TO supabase_admin; -- -- Name: module_features; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.module_features ( module_id uuid NOT NULL, feature_id uuid NOT NULL, enabled boolean DEFAULT true NOT NULL, limits jsonb, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.module_features OWNER TO supabase_admin; -- -- Name: modules; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.modules ( id uuid DEFAULT gen_random_uuid() NOT NULL, key text NOT NULL, name text NOT NULL, description text, is_active boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.modules OWNER TO supabase_admin; -- -- Name: plan_features; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.plan_features ( plan_id uuid NOT NULL, feature_id uuid NOT NULL, enabled boolean DEFAULT true NOT NULL, limits jsonb, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.plan_features OWNER TO supabase_admin; -- -- Name: tenant_modules; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenant_modules ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, module_id uuid NOT NULL, status text DEFAULT 'active'::text NOT NULL, settings jsonb, provider text DEFAULT 'manual'::text NOT NULL, provider_item_id text, installed_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.tenant_modules OWNER TO supabase_admin; -- -- Name: owner_feature_entitlements; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.owner_feature_entitlements AS WITH base AS ( SELECT s.user_id AS owner_id, f.key AS feature_key, pf.limits, 'plan'::text AS source FROM ((public.subscriptions s JOIN public.plan_features pf ON (((pf.plan_id = s.plan_id) AND (pf.enabled = true)))) JOIN public.features f ON ((f.id = pf.feature_id))) WHERE ((s.status = 'active'::text) AND (s.user_id IS NOT NULL)) UNION ALL SELECT tm.owner_id, f.key AS feature_key, mf.limits, 'module'::text AS source FROM (((public.tenant_modules tm JOIN public.modules m ON (((m.id = tm.module_id) AND (m.is_active = true)))) JOIN public.module_features mf ON (((mf.module_id = m.id) AND (mf.enabled = true)))) JOIN public.features f ON ((f.id = mf.feature_id))) WHERE ((tm.status = 'active'::text) AND (tm.owner_id IS NOT NULL)) ) SELECT owner_id, feature_key, array_agg(DISTINCT source) AS sources, jsonb_agg(limits) FILTER (WHERE (limits IS NOT NULL)) AS limits_list FROM base GROUP BY owner_id, feature_key; ALTER VIEW public.owner_feature_entitlements OWNER TO supabase_admin; -- -- Name: owner_users; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.owner_users ( owner_id uuid NOT NULL, user_id uuid NOT NULL, role text DEFAULT 'admin'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.owner_users OWNER TO supabase_admin; -- -- Name: patient_discounts; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_discounts ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid NOT NULL, patient_id uuid NOT NULL, discount_pct numeric(5,2) DEFAULT 0, discount_flat numeric(10,2) DEFAULT 0, reason text, active boolean DEFAULT true NOT NULL, active_from timestamp with time zone DEFAULT now(), active_to timestamp with time zone, created_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.patient_discounts OWNER TO supabase_admin; -- -- Name: patient_group_patient; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_group_patient ( patient_group_id uuid NOT NULL, patient_id uuid NOT NULL, created_at timestamp with time zone DEFAULT now(), tenant_id uuid NOT NULL ); ALTER TABLE public.patient_group_patient OWNER TO supabase_admin; -- -- Name: patient_groups; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_groups ( id uuid DEFAULT gen_random_uuid() NOT NULL, nome text NOT NULL, descricao text, cor text, is_active boolean DEFAULT true NOT NULL, is_system boolean DEFAULT false NOT NULL, owner_id uuid DEFAULT auth.uid() NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, therapist_id uuid, tenant_id uuid NOT NULL ); ALTER TABLE public.patient_groups OWNER TO supabase_admin; -- -- Name: patient_intake_requests; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_intake_requests ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, token text NOT NULL, consent boolean DEFAULT false NOT NULL, status text DEFAULT 'new'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, converted_patient_id uuid, rejected_reason text, updated_at timestamp with time zone DEFAULT now() NOT NULL, cpf text, rg text, cep text, nome_completo text, email_principal text, telefone text, pais text, cidade text, estado text, endereco text, numero text, bairro text, complemento text, data_nascimento date, naturalidade text, genero text, estado_civil text, onde_nos_conheceu text, encaminhado_por text, observacoes text, notas_internas text, email_alternativo text, telefone_alternativo text, profissao text, escolaridade text, nacionalidade text, avatar_url text, tenant_id uuid, CONSTRAINT chk_intakes_status CHECK ((status = ANY (ARRAY['new'::text, 'converted'::text, 'rejected'::text]))) ); ALTER TABLE public.patient_intake_requests OWNER TO supabase_admin; -- -- Name: patient_invites; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_invites ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, token text NOT NULL, active boolean DEFAULT true NOT NULL, expires_at timestamp with time zone, max_uses integer, uses integer DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid ); ALTER TABLE public.patient_invites OWNER TO supabase_admin; -- -- Name: patient_patient_tag; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_patient_tag ( owner_id uuid NOT NULL, patient_id uuid NOT NULL, tag_id uuid NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, tenant_id uuid NOT NULL ); ALTER TABLE public.patient_patient_tag OWNER TO supabase_admin; -- -- Name: patient_tags; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patient_tags ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, nome text NOT NULL, cor text, is_padrao boolean DEFAULT false NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone, tenant_id uuid NOT NULL ); ALTER TABLE public.patient_tags OWNER TO supabase_admin; -- -- Name: patients; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.patients ( id uuid DEFAULT gen_random_uuid() NOT NULL, nome_completo text NOT NULL, email_principal text, telefone text, created_at timestamp with time zone DEFAULT now(), owner_id uuid, avatar_url text, status text DEFAULT 'Ativo'::text, last_attended_at timestamp with time zone, is_native boolean DEFAULT false, naturalidade text, data_nascimento date, rg text, cpf text, identification_color text, genero text, estado_civil text, email_alternativo text, pais text DEFAULT 'Brasil'::text, cep text, cidade text, estado text, endereco text, numero text, bairro text, complemento text, escolaridade text, profissao text, nome_parente text, grau_parentesco text, telefone_alternativo text, onde_nos_conheceu text, encaminhado_por text, nome_responsavel text, telefone_responsavel text, cpf_responsavel text, observacao_responsavel text, cobranca_no_responsavel boolean DEFAULT false, observacoes text, notas_internas text, updated_at timestamp with time zone DEFAULT now(), telefone_parente text, tenant_id uuid NOT NULL, responsible_member_id uuid NOT NULL, user_id uuid, patient_scope text DEFAULT 'clinic'::text NOT NULL, therapist_member_id uuid, CONSTRAINT cpf_responsavel_format_check CHECK (((cpf_responsavel IS NULL) OR (cpf_responsavel ~ '^\d{11}$'::text))), CONSTRAINT patients_cpf_format_check CHECK (((cpf IS NULL) OR (cpf ~ '^\d{11}$'::text))), CONSTRAINT patients_patient_scope_check CHECK ((patient_scope = ANY (ARRAY['clinic'::text, 'therapist'::text]))), CONSTRAINT patients_status_check CHECK ((status = ANY (ARRAY['Ativo'::text, 'Inativo'::text, 'Alta'::text, 'Encaminhado'::text]))), CONSTRAINT patients_therapist_scope_consistency CHECK ((((patient_scope = 'clinic'::text) AND (therapist_member_id IS NULL)) OR ((patient_scope = 'therapist'::text) AND (therapist_member_id IS NOT NULL)))) ); ALTER TABLE public.patients OWNER TO supabase_admin; -- -- Name: COLUMN patients.avatar_url; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.patients.avatar_url IS 'URL pública da imagem de avatar armazenada no Supabase Storage'; -- -- Name: payment_settings; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.payment_settings ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid, pix_ativo boolean DEFAULT false NOT NULL, pix_tipo text DEFAULT 'cpf'::text NOT NULL, pix_chave text DEFAULT ''::text NOT NULL, pix_nome_titular text DEFAULT ''::text NOT NULL, deposito_ativo boolean DEFAULT false NOT NULL, deposito_banco text DEFAULT ''::text NOT NULL, deposito_agencia text DEFAULT ''::text NOT NULL, deposito_conta text DEFAULT ''::text NOT NULL, deposito_tipo_conta text DEFAULT 'corrente'::text NOT NULL, deposito_titular text DEFAULT ''::text NOT NULL, deposito_cpf_cnpj text DEFAULT ''::text NOT NULL, dinheiro_ativo boolean DEFAULT false NOT NULL, cartao_ativo boolean DEFAULT false NOT NULL, cartao_instrucao text DEFAULT ''::text NOT NULL, convenio_ativo boolean DEFAULT false NOT NULL, convenio_lista text DEFAULT ''::text NOT NULL, observacoes_pagamento text DEFAULT ''::text NOT NULL, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.payment_settings OWNER TO supabase_admin; -- -- Name: plan_prices; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.plan_prices ( id uuid DEFAULT gen_random_uuid() NOT NULL, plan_id uuid NOT NULL, currency text DEFAULT 'BRL'::text NOT NULL, "interval" text NOT NULL, amount_cents integer NOT NULL, is_active boolean DEFAULT true NOT NULL, active_from timestamp with time zone DEFAULT now() NOT NULL, active_to timestamp with time zone, source text DEFAULT 'manual'::text NOT NULL, provider text, provider_price_id text, created_at timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT plan_prices_amount_cents_check CHECK ((amount_cents >= 0)), CONSTRAINT plan_prices_interval_check CHECK (("interval" = ANY (ARRAY['month'::text, 'year'::text]))) ); ALTER TABLE public.plan_prices OWNER TO supabase_admin; -- -- Name: TABLE plan_prices; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON TABLE public.plan_prices IS 'Histórico de preços por plano (fonte: manual/gateway).'; -- -- Name: plan_public; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.plan_public ( plan_id uuid NOT NULL, public_name text DEFAULT ''::text NOT NULL, public_description text DEFAULT ''::text NOT NULL, badge text, is_featured boolean DEFAULT false NOT NULL, is_visible boolean DEFAULT true NOT NULL, sort_order integer DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.plan_public OWNER TO supabase_admin; -- -- Name: TABLE plan_public; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON TABLE public.plan_public IS 'Configuração de vitrine (página pública) dos planos.'; -- -- Name: plan_public_bullets; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.plan_public_bullets ( id uuid DEFAULT gen_random_uuid() NOT NULL, plan_id uuid NOT NULL, text text NOT NULL, sort_order integer DEFAULT 0 NOT NULL, highlight boolean DEFAULT false NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.plan_public_bullets OWNER TO supabase_admin; -- -- Name: plans; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.plans ( id uuid DEFAULT gen_random_uuid() NOT NULL, key text NOT NULL, name text NOT NULL, description text, is_active boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, price_cents integer DEFAULT 0 NOT NULL, currency text DEFAULT 'BRL'::text NOT NULL, billing_interval text DEFAULT 'month'::text NOT NULL, target text, max_supervisees integer, CONSTRAINT plans_target_check CHECK ((target = ANY (ARRAY['patient'::text, 'therapist'::text, 'clinic'::text, 'supervisor'::text]))) ); ALTER TABLE public.plans OWNER TO supabase_admin; -- -- Name: COLUMN plans.name; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.plans.name IS 'Nome interno do plano (admin). A key é técnica/imutável.'; -- -- Name: COLUMN plans.target; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.plans.target IS 'Público-alvo do plano: patient, therapist ou clinic.'; -- -- Name: COLUMN plans.max_supervisees; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.plans.max_supervisees IS 'Limite de terapeutas que podem ser supervisionados. Apenas para planos target=supervisor. NULL = sem limite.'; -- -- Name: professional_pricing; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.professional_pricing ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid NOT NULL, determined_commitment_id uuid, price numeric(10,2) NOT NULL, notes text, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.professional_pricing OWNER TO supabase_admin; -- -- Name: TABLE professional_pricing; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON TABLE public.professional_pricing IS 'DEPRECATED: substituída por public.services. Manter até próxima release de limpeza.'; -- -- Name: profiles; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.profiles ( id uuid NOT NULL, role text DEFAULT 'tenant_member'::text NOT NULL, full_name text, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, avatar_url text, phone text, bio text, language text DEFAULT 'pt-BR'::text NOT NULL, timezone text DEFAULT 'America/Sao_Paulo'::text NOT NULL, notify_system_email boolean DEFAULT true NOT NULL, notify_reminders boolean DEFAULT true NOT NULL, notify_news boolean DEFAULT false NOT NULL, account_type text DEFAULT 'free'::text NOT NULL, platform_roles text[] DEFAULT '{}'::text[] NOT NULL, nickname text, work_description text, work_description_other text, site_url text, social_instagram text, social_youtube text, social_facebook text, social_x text, social_custom jsonb DEFAULT '[]'::jsonb NOT NULL, CONSTRAINT profiles_account_type_check CHECK ((account_type = ANY (ARRAY['free'::text, 'patient'::text, 'therapist'::text, 'clinic'::text]))), CONSTRAINT profiles_role_check CHECK ((role = ANY (ARRAY['saas_admin'::text, 'tenant_member'::text, 'portal_user'::text, 'patient'::text]))) ); ALTER TABLE public.profiles OWNER TO supabase_admin; -- -- Name: COLUMN profiles.phone; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.phone IS 'WhatsApp / telefone no formato (99) 99999-9999'; -- -- Name: COLUMN profiles.bio; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.bio IS 'Breve apresentação pública (máx 300 chars no front)'; -- -- Name: COLUMN profiles.account_type; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.account_type IS 'Tipo de conta: free=sem perfil ainda, patient=paciente (imutável), therapist=terapeuta (imutável), clinic=clínica (imutável).'; -- -- Name: COLUMN profiles.platform_roles; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.platform_roles IS 'Papéis globais de plataforma, independentes de tenant. Ex: editor de microlearning. Atribuído pelo saas_admin.'; -- -- Name: COLUMN profiles.nickname; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.nickname IS 'Apelido preferido para comunicação interna (Agência PSI)'; -- -- Name: COLUMN profiles.work_description; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.work_description IS 'Categoria de trabalho selecionada no perfil público'; -- -- Name: COLUMN profiles.work_description_other; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.work_description_other IS 'Descrição livre quando work_description = ''outro'''; -- -- Name: COLUMN profiles.site_url; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.site_url IS 'Endereço do site pessoal ou profissional'; -- -- Name: COLUMN profiles.social_instagram; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.social_instagram IS 'Handle ou URL do Instagram'; -- -- Name: COLUMN profiles.social_youtube; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.social_youtube IS 'Handle ou URL do canal no YouTube'; -- -- Name: COLUMN profiles.social_facebook; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.social_facebook IS 'Handle ou URL da página no Facebook'; -- -- Name: COLUMN profiles.social_x; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.social_x IS 'Handle ou URL do perfil no X (Twitter)'; -- -- Name: COLUMN profiles.social_custom; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.profiles.social_custom IS 'Array JSON com redes adicionais livres: [{name, url}]'; -- -- Name: recurrence_exceptions; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.recurrence_exceptions ( id uuid DEFAULT gen_random_uuid() NOT NULL, recurrence_id uuid NOT NULL, tenant_id uuid NOT NULL, original_date date NOT NULL, type public.recurrence_exception_type NOT NULL, new_date date, new_start_time time without time zone, new_end_time time without time zone, modalidade text, observacoes text, titulo_custom text, extra_fields jsonb, reason text, agenda_evento_id uuid, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.recurrence_exceptions OWNER TO supabase_admin; -- -- Name: recurrence_rule_services; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.recurrence_rule_services ( id uuid DEFAULT gen_random_uuid() NOT NULL, rule_id uuid NOT NULL, service_id uuid NOT NULL, quantity integer DEFAULT 1 NOT NULL, unit_price numeric(10,2) NOT NULL, discount_pct numeric(5,2) DEFAULT 0, discount_flat numeric(10,2) DEFAULT 0, final_price numeric(10,2) NOT NULL, created_at timestamp with time zone DEFAULT now(), CONSTRAINT recurrence_rule_services_disc_flat_chk CHECK ((discount_flat >= (0)::numeric)), CONSTRAINT recurrence_rule_services_disc_pct_chk CHECK (((discount_pct >= (0)::numeric) AND (discount_pct <= (100)::numeric))), CONSTRAINT recurrence_rule_services_final_price_chk CHECK ((final_price >= (0)::numeric)), CONSTRAINT recurrence_rule_services_quantity_chk CHECK ((quantity > 0)) ); ALTER TABLE public.recurrence_rule_services OWNER TO supabase_admin; -- -- Name: recurrence_rules; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.recurrence_rules ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, owner_id uuid NOT NULL, therapist_id uuid, patient_id uuid, determined_commitment_id uuid, type public.recurrence_type DEFAULT 'weekly'::public.recurrence_type NOT NULL, "interval" smallint DEFAULT 1 NOT NULL, weekdays smallint[] DEFAULT '{}'::smallint[] NOT NULL, start_time time without time zone NOT NULL, end_time time without time zone NOT NULL, timezone text DEFAULT 'America/Sao_Paulo'::text NOT NULL, duration_min smallint DEFAULT 50 NOT NULL, start_date date NOT NULL, end_date date, max_occurrences integer, open_ended boolean DEFAULT true NOT NULL, modalidade text DEFAULT 'presencial'::text, titulo_custom text, observacoes text, extra_fields jsonb, status text DEFAULT 'ativo'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, price numeric(10,2), insurance_plan_id uuid, insurance_guide_number text, insurance_value numeric(10,2), insurance_plan_service_id uuid, CONSTRAINT recurrence_rules_dates_chk CHECK (((end_date IS NULL) OR (end_date >= start_date))), CONSTRAINT recurrence_rules_interval_chk CHECK (("interval" >= 1)), CONSTRAINT recurrence_rules_status_check CHECK ((status = ANY (ARRAY['ativo'::text, 'pausado'::text, 'cancelado'::text]))), CONSTRAINT recurrence_rules_times_chk CHECK ((end_time > start_time)) ); ALTER TABLE public.recurrence_rules OWNER TO supabase_admin; -- -- Name: saas_admins; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.saas_admins ( user_id uuid NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.saas_admins OWNER TO supabase_admin; -- -- Name: saas_doc_votos; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.saas_doc_votos ( id uuid DEFAULT gen_random_uuid() NOT NULL, doc_id uuid NOT NULL, user_id uuid NOT NULL, util boolean NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.saas_doc_votos OWNER TO supabase_admin; -- -- Name: saas_docs; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.saas_docs ( id uuid DEFAULT gen_random_uuid() NOT NULL, titulo text NOT NULL, conteudo text DEFAULT ''::text NOT NULL, medias jsonb DEFAULT '[]'::jsonb NOT NULL, tipo_acesso text DEFAULT 'usuario'::text NOT NULL, pagina_path text NOT NULL, docs_relacionados uuid[] DEFAULT '{}'::uuid[] NOT NULL, ativo boolean DEFAULT true NOT NULL, ordem integer DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, categoria text, exibir_no_faq boolean DEFAULT false NOT NULL, votos_util integer DEFAULT 0 NOT NULL, votos_nao_util integer DEFAULT 0 NOT NULL, CONSTRAINT saas_docs_tipo_acesso_check CHECK ((tipo_acesso = ANY (ARRAY['admin'::text, 'usuario'::text]))) ); ALTER TABLE public.saas_docs OWNER TO supabase_admin; -- -- Name: COLUMN saas_docs.categoria; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.saas_docs.categoria IS 'Agrupa docs no portal FAQ (ex: Conta, Agenda, Pagamentos)'; -- -- Name: COLUMN saas_docs.exibir_no_faq; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.saas_docs.exibir_no_faq IS 'Se true, a doc e seus itens FAQ aparecem no portal de FAQ'; -- -- Name: saas_faq; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.saas_faq ( id uuid DEFAULT gen_random_uuid() NOT NULL, pergunta text NOT NULL, categoria text, publico boolean DEFAULT false NOT NULL, votos integer DEFAULT 0 NOT NULL, titulo text, conteudo text, tipo_acesso text DEFAULT 'usuario'::text NOT NULL, pagina_path text NOT NULL, pagina_label text, medias jsonb DEFAULT '[]'::jsonb NOT NULL, faqs_relacionados uuid[] DEFAULT '{}'::uuid[] NOT NULL, ativo boolean DEFAULT true NOT NULL, ordem integer DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.saas_faq OWNER TO supabase_admin; -- -- Name: saas_faq_itens; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.saas_faq_itens ( id uuid DEFAULT gen_random_uuid() NOT NULL, doc_id uuid NOT NULL, pergunta text NOT NULL, resposta text, ordem integer DEFAULT 0 NOT NULL, ativo boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.saas_faq_itens OWNER TO supabase_admin; -- -- Name: TABLE saas_faq_itens; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON TABLE public.saas_faq_itens IS 'Pares pergunta/resposta vinculados a um documento de ajuda'; -- -- Name: services; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.services ( id uuid DEFAULT gen_random_uuid() NOT NULL, owner_id uuid NOT NULL, tenant_id uuid NOT NULL, name text NOT NULL, description text, price numeric(10,2) NOT NULL, duration_min integer, active boolean DEFAULT true NOT NULL, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.services OWNER TO supabase_admin; -- -- Name: subscription_events; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.subscription_events ( id uuid DEFAULT gen_random_uuid() NOT NULL, subscription_id uuid NOT NULL, owner_id uuid NOT NULL, event_type text NOT NULL, old_plan_id uuid, new_plan_id uuid, created_at timestamp with time zone DEFAULT now() NOT NULL, created_by uuid, source text DEFAULT 'admin_ui'::text, reason text, metadata jsonb, owner_type text NOT NULL, owner_ref uuid NOT NULL, CONSTRAINT subscription_events_owner_ref_consistency_chk CHECK ((owner_id = owner_ref)), CONSTRAINT subscription_events_owner_type_chk CHECK (((owner_type IS NULL) OR (owner_type = ANY (ARRAY['clinic'::text, 'therapist'::text])))) ); ALTER TABLE public.subscription_events OWNER TO supabase_admin; -- -- Name: subscription_intents_personal; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.subscription_intents_personal ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid NOT NULL, created_by_user_id uuid, email text NOT NULL, plan_id uuid NOT NULL, plan_key text, "interval" text, amount_cents integer, currency text, status text DEFAULT 'new'::text NOT NULL, source text DEFAULT 'manual'::text NOT NULL, notes text, created_at timestamp with time zone DEFAULT now() NOT NULL, paid_at timestamp with time zone, subscription_id uuid, CONSTRAINT sint_personal_interval_check CHECK ((("interval" IS NULL) OR ("interval" = ANY (ARRAY['month'::text, 'year'::text])))), CONSTRAINT sint_personal_status_check CHECK ((status = ANY (ARRAY['new'::text, 'waiting_payment'::text, 'paid'::text, 'canceled'::text]))) ); ALTER TABLE public.subscription_intents_personal OWNER TO supabase_admin; -- -- Name: subscription_intents_tenant; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.subscription_intents_tenant ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid NOT NULL, created_by_user_id uuid, email text NOT NULL, plan_id uuid NOT NULL, plan_key text, "interval" text, amount_cents integer, currency text, status text DEFAULT 'new'::text NOT NULL, source text DEFAULT 'manual'::text NOT NULL, notes text, created_at timestamp with time zone DEFAULT now() NOT NULL, paid_at timestamp with time zone, tenant_id uuid NOT NULL, subscription_id uuid, CONSTRAINT sint_tenant_interval_check CHECK ((("interval" IS NULL) OR ("interval" = ANY (ARRAY['month'::text, 'year'::text])))), CONSTRAINT sint_tenant_status_check CHECK ((status = ANY (ARRAY['new'::text, 'waiting_payment'::text, 'paid'::text, 'canceled'::text]))) ); ALTER TABLE public.subscription_intents_tenant OWNER TO supabase_admin; -- -- Name: subscription_intents; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.subscription_intents AS SELECT t.id, t.user_id, t.created_by_user_id, t.email, t.plan_id, t.plan_key, t."interval", t.amount_cents, t.currency, t.status, t.source, t.notes, t.created_at, t.paid_at, t.tenant_id, t.subscription_id, 'clinic'::text AS plan_target FROM public.subscription_intents_tenant t UNION ALL SELECT p.id, p.user_id, p.created_by_user_id, p.email, p.plan_id, p.plan_key, p."interval", p.amount_cents, p.currency, p.status, p.source, p.notes, p.created_at, p.paid_at, NULL::uuid AS tenant_id, p.subscription_id, 'therapist'::text AS plan_target FROM public.subscription_intents_personal p; ALTER VIEW public.subscription_intents OWNER TO supabase_admin; -- -- Name: subscription_intents_legacy; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.subscription_intents_legacy ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid, email text, plan_key text NOT NULL, "interval" text NOT NULL, amount_cents integer NOT NULL, currency text DEFAULT 'BRL'::text NOT NULL, status text DEFAULT 'new'::text NOT NULL, source text DEFAULT 'landing'::text NOT NULL, notes text, created_at timestamp with time zone DEFAULT now() NOT NULL, paid_at timestamp with time zone, tenant_id uuid NOT NULL, created_by_user_id uuid, CONSTRAINT subscription_intents_interval_check CHECK (("interval" = ANY (ARRAY['month'::text, 'year'::text]))), CONSTRAINT subscription_intents_status_check CHECK ((status = ANY (ARRAY['new'::text, 'waiting_payment'::text, 'paid'::text, 'canceled'::text]))) ); ALTER TABLE public.subscription_intents_legacy OWNER TO supabase_admin; -- -- Name: support_sessions; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.support_sessions ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, admin_id uuid NOT NULL, token text DEFAULT encode(extensions.gen_random_bytes(32), 'hex'::text) NOT NULL, expires_at timestamp with time zone DEFAULT (now() + '01:00:00'::interval) NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.support_sessions OWNER TO supabase_admin; -- -- Name: tenant_feature_exceptions_log; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenant_feature_exceptions_log ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, feature_key text NOT NULL, enabled boolean NOT NULL, reason text, created_by uuid, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.tenant_feature_exceptions_log OWNER TO supabase_admin; -- -- Name: tenant_features; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenant_features ( tenant_id uuid NOT NULL, feature_key text NOT NULL, enabled boolean DEFAULT false NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE public.tenant_features OWNER TO supabase_admin; -- -- Name: tenant_invites; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenant_invites ( id uuid DEFAULT gen_random_uuid() NOT NULL, tenant_id uuid NOT NULL, email text NOT NULL, role text NOT NULL, token uuid DEFAULT gen_random_uuid() NOT NULL, invited_by uuid, created_at timestamp with time zone DEFAULT now() NOT NULL, expires_at timestamp with time zone DEFAULT (now() + '7 days'::interval) NOT NULL, accepted_at timestamp with time zone, accepted_by uuid, revoked_at timestamp with time zone, revoked_by uuid, CONSTRAINT tenant_invites_role_check CHECK ((role = ANY (ARRAY['therapist'::text, 'secretary'::text]))) ); ALTER TABLE public.tenant_invites OWNER TO supabase_admin; -- -- Name: tenants; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.tenants ( id uuid DEFAULT gen_random_uuid() NOT NULL, name text, created_at timestamp with time zone DEFAULT now() NOT NULL, kind text DEFAULT 'saas'::text NOT NULL, CONSTRAINT tenants_kind_check CHECK ((kind = ANY (ARRAY['therapist'::text, 'clinic_coworking'::text, 'clinic_reception'::text, 'clinic_full'::text, 'clinic'::text, 'saas'::text, 'supervisor'::text]))) ); ALTER TABLE public.tenants OWNER TO supabase_admin; -- -- Name: COLUMN tenants.kind; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.tenants.kind IS 'Tipo do tenant. Imutável após criação. therapist=terapeuta solo. clinic_coworking/clinic_reception/clinic_full=clínicas. clinic e saas são legados.'; -- -- Name: user_settings; Type: TABLE; Schema: public; Owner: supabase_admin -- CREATE TABLE public.user_settings ( user_id uuid NOT NULL, theme_mode text DEFAULT 'dark'::text NOT NULL, preset text DEFAULT 'Aura'::text NOT NULL, primary_color text DEFAULT 'noir'::text NOT NULL, surface_color text DEFAULT 'slate'::text NOT NULL, menu_mode text DEFAULT 'static'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, layout_variant text DEFAULT 'classic'::text NOT NULL, CONSTRAINT user_settings_layout_variant_check CHECK ((layout_variant = ANY (ARRAY['classic'::text, 'rail'::text]))), CONSTRAINT user_settings_menu_mode_check CHECK ((menu_mode = ANY (ARRAY['static'::text, 'overlay'::text]))), CONSTRAINT user_settings_theme_mode_check CHECK ((theme_mode = ANY (ARRAY['light'::text, 'dark'::text]))) ); ALTER TABLE public.user_settings OWNER TO supabase_admin; -- -- Name: TABLE user_settings; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON TABLE public.user_settings IS 'Preferências de aparência e layout por usuário'; -- -- Name: COLUMN user_settings.user_id; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.user_id IS 'FK = auth.users.id — um registro por usuário'; -- -- Name: COLUMN user_settings.theme_mode; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.theme_mode IS 'light | dark'; -- -- Name: COLUMN user_settings.preset; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.preset IS 'Preset PrimeVue: Aura | Lara | Nora'; -- -- Name: COLUMN user_settings.primary_color; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.primary_color IS 'Nome da cor primária (ex: blue, emerald, noir)'; -- -- Name: COLUMN user_settings.surface_color; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.surface_color IS 'Nome da surface (ex: slate, zinc, neutral)'; -- -- Name: COLUMN user_settings.menu_mode; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.menu_mode IS 'static | overlay'; -- -- Name: COLUMN user_settings.layout_variant; Type: COMMENT; Schema: public; Owner: supabase_admin -- COMMENT ON COLUMN public.user_settings.layout_variant IS 'classic (sidebar) | rail (mini rail + painel)'; -- -- Name: v_auth_users_public; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_auth_users_public AS SELECT id AS user_id, email, created_at, last_sign_in_at FROM auth.users u; ALTER VIEW public.v_auth_users_public OWNER TO supabase_admin; -- -- Name: v_commitment_totals; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_commitment_totals AS SELECT c.tenant_id, c.id AS commitment_id, (COALESCE(sum(l.minutes), (0)::bigint))::integer AS total_minutes FROM (public.determined_commitments c LEFT JOIN public.commitment_time_logs l ON ((l.commitment_id = c.id))) GROUP BY c.tenant_id, c.id; ALTER VIEW public.v_commitment_totals OWNER TO supabase_admin; -- -- Name: v_patient_groups_with_counts; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_patient_groups_with_counts AS SELECT pg.id, pg.nome, pg.cor, pg.owner_id, pg.is_system, pg.is_active, pg.created_at, pg.updated_at, (COALESCE(count(pgp.patient_id), (0)::bigint))::integer AS patients_count FROM (public.patient_groups pg LEFT JOIN public.patient_group_patient pgp ON ((pgp.patient_group_id = pg.id))) GROUP BY pg.id, pg.nome, pg.cor, pg.owner_id, pg.is_system, pg.is_active, pg.created_at, pg.updated_at; ALTER VIEW public.v_patient_groups_with_counts OWNER TO supabase_admin; -- -- Name: v_plan_active_prices; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_plan_active_prices AS SELECT plan_id, max( CASE WHEN (("interval" = 'month'::text) AND is_active) THEN amount_cents ELSE NULL::integer END) AS monthly_cents, max( CASE WHEN (("interval" = 'year'::text) AND is_active) THEN amount_cents ELSE NULL::integer END) AS yearly_cents, max( CASE WHEN (("interval" = 'month'::text) AND is_active) THEN currency ELSE NULL::text END) AS monthly_currency, max( CASE WHEN (("interval" = 'year'::text) AND is_active) THEN currency ELSE NULL::text END) AS yearly_currency FROM public.plan_prices GROUP BY plan_id; ALTER VIEW public.v_plan_active_prices OWNER TO supabase_admin; -- -- Name: v_public_pricing; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_public_pricing AS SELECT p.id AS plan_id, p.key AS plan_key, p.name AS plan_name, COALESCE(pp.public_name, ''::text) AS public_name, COALESCE(pp.public_description, ''::text) AS public_description, pp.badge, COALESCE(pp.is_featured, false) AS is_featured, COALESCE(pp.is_visible, true) AS is_visible, COALESCE(pp.sort_order, 0) AS sort_order, ap.monthly_cents, ap.yearly_cents, ap.monthly_currency, ap.yearly_currency, COALESCE(( SELECT jsonb_agg(jsonb_build_object('id', b.id, 'text', b.text, 'highlight', b.highlight, 'sort_order', b.sort_order) ORDER BY b.sort_order, b.created_at) AS jsonb_agg FROM public.plan_public_bullets b WHERE (b.plan_id = p.id)), '[]'::jsonb) AS bullets, p.target AS plan_target FROM ((public.plans p LEFT JOIN public.plan_public pp ON ((pp.plan_id = p.id))) LEFT JOIN public.v_plan_active_prices ap ON ((ap.plan_id = p.id))) ORDER BY COALESCE(pp.sort_order, 0), p.key; ALTER VIEW public.v_public_pricing OWNER TO supabase_admin; -- -- Name: v_subscription_feature_mismatch; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_subscription_feature_mismatch AS WITH expected AS ( SELECT s.user_id AS owner_id, f.key AS feature_key FROM ((public.subscriptions s JOIN public.plan_features pf ON (((pf.plan_id = s.plan_id) AND (pf.enabled = true)))) JOIN public.features f ON ((f.id = pf.feature_id))) WHERE ((s.status = 'active'::text) AND (s.tenant_id IS NULL) AND (s.user_id IS NOT NULL)) ), actual AS ( SELECT e.owner_id, e.feature_key FROM public.owner_feature_entitlements e ) SELECT COALESCE(expected.owner_id, actual.owner_id) AS owner_id, COALESCE(expected.feature_key, actual.feature_key) AS feature_key, CASE WHEN ((expected.feature_key IS NOT NULL) AND (actual.feature_key IS NULL)) THEN 'missing_entitlement'::text WHEN ((expected.feature_key IS NULL) AND (actual.feature_key IS NOT NULL)) THEN 'unexpected_entitlement'::text ELSE NULL::text END AS mismatch_type FROM (expected FULL JOIN actual ON (((expected.owner_id = actual.owner_id) AND (expected.feature_key = actual.feature_key)))) WHERE ((expected.feature_key IS NULL) OR (actual.feature_key IS NULL)); ALTER VIEW public.v_subscription_feature_mismatch OWNER TO supabase_admin; -- -- Name: v_subscription_health; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_subscription_health AS SELECT s.id AS subscription_id, s.user_id AS owner_id, s.status, s.plan_id, p.key AS plan_key, s.current_period_start, s.current_period_end, s.updated_at, CASE WHEN (s.plan_id IS NULL) THEN 'missing_plan'::text WHEN (p.id IS NULL) THEN 'invalid_plan'::text WHEN ((s.status = 'active'::text) AND (s.current_period_end IS NOT NULL) AND (s.current_period_end < now())) THEN 'expired_but_active'::text WHEN ((s.status = 'canceled'::text) AND (s.current_period_end > now())) THEN 'canceled_but_still_in_period'::text ELSE 'ok'::text END AS health_status, CASE WHEN (s.tenant_id IS NOT NULL) THEN 'clinic'::text ELSE 'therapist'::text END AS owner_type, COALESCE(s.tenant_id, s.user_id) AS owner_ref FROM (public.subscriptions s LEFT JOIN public.plans p ON ((p.id = s.plan_id))); ALTER VIEW public.v_subscription_health OWNER TO supabase_admin; -- -- Name: v_subscription_health_v2; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_subscription_health_v2 AS SELECT s.id AS subscription_id, s.user_id AS owner_id, CASE WHEN (s.tenant_id IS NOT NULL) THEN 'clinic'::text ELSE 'therapist'::text END AS owner_type, COALESCE(s.tenant_id, s.user_id) AS owner_ref, s.status, s.plan_id, p.key AS plan_key, s.current_period_start, s.current_period_end, s.updated_at, CASE WHEN (s.plan_id IS NULL) THEN 'missing_plan'::text WHEN (p.id IS NULL) THEN 'invalid_plan'::text WHEN ((s.status = 'active'::text) AND (s.current_period_end IS NOT NULL) AND (s.current_period_end < now())) THEN 'expired_but_active'::text WHEN ((s.status = 'canceled'::text) AND (s.current_period_end > now())) THEN 'canceled_but_still_in_period'::text ELSE 'ok'::text END AS health_status FROM (public.subscriptions s LEFT JOIN public.plans p ON ((p.id = s.plan_id))); ALTER VIEW public.v_subscription_health_v2 OWNER TO supabase_admin; -- -- Name: v_tag_patient_counts; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tag_patient_counts AS SELECT t.id, t.owner_id, t.nome, t.cor, t.is_padrao, t.created_at, t.updated_at, (COALESCE(count(ppt.patient_id), (0)::bigint))::integer AS pacientes_count, (COALESCE(count(ppt.patient_id), (0)::bigint))::integer AS patient_count FROM (public.patient_tags t LEFT JOIN public.patient_patient_tag ppt ON (((ppt.tag_id = t.id) AND (ppt.owner_id = t.owner_id)))) GROUP BY t.id, t.owner_id, t.nome, t.cor, t.is_padrao, t.created_at, t.updated_at; ALTER VIEW public.v_tag_patient_counts OWNER TO supabase_admin; -- -- Name: v_tenant_active_subscription; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_active_subscription AS SELECT DISTINCT ON (tenant_id) tenant_id, plan_id, plan_key, "interval", status, current_period_start, current_period_end, created_at FROM public.subscriptions s WHERE ((tenant_id IS NOT NULL) AND (status = 'active'::text) AND ((current_period_end IS NULL) OR (current_period_end > now()))) ORDER BY tenant_id, created_at DESC; ALTER VIEW public.v_tenant_active_subscription OWNER TO supabase_admin; -- -- Name: v_tenant_entitlements; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_entitlements AS SELECT a.tenant_id, f.key AS feature_key, true AS allowed FROM ((public.v_tenant_active_subscription a JOIN public.plan_features pf ON (((pf.plan_id = a.plan_id) AND (pf.enabled = true)))) JOIN public.features f ON ((f.id = pf.feature_id))); ALTER VIEW public.v_tenant_entitlements OWNER TO supabase_admin; -- -- Name: v_tenant_entitlements_full; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_entitlements_full AS SELECT a.tenant_id, f.key AS feature_key, (pf.enabled = true) AS allowed, pf.limits, a.plan_id, p.key AS plan_key FROM (((public.v_tenant_active_subscription a JOIN public.plan_features pf ON ((pf.plan_id = a.plan_id))) JOIN public.features f ON ((f.id = pf.feature_id))) JOIN public.plans p ON ((p.id = a.plan_id))); ALTER VIEW public.v_tenant_entitlements_full OWNER TO supabase_admin; -- -- Name: v_tenant_entitlements_json; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_entitlements_json AS SELECT tenant_id, max(plan_key) AS plan_key, jsonb_object_agg(feature_key, jsonb_build_object('allowed', allowed, 'limits', COALESCE(limits, '{}'::jsonb)) ORDER BY feature_key) AS entitlements FROM public.v_tenant_entitlements_full GROUP BY tenant_id; ALTER VIEW public.v_tenant_entitlements_json OWNER TO supabase_admin; -- -- Name: v_tenant_feature_exceptions; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_feature_exceptions AS SELECT tf.tenant_id, a.plan_key, tf.feature_key, 'commercial_exception'::text AS exception_type FROM ((public.tenant_features tf JOIN public.v_tenant_active_subscription a ON ((a.tenant_id = tf.tenant_id))) LEFT JOIN public.v_tenant_entitlements_full v ON (((v.tenant_id = tf.tenant_id) AND (v.feature_key = tf.feature_key)))) WHERE ((tf.enabled = true) AND (COALESCE(v.allowed, false) = false)); ALTER VIEW public.v_tenant_feature_exceptions OWNER TO supabase_admin; -- -- Name: v_tenant_feature_mismatch; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_feature_mismatch AS WITH plan_allowed AS ( SELECT v.tenant_id, v.feature_key, v.allowed FROM public.v_tenant_entitlements_full v ), overrides AS ( SELECT tf.tenant_id, tf.feature_key, tf.enabled FROM public.tenant_features tf ) SELECT o.tenant_id, o.feature_key, CASE WHEN ((o.enabled = true) AND (COALESCE(p.allowed, false) = false)) THEN 'unexpected_override'::text ELSE NULL::text END AS mismatch_type FROM (overrides o LEFT JOIN plan_allowed p ON (((p.tenant_id = o.tenant_id) AND (p.feature_key = o.feature_key)))) WHERE ((o.enabled = true) AND (COALESCE(p.allowed, false) = false)); ALTER VIEW public.v_tenant_feature_mismatch OWNER TO supabase_admin; -- -- Name: v_tenant_members_with_profiles; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_members_with_profiles AS SELECT tm.id AS tenant_member_id, tm.tenant_id, tm.user_id, tm.role, tm.status, tm.created_at, p.full_name, au.email FROM ((public.tenant_members tm LEFT JOIN public.profiles p ON ((p.id = tm.user_id))) LEFT JOIN auth.users au ON ((au.id = tm.user_id))); ALTER VIEW public.v_tenant_members_with_profiles OWNER TO supabase_admin; -- -- Name: v_tenant_people; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_people AS SELECT 'member'::text AS type, m.tenant_id, m.user_id, u.email, m.role, m.status, NULL::uuid AS invite_token, NULL::timestamp with time zone AS expires_at FROM (public.tenant_members m JOIN auth.users u ON ((u.id = m.user_id))) UNION ALL SELECT 'invite'::text AS type, i.tenant_id, NULL::uuid AS user_id, i.email, i.role, 'invited'::text AS status, i.token AS invite_token, i.expires_at FROM public.tenant_invites i WHERE ((i.accepted_at IS NULL) AND (i.revoked_at IS NULL)); ALTER VIEW public.v_tenant_people OWNER TO supabase_admin; -- -- Name: v_tenant_staff; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_tenant_staff AS SELECT ('m_'::text || (tm.id)::text) AS row_id, tm.tenant_id, tm.user_id, tm.role, tm.status, tm.created_at, p.full_name, au.email, NULL::uuid AS invite_token FROM ((public.tenant_members tm LEFT JOIN public.profiles p ON ((p.id = tm.user_id))) LEFT JOIN auth.users au ON ((au.id = tm.user_id))) UNION ALL SELECT ('i_'::text || (ti.id)::text) AS row_id, ti.tenant_id, NULL::uuid AS user_id, ti.role, 'invited'::text AS status, ti.created_at, NULL::text AS full_name, ti.email, ti.token AS invite_token FROM public.tenant_invites ti WHERE ((ti.accepted_at IS NULL) AND (ti.revoked_at IS NULL) AND (ti.expires_at > now())); ALTER VIEW public.v_tenant_staff OWNER TO supabase_admin; -- -- Name: v_user_active_subscription; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_user_active_subscription AS SELECT DISTINCT ON (user_id) user_id, plan_id, plan_key, "interval", status, current_period_start, current_period_end, created_at FROM public.subscriptions s WHERE ((tenant_id IS NULL) AND (user_id IS NOT NULL) AND (status = 'active'::text) AND ((current_period_end IS NULL) OR (current_period_end > now()))) ORDER BY user_id, created_at DESC; ALTER VIEW public.v_user_active_subscription OWNER TO supabase_admin; -- -- Name: v_user_entitlements; Type: VIEW; Schema: public; Owner: supabase_admin -- CREATE VIEW public.v_user_entitlements AS SELECT a.user_id, f.key AS feature_key, true AS allowed FROM ((public.v_user_active_subscription a JOIN public.plan_features pf ON (((pf.plan_id = a.plan_id) AND (pf.enabled = true)))) JOIN public.features f ON ((f.id = pf.feature_id))); ALTER VIEW public.v_user_entitlements OWNER TO supabase_admin; -- -- Name: messages; Type: TABLE; Schema: realtime; Owner: supabase_realtime_admin -- CREATE TABLE realtime.messages ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ) PARTITION BY RANGE (inserted_at); ALTER TABLE realtime.messages OWNER TO supabase_realtime_admin; -- -- Name: messages_2026_03_12; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_12 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_12 OWNER TO supabase_admin; -- -- Name: messages_2026_03_13; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_13 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_13 OWNER TO supabase_admin; -- -- Name: messages_2026_03_14; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_14 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_14 OWNER TO supabase_admin; -- -- Name: messages_2026_03_15; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_15 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_15 OWNER TO supabase_admin; -- -- Name: messages_2026_03_16; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_16 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_16 OWNER TO supabase_admin; -- -- Name: messages_2026_03_17; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_17 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_17 OWNER TO supabase_admin; -- -- Name: messages_2026_03_18; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.messages_2026_03_18 ( topic text NOT NULL, extension text NOT NULL, payload jsonb, event text, private boolean DEFAULT false, updated_at timestamp without time zone DEFAULT now() NOT NULL, inserted_at timestamp without time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE realtime.messages_2026_03_18 OWNER TO supabase_admin; -- -- Name: schema_migrations; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.schema_migrations ( version bigint NOT NULL, inserted_at timestamp(0) without time zone ); ALTER TABLE realtime.schema_migrations OWNER TO supabase_admin; -- -- Name: subscription; Type: TABLE; Schema: realtime; Owner: supabase_admin -- CREATE TABLE realtime.subscription ( id bigint NOT NULL, subscription_id uuid NOT NULL, entity regclass NOT NULL, filters realtime.user_defined_filter[] DEFAULT '{}'::realtime.user_defined_filter[] NOT NULL, claims jsonb NOT NULL, claims_role regrole GENERATED ALWAYS AS (realtime.to_regrole((claims ->> 'role'::text))) STORED NOT NULL, created_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL ); ALTER TABLE realtime.subscription OWNER TO supabase_admin; -- -- Name: subscription_id_seq; Type: SEQUENCE; Schema: realtime; Owner: supabase_admin -- ALTER TABLE realtime.subscription ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( SEQUENCE NAME realtime.subscription_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1 ); -- -- Name: buckets; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.buckets ( id text NOT NULL, name text NOT NULL, owner uuid, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now(), public boolean DEFAULT false, avif_autodetection boolean DEFAULT false, file_size_limit bigint, allowed_mime_types text[], owner_id text, type storage.buckettype DEFAULT 'STANDARD'::storage.buckettype NOT NULL ); ALTER TABLE storage.buckets OWNER TO supabase_storage_admin; -- -- Name: COLUMN buckets.owner; Type: COMMENT; Schema: storage; Owner: supabase_storage_admin -- COMMENT ON COLUMN storage.buckets.owner IS 'Field is deprecated, use owner_id instead'; -- -- Name: buckets_analytics; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.buckets_analytics ( name text NOT NULL, type storage.buckettype DEFAULT 'ANALYTICS'::storage.buckettype NOT NULL, format text DEFAULT 'ICEBERG'::text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL, deleted_at timestamp with time zone ); ALTER TABLE storage.buckets_analytics OWNER TO supabase_storage_admin; -- -- Name: buckets_vectors; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.buckets_vectors ( id text NOT NULL, type storage.buckettype DEFAULT 'VECTOR'::storage.buckettype NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE storage.buckets_vectors OWNER TO supabase_storage_admin; -- -- Name: iceberg_namespaces; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.iceberg_namespaces ( id uuid DEFAULT gen_random_uuid() NOT NULL, bucket_name text NOT NULL, name text NOT NULL COLLATE pg_catalog."C", created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, metadata jsonb DEFAULT '{}'::jsonb NOT NULL, catalog_id uuid NOT NULL ); ALTER TABLE storage.iceberg_namespaces OWNER TO supabase_storage_admin; -- -- Name: iceberg_tables; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.iceberg_tables ( id uuid DEFAULT gen_random_uuid() NOT NULL, namespace_id uuid NOT NULL, bucket_name text NOT NULL, name text NOT NULL COLLATE pg_catalog."C", location text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, remote_table_id text, shard_key text, shard_id text, catalog_id uuid NOT NULL ); ALTER TABLE storage.iceberg_tables OWNER TO supabase_storage_admin; -- -- Name: migrations; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.migrations ( id integer NOT NULL, name character varying(100) NOT NULL, hash character varying(40) NOT NULL, executed_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE storage.migrations OWNER TO supabase_storage_admin; -- -- Name: objects; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.objects ( id uuid DEFAULT gen_random_uuid() NOT NULL, bucket_id text, name text, owner uuid, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now(), last_accessed_at timestamp with time zone DEFAULT now(), metadata jsonb, path_tokens text[] GENERATED ALWAYS AS (string_to_array(name, '/'::text)) STORED, version text, owner_id text, user_metadata jsonb ); ALTER TABLE storage.objects OWNER TO supabase_storage_admin; -- -- Name: COLUMN objects.owner; Type: COMMENT; Schema: storage; Owner: supabase_storage_admin -- COMMENT ON COLUMN storage.objects.owner IS 'Field is deprecated, use owner_id instead'; -- -- Name: s3_multipart_uploads; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.s3_multipart_uploads ( id text NOT NULL, in_progress_size bigint DEFAULT 0 NOT NULL, upload_signature text NOT NULL, bucket_id text NOT NULL, key text NOT NULL COLLATE pg_catalog."C", version text NOT NULL, owner_id text, created_at timestamp with time zone DEFAULT now() NOT NULL, user_metadata jsonb ); ALTER TABLE storage.s3_multipart_uploads OWNER TO supabase_storage_admin; -- -- Name: s3_multipart_uploads_parts; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.s3_multipart_uploads_parts ( id uuid DEFAULT gen_random_uuid() NOT NULL, upload_id text NOT NULL, size bigint DEFAULT 0 NOT NULL, part_number integer NOT NULL, bucket_id text NOT NULL, key text NOT NULL COLLATE pg_catalog."C", etag text NOT NULL, owner_id text, version text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE storage.s3_multipart_uploads_parts OWNER TO supabase_storage_admin; -- -- Name: vector_indexes; Type: TABLE; Schema: storage; Owner: supabase_storage_admin -- CREATE TABLE storage.vector_indexes ( id text DEFAULT gen_random_uuid() NOT NULL, name text NOT NULL COLLATE pg_catalog."C", bucket_id text NOT NULL, data_type text NOT NULL, dimension integer NOT NULL, distance_metric text NOT NULL, metadata_configuration jsonb, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE storage.vector_indexes OWNER TO supabase_storage_admin; -- -- Name: hooks; Type: TABLE; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE TABLE supabase_functions.hooks ( id bigint NOT NULL, hook_table_id integer NOT NULL, hook_name text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, request_id bigint ); ALTER TABLE supabase_functions.hooks OWNER TO supabase_functions_admin; -- -- Name: TABLE hooks; Type: COMMENT; Schema: supabase_functions; Owner: supabase_functions_admin -- COMMENT ON TABLE supabase_functions.hooks IS 'Supabase Functions Hooks: Audit trail for triggered hooks.'; -- -- Name: hooks_id_seq; Type: SEQUENCE; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE SEQUENCE supabase_functions.hooks_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE supabase_functions.hooks_id_seq OWNER TO supabase_functions_admin; -- -- Name: hooks_id_seq; Type: SEQUENCE OWNED BY; Schema: supabase_functions; Owner: supabase_functions_admin -- ALTER SEQUENCE supabase_functions.hooks_id_seq OWNED BY supabase_functions.hooks.id; -- -- Name: migrations; Type: TABLE; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE TABLE supabase_functions.migrations ( version text NOT NULL, inserted_at timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE supabase_functions.migrations OWNER TO supabase_functions_admin; -- -- Name: messages_2026_03_12; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_12 FOR VALUES FROM ('2026-03-12 00:00:00') TO ('2026-03-13 00:00:00'); -- -- Name: messages_2026_03_13; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_13 FOR VALUES FROM ('2026-03-13 00:00:00') TO ('2026-03-14 00:00:00'); -- -- Name: messages_2026_03_14; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_14 FOR VALUES FROM ('2026-03-14 00:00:00') TO ('2026-03-15 00:00:00'); -- -- Name: messages_2026_03_15; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_15 FOR VALUES FROM ('2026-03-15 00:00:00') TO ('2026-03-16 00:00:00'); -- -- Name: messages_2026_03_16; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_16 FOR VALUES FROM ('2026-03-16 00:00:00') TO ('2026-03-17 00:00:00'); -- -- Name: messages_2026_03_17; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_17 FOR VALUES FROM ('2026-03-17 00:00:00') TO ('2026-03-18 00:00:00'); -- -- Name: messages_2026_03_18; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_03_18 FOR VALUES FROM ('2026-03-18 00:00:00') TO ('2026-03-19 00:00:00'); -- -- Name: refresh_tokens id; Type: DEFAULT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.refresh_tokens ALTER COLUMN id SET DEFAULT nextval('auth.refresh_tokens_id_seq'::regclass); -- -- Name: agenda_online_slots id; Type: DEFAULT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_online_slots ALTER COLUMN id SET DEFAULT nextval('public.agenda_online_slots_id_seq'::regclass); -- -- Name: hooks id; Type: DEFAULT; Schema: supabase_functions; Owner: supabase_functions_admin -- ALTER TABLE ONLY supabase_functions.hooks ALTER COLUMN id SET DEFAULT nextval('supabase_functions.hooks_id_seq'::regclass); -- -- Name: extensions extensions_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin -- ALTER TABLE ONLY _realtime.extensions ADD CONSTRAINT extensions_pkey PRIMARY KEY (id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin -- ALTER TABLE ONLY _realtime.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: tenants tenants_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin -- ALTER TABLE ONLY _realtime.tenants ADD CONSTRAINT tenants_pkey PRIMARY KEY (id); -- -- Name: mfa_amr_claims amr_id_pk; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_amr_claims ADD CONSTRAINT amr_id_pk PRIMARY KEY (id); -- -- Name: audit_log_entries audit_log_entries_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.audit_log_entries ADD CONSTRAINT audit_log_entries_pkey PRIMARY KEY (id); -- -- Name: flow_state flow_state_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.flow_state ADD CONSTRAINT flow_state_pkey PRIMARY KEY (id); -- -- Name: identities identities_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.identities ADD CONSTRAINT identities_pkey PRIMARY KEY (id); -- -- Name: identities identities_provider_id_provider_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.identities ADD CONSTRAINT identities_provider_id_provider_unique UNIQUE (provider_id, provider); -- -- Name: instances instances_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.instances ADD CONSTRAINT instances_pkey PRIMARY KEY (id); -- -- Name: mfa_amr_claims mfa_amr_claims_session_id_authentication_method_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_amr_claims ADD CONSTRAINT mfa_amr_claims_session_id_authentication_method_pkey UNIQUE (session_id, authentication_method); -- -- Name: mfa_challenges mfa_challenges_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_challenges ADD CONSTRAINT mfa_challenges_pkey PRIMARY KEY (id); -- -- Name: mfa_factors mfa_factors_last_challenged_at_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_factors ADD CONSTRAINT mfa_factors_last_challenged_at_key UNIQUE (last_challenged_at); -- -- Name: mfa_factors mfa_factors_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_factors ADD CONSTRAINT mfa_factors_pkey PRIMARY KEY (id); -- -- Name: oauth_authorizations oauth_authorizations_authorization_code_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_authorizations ADD CONSTRAINT oauth_authorizations_authorization_code_key UNIQUE (authorization_code); -- -- Name: oauth_authorizations oauth_authorizations_authorization_id_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_authorizations ADD CONSTRAINT oauth_authorizations_authorization_id_key UNIQUE (authorization_id); -- -- Name: oauth_authorizations oauth_authorizations_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_authorizations ADD CONSTRAINT oauth_authorizations_pkey PRIMARY KEY (id); -- -- Name: oauth_client_states oauth_client_states_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_client_states ADD CONSTRAINT oauth_client_states_pkey PRIMARY KEY (id); -- -- Name: oauth_clients oauth_clients_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_clients ADD CONSTRAINT oauth_clients_pkey PRIMARY KEY (id); -- -- Name: oauth_consents oauth_consents_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_consents ADD CONSTRAINT oauth_consents_pkey PRIMARY KEY (id); -- -- Name: oauth_consents oauth_consents_user_client_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_consents ADD CONSTRAINT oauth_consents_user_client_unique UNIQUE (user_id, client_id); -- -- Name: one_time_tokens one_time_tokens_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.one_time_tokens ADD CONSTRAINT one_time_tokens_pkey PRIMARY KEY (id); -- -- Name: refresh_tokens refresh_tokens_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.refresh_tokens ADD CONSTRAINT refresh_tokens_pkey PRIMARY KEY (id); -- -- Name: refresh_tokens refresh_tokens_token_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.refresh_tokens ADD CONSTRAINT refresh_tokens_token_unique UNIQUE (token); -- -- Name: saml_providers saml_providers_entity_id_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_providers ADD CONSTRAINT saml_providers_entity_id_key UNIQUE (entity_id); -- -- Name: saml_providers saml_providers_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_providers ADD CONSTRAINT saml_providers_pkey PRIMARY KEY (id); -- -- Name: saml_relay_states saml_relay_states_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_relay_states ADD CONSTRAINT saml_relay_states_pkey PRIMARY KEY (id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sessions ADD CONSTRAINT sessions_pkey PRIMARY KEY (id); -- -- Name: sso_domains sso_domains_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sso_domains ADD CONSTRAINT sso_domains_pkey PRIMARY KEY (id); -- -- Name: sso_providers sso_providers_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sso_providers ADD CONSTRAINT sso_providers_pkey PRIMARY KEY (id); -- -- Name: users users_phone_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.users ADD CONSTRAINT users_phone_key UNIQUE (phone); -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- -- Name: agenda_bloqueios agenda_bloqueios_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_bloqueios ADD CONSTRAINT agenda_bloqueios_pkey PRIMARY KEY (id); -- -- Name: agenda_configuracoes agenda_configuracoes_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_configuracoes ADD CONSTRAINT agenda_configuracoes_pkey PRIMARY KEY (owner_id); -- -- Name: agenda_eventos agenda_eventos_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_pkey PRIMARY KEY (id); -- -- Name: agenda_eventos agenda_eventos_sem_sobreposicao; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_sem_sobreposicao EXCLUDE USING gist (owner_id WITH =, tstzrange(inicio_em, fim_em, '[)'::text) WITH &&); -- -- Name: agenda_excecoes agenda_excecoes_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_excecoes ADD CONSTRAINT agenda_excecoes_pkey PRIMARY KEY (id); -- -- Name: agenda_online_slots agenda_online_slots_owner_id_weekday_time_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_online_slots ADD CONSTRAINT agenda_online_slots_owner_id_weekday_time_key UNIQUE (owner_id, weekday, "time"); -- -- Name: agenda_online_slots agenda_online_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_online_slots ADD CONSTRAINT agenda_online_slots_pkey PRIMARY KEY (id); -- -- Name: agenda_regras_semanais agenda_regras_semanais_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_regras_semanais ADD CONSTRAINT agenda_regras_semanais_pkey PRIMARY KEY (id); -- -- Name: agenda_regras_semanais agenda_regras_semanais_unique; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_regras_semanais ADD CONSTRAINT agenda_regras_semanais_unique UNIQUE (owner_id, dia_semana, hora_inicio, hora_fim, modalidade); -- -- Name: agenda_slots_bloqueados_semanais agenda_slots_bloqueados_seman_owner_id_dia_semana_hora_inic_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_bloqueados_semanais ADD CONSTRAINT agenda_slots_bloqueados_seman_owner_id_dia_semana_hora_inic_key UNIQUE (owner_id, dia_semana, hora_inicio); -- -- Name: agenda_slots_bloqueados_semanais agenda_slots_bloqueados_semanais_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_bloqueados_semanais ADD CONSTRAINT agenda_slots_bloqueados_semanais_pkey PRIMARY KEY (id); -- -- Name: agenda_slots_regras agenda_slots_regras_owner_id_dia_semana_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_regras ADD CONSTRAINT agenda_slots_regras_owner_id_dia_semana_key UNIQUE (owner_id, dia_semana); -- -- Name: agenda_slots_regras agenda_slots_regras_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_regras ADD CONSTRAINT agenda_slots_regras_pkey PRIMARY KEY (id); -- -- Name: agendador_configuracoes agendador_configuracoes_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_configuracoes ADD CONSTRAINT agendador_configuracoes_pkey PRIMARY KEY (owner_id); -- -- Name: agendador_solicitacoes agendador_solicitacoes_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_solicitacoes ADD CONSTRAINT agendador_solicitacoes_pkey PRIMARY KEY (id); -- -- Name: billing_contracts billing_contracts_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.billing_contracts ADD CONSTRAINT billing_contracts_pkey PRIMARY KEY (id); -- -- Name: commitment_services commitment_services_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_services ADD CONSTRAINT commitment_services_pkey PRIMARY KEY (id); -- -- Name: commitment_time_logs commitment_time_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_time_logs ADD CONSTRAINT commitment_time_logs_pkey PRIMARY KEY (id); -- -- Name: determined_commitment_fields determined_commitment_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitment_fields ADD CONSTRAINT determined_commitment_fields_pkey PRIMARY KEY (id); -- -- Name: determined_commitments determined_commitments_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitments ADD CONSTRAINT determined_commitments_pkey PRIMARY KEY (id); -- -- Name: determined_commitments determined_commitments_tenant_native_key_uq; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitments ADD CONSTRAINT determined_commitments_tenant_native_key_uq UNIQUE (tenant_id, native_key); -- -- Name: dev_user_credentials dev_user_credentials_email_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.dev_user_credentials ADD CONSTRAINT dev_user_credentials_email_key UNIQUE (email); -- -- Name: dev_user_credentials dev_user_credentials_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.dev_user_credentials ADD CONSTRAINT dev_user_credentials_pkey PRIMARY KEY (id); -- -- Name: entitlements_invalidation entitlements_invalidation_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.entitlements_invalidation ADD CONSTRAINT entitlements_invalidation_pkey PRIMARY KEY (owner_id); -- -- Name: features features_key_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.features ADD CONSTRAINT features_key_key UNIQUE (key); -- -- Name: features features_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.features ADD CONSTRAINT features_pkey PRIMARY KEY (id); -- -- Name: feriados feriados_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.feriados ADD CONSTRAINT feriados_pkey PRIMARY KEY (id); -- -- Name: feriados feriados_tenant_id_data_nome_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.feriados ADD CONSTRAINT feriados_tenant_id_data_nome_key UNIQUE (tenant_id, data, nome); -- -- Name: financial_exceptions financial_exceptions_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.financial_exceptions ADD CONSTRAINT financial_exceptions_pkey PRIMARY KEY (id); -- -- Name: insurance_plan_services insurance_plan_services_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.insurance_plan_services ADD CONSTRAINT insurance_plan_services_pkey PRIMARY KEY (id); -- -- Name: insurance_plans insurance_plans_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.insurance_plans ADD CONSTRAINT insurance_plans_pkey PRIMARY KEY (id); -- -- Name: module_features module_features_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.module_features ADD CONSTRAINT module_features_pkey PRIMARY KEY (module_id, feature_id); -- -- Name: modules modules_key_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.modules ADD CONSTRAINT modules_key_key UNIQUE (key); -- -- Name: modules modules_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.modules ADD CONSTRAINT modules_pkey PRIMARY KEY (id); -- -- Name: owner_users owner_users_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.owner_users ADD CONSTRAINT owner_users_pkey PRIMARY KEY (owner_id, user_id); -- -- Name: patient_discounts patient_discounts_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_discounts ADD CONSTRAINT patient_discounts_pkey PRIMARY KEY (id); -- -- Name: patient_group_patient patient_group_patient_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_group_patient ADD CONSTRAINT patient_group_patient_pkey PRIMARY KEY (patient_group_id, patient_id); -- -- Name: patient_groups patient_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_groups ADD CONSTRAINT patient_groups_pkey PRIMARY KEY (id); -- -- Name: patient_intake_requests patient_intake_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_intake_requests ADD CONSTRAINT patient_intake_requests_pkey PRIMARY KEY (id); -- -- Name: patient_invites patient_invites_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_invites ADD CONSTRAINT patient_invites_pkey PRIMARY KEY (id); -- -- Name: patient_invites patient_invites_token_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_invites ADD CONSTRAINT patient_invites_token_key UNIQUE (token); -- -- Name: patient_patient_tag patient_patient_tag_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_patient_tag ADD CONSTRAINT patient_patient_tag_pkey PRIMARY KEY (patient_id, tag_id); -- -- Name: patient_tags patient_tags_owner_name_uniq; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_tags ADD CONSTRAINT patient_tags_owner_name_uniq UNIQUE (owner_id, nome); -- -- Name: patient_tags patient_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_tags ADD CONSTRAINT patient_tags_pkey PRIMARY KEY (id); -- -- Name: patients patients_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patients ADD CONSTRAINT patients_pkey PRIMARY KEY (id); -- -- Name: payment_settings payment_settings_owner_id_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.payment_settings ADD CONSTRAINT payment_settings_owner_id_key UNIQUE (owner_id); -- -- Name: payment_settings payment_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.payment_settings ADD CONSTRAINT payment_settings_pkey PRIMARY KEY (id); -- -- Name: plan_features plan_features_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_features ADD CONSTRAINT plan_features_pkey PRIMARY KEY (plan_id, feature_id); -- -- Name: plan_prices plan_prices_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_prices ADD CONSTRAINT plan_prices_pkey PRIMARY KEY (id); -- -- Name: plan_public_bullets plan_public_bullets_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_public_bullets ADD CONSTRAINT plan_public_bullets_pkey PRIMARY KEY (id); -- -- Name: plan_public plan_public_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_public ADD CONSTRAINT plan_public_pkey PRIMARY KEY (plan_id); -- -- Name: plans plans_key_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plans ADD CONSTRAINT plans_key_key UNIQUE (key); -- -- Name: plans plans_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plans ADD CONSTRAINT plans_pkey PRIMARY KEY (id); -- -- Name: professional_pricing professional_pricing_owner_commitment_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.professional_pricing ADD CONSTRAINT professional_pricing_owner_commitment_key UNIQUE (owner_id, determined_commitment_id); -- -- Name: professional_pricing professional_pricing_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.professional_pricing ADD CONSTRAINT professional_pricing_pkey PRIMARY KEY (id); -- -- Name: profiles profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.profiles ADD CONSTRAINT profiles_pkey PRIMARY KEY (id); -- -- Name: recurrence_exceptions recurrence_exceptions_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_exceptions ADD CONSTRAINT recurrence_exceptions_pkey PRIMARY KEY (id); -- -- Name: recurrence_exceptions recurrence_exceptions_unique; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_exceptions ADD CONSTRAINT recurrence_exceptions_unique UNIQUE (recurrence_id, original_date); -- -- Name: recurrence_rule_services recurrence_rule_services_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rule_services ADD CONSTRAINT recurrence_rule_services_pkey PRIMARY KEY (id); -- -- Name: recurrence_rules recurrence_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rules ADD CONSTRAINT recurrence_rules_pkey PRIMARY KEY (id); -- -- Name: saas_admins saas_admins_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_admins ADD CONSTRAINT saas_admins_pkey PRIMARY KEY (user_id); -- -- Name: saas_doc_votos saas_doc_votos_doc_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_doc_votos ADD CONSTRAINT saas_doc_votos_doc_id_user_id_key UNIQUE (doc_id, user_id); -- -- Name: saas_doc_votos saas_doc_votos_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_doc_votos ADD CONSTRAINT saas_doc_votos_pkey PRIMARY KEY (id); -- -- Name: saas_docs saas_docs_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_docs ADD CONSTRAINT saas_docs_pkey PRIMARY KEY (id); -- -- Name: saas_faq_itens saas_faq_itens_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_faq_itens ADD CONSTRAINT saas_faq_itens_pkey PRIMARY KEY (id); -- -- Name: saas_faq saas_faq_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_faq ADD CONSTRAINT saas_faq_pkey PRIMARY KEY (id); -- -- Name: services services_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.services ADD CONSTRAINT services_pkey PRIMARY KEY (id); -- -- Name: subscription_events subscription_events_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_events ADD CONSTRAINT subscription_events_pkey PRIMARY KEY (id); -- -- Name: subscription_intents_personal subscription_intents_personal_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_personal ADD CONSTRAINT subscription_intents_personal_pkey PRIMARY KEY (id); -- -- Name: subscription_intents_legacy subscription_intents_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_legacy ADD CONSTRAINT subscription_intents_pkey PRIMARY KEY (id); -- -- Name: subscription_intents_tenant subscription_intents_tenant_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_tenant ADD CONSTRAINT subscription_intents_tenant_pkey PRIMARY KEY (id); -- -- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (id); -- -- Name: support_sessions support_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.support_sessions ADD CONSTRAINT support_sessions_pkey PRIMARY KEY (id); -- -- Name: support_sessions support_sessions_token_unique; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.support_sessions ADD CONSTRAINT support_sessions_token_unique UNIQUE (token); -- -- Name: tenant_feature_exceptions_log tenant_feature_exceptions_log_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_feature_exceptions_log ADD CONSTRAINT tenant_feature_exceptions_log_pkey PRIMARY KEY (id); -- -- Name: tenant_features tenant_features_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_features ADD CONSTRAINT tenant_features_pkey PRIMARY KEY (tenant_id, feature_key); -- -- Name: tenant_invites tenant_invites_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_invites ADD CONSTRAINT tenant_invites_pkey PRIMARY KEY (id); -- -- Name: tenant_members tenant_members_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_members ADD CONSTRAINT tenant_members_pkey PRIMARY KEY (id); -- -- Name: tenant_members tenant_members_tenant_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_members ADD CONSTRAINT tenant_members_tenant_id_user_id_key UNIQUE (tenant_id, user_id); -- -- Name: tenant_modules tenant_modules_owner_id_module_id_key; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_modules ADD CONSTRAINT tenant_modules_owner_id_module_id_key UNIQUE (owner_id, module_id); -- -- Name: tenant_modules tenant_modules_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_modules ADD CONSTRAINT tenant_modules_pkey PRIMARY KEY (id); -- -- Name: tenants tenants_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenants ADD CONSTRAINT tenants_pkey PRIMARY KEY (id); -- -- Name: user_settings user_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.user_settings ADD CONSTRAINT user_settings_pkey PRIMARY KEY (user_id); -- -- Name: messages messages_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_realtime_admin -- ALTER TABLE ONLY realtime.messages ADD CONSTRAINT messages_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_12 messages_2026_03_12_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_12 ADD CONSTRAINT messages_2026_03_12_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_13 messages_2026_03_13_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_13 ADD CONSTRAINT messages_2026_03_13_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_14 messages_2026_03_14_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_14 ADD CONSTRAINT messages_2026_03_14_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_15 messages_2026_03_15_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_15 ADD CONSTRAINT messages_2026_03_15_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_16 messages_2026_03_16_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_16 ADD CONSTRAINT messages_2026_03_16_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_17 messages_2026_03_17_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_17 ADD CONSTRAINT messages_2026_03_17_pkey PRIMARY KEY (id, inserted_at); -- -- Name: messages_2026_03_18 messages_2026_03_18_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.messages_2026_03_18 ADD CONSTRAINT messages_2026_03_18_pkey PRIMARY KEY (id, inserted_at); -- -- Name: subscription pk_subscription; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.subscription ADD CONSTRAINT pk_subscription PRIMARY KEY (id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin -- ALTER TABLE ONLY realtime.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: buckets_analytics buckets_analytics_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.buckets_analytics ADD CONSTRAINT buckets_analytics_pkey PRIMARY KEY (id); -- -- Name: buckets buckets_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.buckets ADD CONSTRAINT buckets_pkey PRIMARY KEY (id); -- -- Name: buckets_vectors buckets_vectors_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.buckets_vectors ADD CONSTRAINT buckets_vectors_pkey PRIMARY KEY (id); -- -- Name: iceberg_namespaces iceberg_namespaces_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.iceberg_namespaces ADD CONSTRAINT iceberg_namespaces_pkey PRIMARY KEY (id); -- -- Name: iceberg_tables iceberg_tables_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.iceberg_tables ADD CONSTRAINT iceberg_tables_pkey PRIMARY KEY (id); -- -- Name: migrations migrations_name_key; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.migrations ADD CONSTRAINT migrations_name_key UNIQUE (name); -- -- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.migrations ADD CONSTRAINT migrations_pkey PRIMARY KEY (id); -- -- Name: objects objects_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.objects ADD CONSTRAINT objects_pkey PRIMARY KEY (id); -- -- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.s3_multipart_uploads_parts ADD CONSTRAINT s3_multipart_uploads_parts_pkey PRIMARY KEY (id); -- -- Name: s3_multipart_uploads s3_multipart_uploads_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.s3_multipart_uploads ADD CONSTRAINT s3_multipart_uploads_pkey PRIMARY KEY (id); -- -- Name: vector_indexes vector_indexes_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.vector_indexes ADD CONSTRAINT vector_indexes_pkey PRIMARY KEY (id); -- -- Name: hooks hooks_pkey; Type: CONSTRAINT; Schema: supabase_functions; Owner: supabase_functions_admin -- ALTER TABLE ONLY supabase_functions.hooks ADD CONSTRAINT hooks_pkey PRIMARY KEY (id); -- -- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: supabase_functions; Owner: supabase_functions_admin -- ALTER TABLE ONLY supabase_functions.migrations ADD CONSTRAINT migrations_pkey PRIMARY KEY (version); -- -- Name: extensions_tenant_external_id_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin -- CREATE INDEX extensions_tenant_external_id_index ON _realtime.extensions USING btree (tenant_external_id); -- -- Name: extensions_tenant_external_id_type_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin -- CREATE UNIQUE INDEX extensions_tenant_external_id_type_index ON _realtime.extensions USING btree (tenant_external_id, type); -- -- Name: tenants_external_id_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin -- CREATE UNIQUE INDEX tenants_external_id_index ON _realtime.tenants USING btree (external_id); -- -- Name: audit_logs_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX audit_logs_instance_id_idx ON auth.audit_log_entries USING btree (instance_id); -- -- Name: confirmation_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX confirmation_token_idx ON auth.users USING btree (confirmation_token) WHERE ((confirmation_token)::text !~ '^[0-9 ]*$'::text); -- -- Name: email_change_token_current_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX email_change_token_current_idx ON auth.users USING btree (email_change_token_current) WHERE ((email_change_token_current)::text !~ '^[0-9 ]*$'::text); -- -- Name: email_change_token_new_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX email_change_token_new_idx ON auth.users USING btree (email_change_token_new) WHERE ((email_change_token_new)::text !~ '^[0-9 ]*$'::text); -- -- Name: factor_id_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX factor_id_created_at_idx ON auth.mfa_factors USING btree (user_id, created_at); -- -- Name: flow_state_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX flow_state_created_at_idx ON auth.flow_state USING btree (created_at DESC); -- -- Name: identities_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX identities_email_idx ON auth.identities USING btree (email text_pattern_ops); -- -- Name: INDEX identities_email_idx; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON INDEX auth.identities_email_idx IS 'Auth: Ensures indexed queries on the email column'; -- -- Name: identities_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX identities_user_id_idx ON auth.identities USING btree (user_id); -- -- Name: idx_auth_code; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX idx_auth_code ON auth.flow_state USING btree (auth_code); -- -- Name: idx_oauth_client_states_created_at; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX idx_oauth_client_states_created_at ON auth.oauth_client_states USING btree (created_at); -- -- Name: idx_user_id_auth_method; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX idx_user_id_auth_method ON auth.flow_state USING btree (user_id, authentication_method); -- -- Name: mfa_challenge_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX mfa_challenge_created_at_idx ON auth.mfa_challenges USING btree (created_at DESC); -- -- Name: mfa_factors_user_friendly_name_unique; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX mfa_factors_user_friendly_name_unique ON auth.mfa_factors USING btree (friendly_name, user_id) WHERE (TRIM(BOTH FROM friendly_name) <> ''::text); -- -- Name: mfa_factors_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX mfa_factors_user_id_idx ON auth.mfa_factors USING btree (user_id); -- -- Name: oauth_auth_pending_exp_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX oauth_auth_pending_exp_idx ON auth.oauth_authorizations USING btree (expires_at) WHERE (status = 'pending'::auth.oauth_authorization_status); -- -- Name: oauth_clients_deleted_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX oauth_clients_deleted_at_idx ON auth.oauth_clients USING btree (deleted_at); -- -- Name: oauth_consents_active_client_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX oauth_consents_active_client_idx ON auth.oauth_consents USING btree (client_id) WHERE (revoked_at IS NULL); -- -- Name: oauth_consents_active_user_client_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX oauth_consents_active_user_client_idx ON auth.oauth_consents USING btree (user_id, client_id) WHERE (revoked_at IS NULL); -- -- Name: oauth_consents_user_order_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX oauth_consents_user_order_idx ON auth.oauth_consents USING btree (user_id, granted_at DESC); -- -- Name: one_time_tokens_relates_to_hash_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX one_time_tokens_relates_to_hash_idx ON auth.one_time_tokens USING hash (relates_to); -- -- Name: one_time_tokens_token_hash_hash_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX one_time_tokens_token_hash_hash_idx ON auth.one_time_tokens USING hash (token_hash); -- -- Name: one_time_tokens_user_id_token_type_key; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX one_time_tokens_user_id_token_type_key ON auth.one_time_tokens USING btree (user_id, token_type); -- -- Name: reauthentication_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX reauthentication_token_idx ON auth.users USING btree (reauthentication_token) WHERE ((reauthentication_token)::text !~ '^[0-9 ]*$'::text); -- -- Name: recovery_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX recovery_token_idx ON auth.users USING btree (recovery_token) WHERE ((recovery_token)::text !~ '^[0-9 ]*$'::text); -- -- Name: refresh_tokens_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX refresh_tokens_instance_id_idx ON auth.refresh_tokens USING btree (instance_id); -- -- Name: refresh_tokens_instance_id_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX refresh_tokens_instance_id_user_id_idx ON auth.refresh_tokens USING btree (instance_id, user_id); -- -- Name: refresh_tokens_parent_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX refresh_tokens_parent_idx ON auth.refresh_tokens USING btree (parent); -- -- Name: refresh_tokens_session_id_revoked_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX refresh_tokens_session_id_revoked_idx ON auth.refresh_tokens USING btree (session_id, revoked); -- -- Name: refresh_tokens_updated_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX refresh_tokens_updated_at_idx ON auth.refresh_tokens USING btree (updated_at DESC); -- -- Name: saml_providers_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX saml_providers_sso_provider_id_idx ON auth.saml_providers USING btree (sso_provider_id); -- -- Name: saml_relay_states_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX saml_relay_states_created_at_idx ON auth.saml_relay_states USING btree (created_at DESC); -- -- Name: saml_relay_states_for_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX saml_relay_states_for_email_idx ON auth.saml_relay_states USING btree (for_email); -- -- Name: saml_relay_states_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX saml_relay_states_sso_provider_id_idx ON auth.saml_relay_states USING btree (sso_provider_id); -- -- Name: sessions_not_after_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX sessions_not_after_idx ON auth.sessions USING btree (not_after DESC); -- -- Name: sessions_oauth_client_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX sessions_oauth_client_id_idx ON auth.sessions USING btree (oauth_client_id); -- -- Name: sessions_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX sessions_user_id_idx ON auth.sessions USING btree (user_id); -- -- Name: sso_domains_domain_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX sso_domains_domain_idx ON auth.sso_domains USING btree (lower(domain)); -- -- Name: sso_domains_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX sso_domains_sso_provider_id_idx ON auth.sso_domains USING btree (sso_provider_id); -- -- Name: sso_providers_resource_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX sso_providers_resource_id_idx ON auth.sso_providers USING btree (lower(resource_id)); -- -- Name: sso_providers_resource_id_pattern_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX sso_providers_resource_id_pattern_idx ON auth.sso_providers USING btree (resource_id text_pattern_ops); -- -- Name: unique_phone_factor_per_user; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX unique_phone_factor_per_user ON auth.mfa_factors USING btree (user_id, phone); -- -- Name: user_id_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX user_id_created_at_idx ON auth.sessions USING btree (user_id, created_at); -- -- Name: users_email_partial_key; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE UNIQUE INDEX users_email_partial_key ON auth.users USING btree (email) WHERE (is_sso_user = false); -- -- Name: INDEX users_email_partial_key; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin -- COMMENT ON INDEX auth.users_email_partial_key IS 'Auth: A partial unique index that applies only when is_sso_user is false'; -- -- Name: users_instance_id_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX users_instance_id_email_idx ON auth.users USING btree (instance_id, lower((email)::text)); -- -- Name: users_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX users_instance_id_idx ON auth.users USING btree (instance_id); -- -- Name: users_is_anonymous_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin -- CREATE INDEX users_is_anonymous_idx ON auth.users USING btree (is_anonymous); -- -- Name: agenda_bloqueios_owner_data_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_bloqueios_owner_data_idx ON public.agenda_bloqueios USING btree (owner_id, data_inicio, data_fim); -- -- Name: agenda_bloqueios_owner_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_bloqueios_owner_id_idx ON public.agenda_bloqueios USING btree (owner_id); -- -- Name: agenda_bloqueios_recorrente_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_bloqueios_recorrente_idx ON public.agenda_bloqueios USING btree (owner_id, dia_semana) WHERE (recorrente = true); -- -- Name: agenda_bloqueios_tenant_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_bloqueios_tenant_id_idx ON public.agenda_bloqueios USING btree (tenant_id); -- -- Name: agenda_configuracoes_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_configuracoes_tenant_idx ON public.agenda_configuracoes USING btree (tenant_id); -- -- Name: agenda_configuracoes_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_configuracoes_tenant_owner_idx ON public.agenda_configuracoes USING btree (tenant_id, owner_id); -- -- Name: agenda_eventos_billing_contract_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_billing_contract_idx ON public.agenda_eventos USING btree (billing_contract_id) WHERE (billing_contract_id IS NOT NULL); -- -- Name: agenda_eventos_insurance_plan_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_insurance_plan_idx ON public.agenda_eventos USING btree (insurance_plan_id); -- -- Name: agenda_eventos_owner_inicio_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_owner_inicio_idx ON public.agenda_eventos USING btree (owner_id, inicio_em); -- -- Name: agenda_eventos_owner_terapeuta_inicio_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_owner_terapeuta_inicio_idx ON public.agenda_eventos USING btree (owner_id, terapeuta_id, inicio_em); -- -- Name: agenda_eventos_recurrence_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_recurrence_idx ON public.agenda_eventos USING btree (recurrence_id) WHERE (recurrence_id IS NOT NULL); -- -- Name: agenda_eventos_tenant_inicio_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_tenant_inicio_idx ON public.agenda_eventos USING btree (tenant_id, inicio_em); -- -- Name: agenda_eventos_tenant_owner_inicio_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_eventos_tenant_owner_inicio_idx ON public.agenda_eventos USING btree (tenant_id, owner_id, inicio_em); -- -- Name: agenda_excecoes_owner_data_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_excecoes_owner_data_idx ON public.agenda_excecoes USING btree (owner_id, data); -- -- Name: agenda_excecoes_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_excecoes_tenant_idx ON public.agenda_excecoes USING btree (tenant_id); -- -- Name: agenda_excecoes_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_excecoes_tenant_owner_idx ON public.agenda_excecoes USING btree (tenant_id, owner_id); -- -- Name: agenda_online_slots_owner_weekday_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_online_slots_owner_weekday_idx ON public.agenda_online_slots USING btree (owner_id, weekday); -- -- Name: agenda_online_slots_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_online_slots_tenant_idx ON public.agenda_online_slots USING btree (tenant_id); -- -- Name: agenda_online_slots_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_online_slots_tenant_owner_idx ON public.agenda_online_slots USING btree (tenant_id, owner_id); -- -- Name: agenda_regras_semanais_owner_dia_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_regras_semanais_owner_dia_idx ON public.agenda_regras_semanais USING btree (owner_id, dia_semana); -- -- Name: agenda_regras_semanais_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_regras_semanais_tenant_idx ON public.agenda_regras_semanais USING btree (tenant_id); -- -- Name: agenda_regras_semanais_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_regras_semanais_tenant_owner_idx ON public.agenda_regras_semanais USING btree (tenant_id, owner_id); -- -- Name: agenda_slots_bloqueados_semanais_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_slots_bloqueados_semanais_tenant_idx ON public.agenda_slots_bloqueados_semanais USING btree (tenant_id); -- -- Name: agenda_slots_bloqueados_semanais_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_slots_bloqueados_semanais_tenant_owner_idx ON public.agenda_slots_bloqueados_semanais USING btree (tenant_id, owner_id); -- -- Name: agenda_slots_regras_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_slots_regras_tenant_idx ON public.agenda_slots_regras USING btree (tenant_id); -- -- Name: agenda_slots_regras_tenant_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agenda_slots_regras_tenant_owner_idx ON public.agenda_slots_regras USING btree (tenant_id, owner_id); -- -- Name: agendador_cfg_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agendador_cfg_tenant_idx ON public.agendador_configuracoes USING btree (tenant_id); -- -- Name: agendador_sol_data_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agendador_sol_data_idx ON public.agendador_solicitacoes USING btree (data_solicitada, hora_solicitada); -- -- Name: agendador_sol_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agendador_sol_owner_idx ON public.agendador_solicitacoes USING btree (owner_id, status); -- -- Name: agendador_sol_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX agendador_sol_tenant_idx ON public.agendador_solicitacoes USING btree (tenant_id); -- -- Name: billing_contracts_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX billing_contracts_owner_idx ON public.billing_contracts USING btree (owner_id); -- -- Name: billing_contracts_patient_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX billing_contracts_patient_idx ON public.billing_contracts USING btree (patient_id); -- -- Name: billing_contracts_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX billing_contracts_tenant_idx ON public.billing_contracts USING btree (tenant_id); -- -- Name: commitment_services_commitment_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX commitment_services_commitment_idx ON public.commitment_services USING btree (commitment_id); -- -- Name: commitment_services_service_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX commitment_services_service_idx ON public.commitment_services USING btree (service_id); -- -- Name: commitment_time_logs_calendar_event_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX commitment_time_logs_calendar_event_idx ON public.commitment_time_logs USING btree (calendar_event_id); -- -- Name: commitment_time_logs_commitment_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX commitment_time_logs_commitment_idx ON public.commitment_time_logs USING btree (commitment_id, created_at DESC); -- -- Name: commitment_time_logs_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX commitment_time_logs_tenant_idx ON public.commitment_time_logs USING btree (tenant_id, created_at DESC); -- -- Name: determined_commitment_fields_commitment_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX determined_commitment_fields_commitment_idx ON public.determined_commitment_fields USING btree (commitment_id, sort_order); -- -- Name: determined_commitment_fields_key_uniq; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX determined_commitment_fields_key_uniq ON public.determined_commitment_fields USING btree (commitment_id, key); -- -- Name: determined_commitment_fields_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX determined_commitment_fields_tenant_idx ON public.determined_commitment_fields USING btree (tenant_id); -- -- Name: determined_commitments_active_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX determined_commitments_active_idx ON public.determined_commitments USING btree (tenant_id, active); -- -- Name: determined_commitments_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX determined_commitments_tenant_idx ON public.determined_commitments USING btree (tenant_id); -- -- Name: determined_commitments_tenant_name_uniq; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX determined_commitments_tenant_name_uniq ON public.determined_commitments USING btree (tenant_id, lower(name)); -- -- Name: feriados_global_unique; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX feriados_global_unique ON public.feriados USING btree (data, nome) WHERE (tenant_id IS NULL); -- -- Name: financial_exceptions_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX financial_exceptions_owner_idx ON public.financial_exceptions USING btree (owner_id); -- -- Name: financial_exceptions_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX financial_exceptions_tenant_idx ON public.financial_exceptions USING btree (tenant_id); -- -- Name: idx_agenda_eventos_determined_commitment_id; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_agenda_eventos_determined_commitment_id ON public.agenda_eventos USING btree (determined_commitment_id); -- -- Name: idx_agenda_excecoes_owner_data; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_agenda_excecoes_owner_data ON public.agenda_excecoes USING btree (owner_id, data); -- -- Name: idx_agenda_slots_regras_owner_dia; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_agenda_slots_regras_owner_dia ON public.agenda_slots_regras USING btree (owner_id, dia_semana); -- -- Name: idx_intakes_converted_patient_id; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_intakes_converted_patient_id ON public.patient_intake_requests USING btree (converted_patient_id); -- -- Name: idx_intakes_owner_cpf; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_intakes_owner_cpf ON public.patient_intake_requests USING btree (owner_id, cpf); -- -- Name: idx_intakes_owner_created; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_intakes_owner_created ON public.patient_intake_requests USING btree (owner_id, created_at DESC); -- -- Name: idx_intakes_owner_status_created; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_intakes_owner_status_created ON public.patient_intake_requests USING btree (owner_id, status, created_at DESC); -- -- Name: idx_intakes_status_created; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_intakes_status_created ON public.patient_intake_requests USING btree (status, created_at DESC); -- -- Name: idx_patient_group_patient_group_id; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patient_group_patient_group_id ON public.patient_group_patient USING btree (patient_group_id); -- -- Name: idx_patient_groups_owner; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patient_groups_owner ON public.patient_groups USING btree (owner_id); -- -- Name: idx_patient_groups_owner_system_nome; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patient_groups_owner_system_nome ON public.patient_groups USING btree (owner_id, is_system, nome); -- -- Name: idx_patient_tags_owner; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patient_tags_owner ON public.patient_tags USING btree (owner_id); -- -- Name: idx_patients_created_at; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_created_at ON public.patients USING btree (created_at DESC); -- -- Name: idx_patients_last_attended; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_last_attended ON public.patients USING btree (last_attended_at DESC); -- -- Name: idx_patients_owner_email_principal; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_owner_email_principal ON public.patients USING btree (owner_id, email_principal); -- -- Name: idx_patients_owner_id; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_owner_id ON public.patients USING btree (owner_id); -- -- Name: idx_patients_owner_nome; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_owner_nome ON public.patients USING btree (owner_id, nome_completo); -- -- Name: idx_patients_responsible_member; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_responsible_member ON public.patients USING btree (responsible_member_id); -- -- Name: idx_patients_status; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_status ON public.patients USING btree (status); -- -- Name: idx_patients_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_tenant ON public.patients USING btree (tenant_id); -- -- Name: idx_patients_tenant_email_norm; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_patients_tenant_email_norm ON public.patients USING btree (tenant_id, lower(TRIM(BOTH FROM email_principal))); -- -- Name: idx_pgp_group; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_pgp_group ON public.patient_group_patient USING btree (patient_group_id); -- -- Name: idx_pgp_patient; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_pgp_patient ON public.patient_group_patient USING btree (patient_id); -- -- Name: idx_ppt_patient; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_ppt_patient ON public.patient_patient_tag USING btree (patient_id); -- -- Name: idx_ppt_tag; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_ppt_tag ON public.patient_patient_tag USING btree (tag_id); -- -- Name: idx_slots_bloq_owner_dia; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_slots_bloq_owner_dia ON public.agenda_slots_bloqueados_semanais USING btree (owner_id, dia_semana); -- -- Name: idx_subscription_intents_plan_interval; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_subscription_intents_plan_interval ON public.subscription_intents_legacy USING btree (plan_key, "interval"); -- -- Name: idx_subscription_intents_status; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_subscription_intents_status ON public.subscription_intents_legacy USING btree (status); -- -- Name: idx_subscription_intents_user_id; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_subscription_intents_user_id ON public.subscription_intents_legacy USING btree (user_id); -- -- Name: idx_tenant_features_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_tenant_features_tenant ON public.tenant_features USING btree (tenant_id); -- -- Name: idx_tenant_invites_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_tenant_invites_tenant ON public.tenant_invites USING btree (tenant_id); -- -- Name: idx_tenant_invites_token; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX idx_tenant_invites_token ON public.tenant_invites USING btree (token); -- -- Name: insurance_plans_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX insurance_plans_owner_idx ON public.insurance_plans USING btree (owner_id); -- -- Name: insurance_plans_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX insurance_plans_tenant_idx ON public.insurance_plans USING btree (tenant_id); -- -- Name: ix_plan_prices_plan; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ix_plan_prices_plan ON public.plan_prices USING btree (plan_id); -- -- Name: ix_plan_public_bullets_plan; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ix_plan_public_bullets_plan ON public.plan_public_bullets USING btree (plan_id); -- -- Name: ix_plan_public_sort; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ix_plan_public_sort ON public.plan_public USING btree (sort_order); -- -- Name: patient_discounts_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_discounts_owner_idx ON public.patient_discounts USING btree (owner_id); -- -- Name: patient_discounts_patient_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_discounts_patient_idx ON public.patient_discounts USING btree (patient_id); -- -- Name: patient_discounts_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_discounts_tenant_idx ON public.patient_discounts USING btree (tenant_id); -- -- Name: patient_group_patient_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_group_patient_tenant_idx ON public.patient_group_patient USING btree (tenant_id); -- -- Name: patient_groups_owner_nome_uniq; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX patient_groups_owner_nome_uniq ON public.patient_groups USING btree (owner_id, nome); -- -- Name: patient_groups_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_groups_tenant_idx ON public.patient_groups USING btree (tenant_id); -- -- Name: patient_intake_owner_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_intake_owner_id_idx ON public.patient_intake_requests USING btree (owner_id); -- -- Name: patient_intake_requests_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_intake_requests_tenant_idx ON public.patient_intake_requests USING btree (tenant_id); -- -- Name: patient_intake_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_intake_status_idx ON public.patient_intake_requests USING btree (status); -- -- Name: patient_intake_token_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_intake_token_idx ON public.patient_intake_requests USING btree (token); -- -- Name: patient_invites_one_active_per_owner; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX patient_invites_one_active_per_owner ON public.patient_invites USING btree (owner_id) WHERE (active = true); -- -- Name: patient_invites_owner_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_invites_owner_id_idx ON public.patient_invites USING btree (owner_id); -- -- Name: patient_invites_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_invites_tenant_idx ON public.patient_invites USING btree (tenant_id); -- -- Name: patient_invites_token_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_invites_token_idx ON public.patient_invites USING btree (token); -- -- Name: patient_patient_tag_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_patient_tag_tenant_idx ON public.patient_patient_tag USING btree (tenant_id); -- -- Name: patient_tags_owner_name_uq; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX patient_tags_owner_name_uq ON public.patient_tags USING btree (owner_id, lower(nome)); -- -- Name: patient_tags_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX patient_tags_tenant_idx ON public.patient_tags USING btree (tenant_id); -- -- Name: payment_settings_tenant_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX payment_settings_tenant_id_idx ON public.payment_settings USING btree (tenant_id); -- -- Name: ppt_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ppt_owner_idx ON public.patient_patient_tag USING btree (owner_id); -- -- Name: ppt_patient_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ppt_patient_idx ON public.patient_patient_tag USING btree (patient_id); -- -- Name: ppt_tag_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX ppt_tag_idx ON public.patient_patient_tag USING btree (tag_id); -- -- Name: professional_pricing_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX professional_pricing_tenant_idx ON public.professional_pricing USING btree (tenant_id); -- -- Name: profiles_work_description_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX profiles_work_description_idx ON public.profiles USING btree (work_description) WHERE (work_description IS NOT NULL); -- -- Name: recurrence_exceptions_rule_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_exceptions_rule_idx ON public.recurrence_exceptions USING btree (recurrence_id); -- -- Name: recurrence_exceptions_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_exceptions_tenant_idx ON public.recurrence_exceptions USING btree (tenant_id); -- -- Name: recurrence_rule_services_rule_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rule_services_rule_idx ON public.recurrence_rule_services USING btree (rule_id); -- -- Name: recurrence_rule_services_service_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rule_services_service_idx ON public.recurrence_rule_services USING btree (service_id); -- -- Name: recurrence_rules_active_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rules_active_idx ON public.recurrence_rules USING btree (owner_id, status) WHERE (status = 'ativo'::text); -- -- Name: recurrence_rules_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rules_owner_idx ON public.recurrence_rules USING btree (owner_id); -- -- Name: recurrence_rules_patient_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rules_patient_idx ON public.recurrence_rules USING btree (patient_id); -- -- Name: recurrence_rules_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX recurrence_rules_tenant_idx ON public.recurrence_rules USING btree (tenant_id); -- -- Name: saas_doc_votos_doc_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_doc_votos_doc_id_idx ON public.saas_doc_votos USING btree (doc_id); -- -- Name: saas_doc_votos_user_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_doc_votos_user_id_idx ON public.saas_doc_votos USING btree (user_id); -- -- Name: saas_docs_categoria_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_docs_categoria_idx ON public.saas_docs USING btree (categoria); -- -- Name: saas_docs_exibir_no_faq_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_docs_exibir_no_faq_idx ON public.saas_docs USING btree (exibir_no_faq) WHERE (exibir_no_faq = true); -- -- Name: saas_docs_path_ativo_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_docs_path_ativo_idx ON public.saas_docs USING btree (pagina_path, ativo); -- -- Name: saas_faq_ativo_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_ativo_idx ON public.saas_faq USING btree (ativo); -- -- Name: saas_faq_categoria_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_categoria_idx ON public.saas_faq USING btree (categoria); -- -- Name: saas_faq_fts_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_fts_idx ON public.saas_faq USING gin (to_tsvector('portuguese'::regconfig, ((COALESCE(pergunta, ''::text) || ' '::text) || COALESCE(conteudo, ''::text)))); -- -- Name: saas_faq_itens_ativo_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_itens_ativo_idx ON public.saas_faq_itens USING btree (ativo); -- -- Name: saas_faq_itens_doc_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_itens_doc_id_idx ON public.saas_faq_itens USING btree (doc_id); -- -- Name: saas_faq_pagina_path_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_pagina_path_idx ON public.saas_faq USING btree (pagina_path); -- -- Name: saas_faq_publico_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_publico_idx ON public.saas_faq USING btree (publico); -- -- Name: saas_faq_votos_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX saas_faq_votos_idx ON public.saas_faq USING btree (votos DESC); -- -- Name: services_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX services_owner_idx ON public.services USING btree (owner_id); -- -- Name: services_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX services_tenant_idx ON public.services USING btree (tenant_id); -- -- Name: sint_personal_created_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX sint_personal_created_idx ON public.subscription_intents_personal USING btree (created_at DESC); -- -- Name: sint_personal_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX sint_personal_status_idx ON public.subscription_intents_personal USING btree (status); -- -- Name: sint_tenant_created_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX sint_tenant_created_idx ON public.subscription_intents_tenant USING btree (created_at DESC); -- -- Name: sint_tenant_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX sint_tenant_status_idx ON public.subscription_intents_tenant USING btree (status); -- -- Name: sint_tenant_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX sint_tenant_tenant_idx ON public.subscription_intents_tenant USING btree (tenant_id); -- -- Name: subscription_events_created_at_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscription_events_created_at_idx ON public.subscription_events USING btree (created_at DESC); -- -- Name: subscription_events_owner_ref_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscription_events_owner_ref_idx ON public.subscription_events USING btree (owner_type, owner_ref); -- -- Name: subscription_events_sub_created_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscription_events_sub_created_idx ON public.subscription_events USING btree (subscription_id, created_at DESC); -- -- Name: subscription_events_subscription_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscription_events_subscription_id_idx ON public.subscription_events USING btree (subscription_id); -- -- Name: subscriptions_one_active_per_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX subscriptions_one_active_per_tenant ON public.subscriptions USING btree (tenant_id) WHERE (status = 'active'::text); -- -- Name: subscriptions_one_active_per_user; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX subscriptions_one_active_per_user ON public.subscriptions USING btree (user_id) WHERE (status = 'active'::text); -- -- Name: subscriptions_one_active_per_user_personal; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX subscriptions_one_active_per_user_personal ON public.subscriptions USING btree (user_id) WHERE ((tenant_id IS NULL) AND (status = 'active'::text)); -- -- Name: subscriptions_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_owner_idx ON public.subscriptions USING btree (user_id); -- -- Name: subscriptions_plan_key_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_plan_key_idx ON public.subscriptions USING btree (plan_key); -- -- Name: subscriptions_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_status_idx ON public.subscriptions USING btree (status); -- -- Name: subscriptions_tenant_id_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_tenant_id_idx ON public.subscriptions USING btree (tenant_id); -- -- Name: subscriptions_tenant_period_end_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_tenant_period_end_idx ON public.subscriptions USING btree (tenant_id, current_period_end); -- -- Name: subscriptions_tenant_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_tenant_status_idx ON public.subscriptions USING btree (tenant_id, status); -- -- Name: subscriptions_user_status_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX subscriptions_user_status_idx ON public.subscriptions USING btree (user_id, status, created_at DESC); -- -- Name: support_sessions_expires_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX support_sessions_expires_idx ON public.support_sessions USING btree (expires_at); -- -- Name: support_sessions_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX support_sessions_tenant_idx ON public.support_sessions USING btree (tenant_id); -- -- Name: support_sessions_token_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX support_sessions_token_idx ON public.support_sessions USING btree (token); -- -- Name: tenant_members_tenant_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX tenant_members_tenant_idx ON public.tenant_members USING btree (tenant_id); -- -- Name: tenant_members_user_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX tenant_members_user_idx ON public.tenant_members USING btree (user_id); -- -- Name: tenant_modules_owner_idx; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE INDEX tenant_modules_owner_idx ON public.tenant_modules USING btree (owner_id); -- -- Name: unique_member_per_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX unique_member_per_tenant ON public.tenant_members USING btree (tenant_id, user_id); -- -- Name: uq_patients_tenant_user; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_patients_tenant_user ON public.patients USING btree (tenant_id, user_id) WHERE (user_id IS NOT NULL); -- -- Name: uq_plan_price_active; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_plan_price_active ON public.plan_prices USING btree (plan_id, "interval", currency) WHERE ((is_active = true) AND (active_to IS NULL)); -- -- Name: uq_plan_prices_active; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_plan_prices_active ON public.plan_prices USING btree (plan_id, "interval") WHERE (is_active = true); -- -- Name: uq_subscriptions_active_by_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_subscriptions_active_by_tenant ON public.subscriptions USING btree (tenant_id) WHERE ((tenant_id IS NOT NULL) AND (status = 'active'::text)); -- -- Name: uq_subscriptions_active_personal_by_user; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_subscriptions_active_personal_by_user ON public.subscriptions USING btree (user_id) WHERE ((tenant_id IS NULL) AND (status = 'active'::text)); -- -- Name: uq_tenant_invites_pending; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_tenant_invites_pending ON public.tenant_invites USING btree (tenant_id, lower(email), role) WHERE ((accepted_at IS NULL) AND (revoked_at IS NULL)); -- -- Name: uq_tenant_members_tenant_user; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX uq_tenant_members_tenant_user ON public.tenant_members USING btree (tenant_id, user_id); -- -- Name: ux_subscriptions_active_per_personal_user; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX ux_subscriptions_active_per_personal_user ON public.subscriptions USING btree (user_id) WHERE ((status = 'active'::text) AND (tenant_id IS NULL)); -- -- Name: ux_subscriptions_active_per_tenant; Type: INDEX; Schema: public; Owner: supabase_admin -- CREATE UNIQUE INDEX ux_subscriptions_active_per_tenant ON public.subscriptions USING btree (tenant_id) WHERE ((status = 'active'::text) AND (tenant_id IS NOT NULL)); -- -- Name: ix_realtime_subscription_entity; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX ix_realtime_subscription_entity ON realtime.subscription USING btree (entity); -- -- Name: messages_inserted_at_topic_index; Type: INDEX; Schema: realtime; Owner: supabase_realtime_admin -- CREATE INDEX messages_inserted_at_topic_index ON ONLY realtime.messages USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_12_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_12_inserted_at_topic_idx ON realtime.messages_2026_03_12 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_13_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_13_inserted_at_topic_idx ON realtime.messages_2026_03_13 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_14_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_14_inserted_at_topic_idx ON realtime.messages_2026_03_14 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_15_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_15_inserted_at_topic_idx ON realtime.messages_2026_03_15 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_16_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_16_inserted_at_topic_idx ON realtime.messages_2026_03_16 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_17_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_17_inserted_at_topic_idx ON realtime.messages_2026_03_17 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: messages_2026_03_18_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE INDEX messages_2026_03_18_inserted_at_topic_idx ON realtime.messages_2026_03_18 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE)); -- -- Name: subscription_subscription_id_entity_filters_key; Type: INDEX; Schema: realtime; Owner: supabase_admin -- CREATE UNIQUE INDEX subscription_subscription_id_entity_filters_key ON realtime.subscription USING btree (subscription_id, entity, filters); -- -- Name: bname; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX bname ON storage.buckets USING btree (name); -- -- Name: bucketid_objname; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX bucketid_objname ON storage.objects USING btree (bucket_id, name); -- -- Name: buckets_analytics_unique_name_idx; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX buckets_analytics_unique_name_idx ON storage.buckets_analytics USING btree (name) WHERE (deleted_at IS NULL); -- -- Name: idx_iceberg_namespaces_bucket_id; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX idx_iceberg_namespaces_bucket_id ON storage.iceberg_namespaces USING btree (catalog_id, name); -- -- Name: idx_iceberg_tables_location; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX idx_iceberg_tables_location ON storage.iceberg_tables USING btree (location); -- -- Name: idx_iceberg_tables_namespace_id; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX idx_iceberg_tables_namespace_id ON storage.iceberg_tables USING btree (catalog_id, namespace_id, name); -- -- Name: idx_multipart_uploads_list; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE INDEX idx_multipart_uploads_list ON storage.s3_multipart_uploads USING btree (bucket_id, key, created_at); -- -- Name: idx_objects_bucket_id_name; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE INDEX idx_objects_bucket_id_name ON storage.objects USING btree (bucket_id, name COLLATE "C"); -- -- Name: idx_objects_bucket_id_name_lower; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE INDEX idx_objects_bucket_id_name_lower ON storage.objects USING btree (bucket_id, lower(name) COLLATE "C"); -- -- Name: name_prefix_search; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE INDEX name_prefix_search ON storage.objects USING btree (name text_pattern_ops); -- -- Name: vector_indexes_name_bucket_id_idx; Type: INDEX; Schema: storage; Owner: supabase_storage_admin -- CREATE UNIQUE INDEX vector_indexes_name_bucket_id_idx ON storage.vector_indexes USING btree (name, bucket_id); -- -- Name: supabase_functions_hooks_h_table_id_h_name_idx; Type: INDEX; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE INDEX supabase_functions_hooks_h_table_id_h_name_idx ON supabase_functions.hooks USING btree (hook_table_id, hook_name); -- -- Name: supabase_functions_hooks_request_id_idx; Type: INDEX; Schema: supabase_functions; Owner: supabase_functions_admin -- CREATE INDEX supabase_functions_hooks_request_id_idx ON supabase_functions.hooks USING btree (request_id); -- -- Name: messages_2026_03_12_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_12_inserted_at_topic_idx; -- -- Name: messages_2026_03_12_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_12_pkey; -- -- Name: messages_2026_03_13_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_13_inserted_at_topic_idx; -- -- Name: messages_2026_03_13_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_13_pkey; -- -- Name: messages_2026_03_14_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_14_inserted_at_topic_idx; -- -- Name: messages_2026_03_14_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_14_pkey; -- -- Name: messages_2026_03_15_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_15_inserted_at_topic_idx; -- -- Name: messages_2026_03_15_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_15_pkey; -- -- Name: messages_2026_03_16_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_16_inserted_at_topic_idx; -- -- Name: messages_2026_03_16_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_16_pkey; -- -- Name: messages_2026_03_17_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_17_inserted_at_topic_idx; -- -- Name: messages_2026_03_17_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_17_pkey; -- -- Name: messages_2026_03_18_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_03_18_inserted_at_topic_idx; -- -- Name: messages_2026_03_18_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin -- ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_03_18_pkey; -- -- Name: users on_auth_user_created; Type: TRIGGER; Schema: auth; Owner: supabase_auth_admin -- CREATE TRIGGER on_auth_user_created AFTER INSERT ON auth.users FOR EACH ROW EXECUTE FUNCTION public.handle_new_user(); -- -- Name: users trg_seed_patient_groups; Type: TRIGGER; Schema: auth; Owner: supabase_auth_admin -- CREATE TRIGGER trg_seed_patient_groups AFTER INSERT ON auth.users FOR EACH ROW EXECUTE FUNCTION public.on_new_user_seed_patient_groups(); -- -- Name: agenda_bloqueios agenda_bloqueios_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER agenda_bloqueios_updated_at BEFORE UPDATE ON public.agenda_bloqueios FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: agendador_configuracoes agendador_slug_trigger; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER agendador_slug_trigger BEFORE INSERT OR UPDATE ON public.agendador_configuracoes FOR EACH ROW EXECUTE FUNCTION public.agendador_gerar_slug(); -- -- Name: tenant_members prevent_saas_membership_trigger; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER prevent_saas_membership_trigger BEFORE INSERT ON public.tenant_members FOR EACH ROW EXECUTE FUNCTION public.prevent_saas_membership(); -- -- Name: insurance_plan_services set_insurance_plan_services_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER set_insurance_plan_services_updated_at BEFORE UPDATE ON public.insurance_plan_services FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: user_settings t_user_settings_set_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER t_user_settings_set_updated_at BEFORE UPDATE ON public.user_settings FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: agenda_configuracoes tg_agenda_configuracoes_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tg_agenda_configuracoes_updated_at BEFORE UPDATE ON public.agenda_configuracoes FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: agenda_eventos tg_agenda_eventos_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tg_agenda_eventos_updated_at BEFORE UPDATE ON public.agenda_eventos FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: agenda_excecoes tg_agenda_excecoes_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tg_agenda_excecoes_updated_at BEFORE UPDATE ON public.agenda_excecoes FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: agenda_regras_semanais tg_agenda_regras_semanais_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tg_agenda_regras_semanais_updated_at BEFORE UPDATE ON public.agenda_regras_semanais FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: recurrence_rules tg_recurrence_rules_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tg_recurrence_rules_updated_at BEFORE UPDATE ON public.recurrence_rules FOR EACH ROW EXECUTE FUNCTION public.set_updated_at_recurrence(); -- -- Name: plan_public tr_plan_public_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER tr_plan_public_updated_at BEFORE UPDATE ON public.plan_public FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: profiles trg_account_type_immutable; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_account_type_immutable BEFORE UPDATE OF account_type ON public.profiles FOR EACH ROW EXECUTE FUNCTION public.guard_account_type_immutable(); -- -- Name: agenda_configuracoes trg_agenda_cfg_sync; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_agenda_cfg_sync BEFORE INSERT OR UPDATE ON public.agenda_configuracoes FOR EACH ROW EXECUTE FUNCTION public.agenda_cfg_sync(); -- -- Name: agenda_eventos trg_agenda_eventos_busy_mirror_del; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_agenda_eventos_busy_mirror_del AFTER DELETE ON public.agenda_eventos FOR EACH ROW WHEN (((old.mirror_of_event_id IS NULL) AND (old.tenant_id = old.owner_id))) EXECUTE FUNCTION public.sync_busy_mirror_agenda_eventos(); -- -- Name: agenda_eventos trg_agenda_eventos_busy_mirror_ins; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_agenda_eventos_busy_mirror_ins AFTER INSERT ON public.agenda_eventos FOR EACH ROW WHEN (((new.mirror_of_event_id IS NULL) AND (new.tenant_id = new.owner_id) AND (new.visibility_scope = ANY (ARRAY['busy_only'::text, 'private'::text])))) EXECUTE FUNCTION public.sync_busy_mirror_agenda_eventos(); -- -- Name: agenda_eventos trg_agenda_eventos_busy_mirror_upd; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_agenda_eventos_busy_mirror_upd AFTER UPDATE ON public.agenda_eventos FOR EACH ROW WHEN (((new.mirror_of_event_id IS NULL) AND (new.tenant_id = new.owner_id) AND ((new.visibility_scope IS DISTINCT FROM old.visibility_scope) OR (new.inicio_em IS DISTINCT FROM old.inicio_em) OR (new.fim_em IS DISTINCT FROM old.fim_em) OR (new.owner_id IS DISTINCT FROM old.owner_id) OR (new.tenant_id IS DISTINCT FROM old.tenant_id)))) EXECUTE FUNCTION public.sync_busy_mirror_agenda_eventos(); -- -- Name: agenda_regras_semanais trg_agenda_regras_semanais_no_overlap; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_agenda_regras_semanais_no_overlap BEFORE INSERT OR UPDATE ON public.agenda_regras_semanais FOR EACH ROW EXECUTE FUNCTION public.fn_agenda_regras_semanais_no_overlap(); -- -- Name: determined_commitment_fields trg_determined_commitment_fields_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_determined_commitment_fields_updated_at BEFORE UPDATE ON public.determined_commitment_fields FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: determined_commitments trg_determined_commitments_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_determined_commitments_updated_at BEFORE UPDATE ON public.determined_commitments FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: financial_exceptions trg_financial_exceptions_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_financial_exceptions_updated_at BEFORE UPDATE ON public.financial_exceptions FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: insurance_plans trg_insurance_plans_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_insurance_plans_updated_at BEFORE UPDATE ON public.insurance_plans FOR EACH ROW EXECUTE FUNCTION public.set_insurance_plans_updated_at(); -- -- Name: plans trg_no_change_core_plan_key; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_no_change_core_plan_key BEFORE UPDATE ON public.plans FOR EACH ROW EXECUTE FUNCTION public.guard_no_change_core_plan_key(); -- -- Name: plans trg_no_change_plan_target; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_no_change_plan_target BEFORE UPDATE ON public.plans FOR EACH ROW EXECUTE FUNCTION public.guard_no_change_plan_target(); -- -- Name: plans trg_no_delete_core_plans; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_no_delete_core_plans BEFORE DELETE ON public.plans FOR EACH ROW EXECUTE FUNCTION public.guard_no_delete_core_plans(); -- -- Name: tenant_members trg_patient_cannot_own_tenant; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patient_cannot_own_tenant BEFORE INSERT OR UPDATE ON public.tenant_members FOR EACH ROW EXECUTE FUNCTION public.guard_patient_cannot_own_tenant(); -- -- Name: patient_groups trg_patient_groups_set_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patient_groups_set_updated_at BEFORE UPDATE ON public.patient_groups FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: patient_intake_requests trg_patient_intake_requests_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patient_intake_requests_updated_at BEFORE UPDATE ON public.patient_intake_requests FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: patient_tags trg_patient_tags_set_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patient_tags_set_updated_at BEFORE UPDATE ON public.patient_tags FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: patients trg_patients_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patients_updated_at BEFORE UPDATE ON public.patients FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: patients trg_patients_validate_members; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_patients_validate_members BEFORE INSERT OR UPDATE OF tenant_id, responsible_member_id, patient_scope, therapist_member_id ON public.patients FOR EACH ROW EXECUTE FUNCTION public.patients_validate_member_consistency(); -- -- Name: payment_settings trg_payment_settings_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_payment_settings_updated_at BEFORE UPDATE ON public.payment_settings FOR EACH ROW EXECUTE FUNCTION public.update_payment_settings_updated_at(); -- -- Name: patient_groups trg_prevent_promoting_to_system; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_prevent_promoting_to_system BEFORE UPDATE ON public.patient_groups FOR EACH ROW EXECUTE FUNCTION public.prevent_promoting_to_system(); -- -- Name: patient_groups trg_prevent_system_group_changes; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_prevent_system_group_changes BEFORE DELETE OR UPDATE ON public.patient_groups FOR EACH ROW EXECUTE FUNCTION public.prevent_system_group_changes(); -- -- Name: professional_pricing trg_professional_pricing_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_professional_pricing_updated_at BEFORE UPDATE ON public.professional_pricing FOR EACH ROW EXECUTE FUNCTION public.update_professional_pricing_updated_at(); -- -- Name: profiles trg_profiles_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_profiles_updated_at BEFORE UPDATE ON public.profiles FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: services trg_services_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_services_updated_at BEFORE UPDATE ON public.services FOR EACH ROW EXECUTE FUNCTION public.set_services_updated_at(); -- -- Name: subscription_intents trg_subscription_intents_view_insert; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_subscription_intents_view_insert INSTEAD OF INSERT ON public.subscription_intents FOR EACH ROW EXECUTE FUNCTION public.subscription_intents_view_insert(); -- -- Name: subscriptions trg_subscriptions_validate_scope; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_subscriptions_validate_scope BEFORE INSERT OR UPDATE ON public.subscriptions FOR EACH ROW EXECUTE FUNCTION public.subscriptions_validate_scope(); -- -- Name: tenant_features trg_tenant_features_guard_with_plan; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_tenant_features_guard_with_plan BEFORE INSERT OR UPDATE ON public.tenant_features FOR EACH ROW EXECUTE FUNCTION public.tenant_features_guard_with_plan(); -- -- Name: tenant_features trg_tenant_features_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_tenant_features_updated_at BEFORE UPDATE ON public.tenant_features FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: tenants trg_tenant_kind_immutable; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_tenant_kind_immutable BEFORE UPDATE OF kind ON public.tenants FOR EACH ROW EXECUTE FUNCTION public.guard_tenant_kind_immutable(); -- -- Name: user_settings trg_user_settings_updated_at; Type: TRIGGER; Schema: public; Owner: supabase_admin -- CREATE TRIGGER trg_user_settings_updated_at BEFORE UPDATE ON public.user_settings FOR EACH ROW EXECUTE FUNCTION public.set_updated_at(); -- -- Name: subscription tr_check_filters; Type: TRIGGER; Schema: realtime; Owner: supabase_admin -- CREATE TRIGGER tr_check_filters BEFORE INSERT OR UPDATE ON realtime.subscription FOR EACH ROW EXECUTE FUNCTION realtime.subscription_check_filters(); -- -- Name: buckets enforce_bucket_name_length_trigger; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin -- CREATE TRIGGER enforce_bucket_name_length_trigger BEFORE INSERT OR UPDATE OF name ON storage.buckets FOR EACH ROW EXECUTE FUNCTION storage.enforce_bucket_name_length(); -- -- Name: buckets protect_buckets_delete; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin -- CREATE TRIGGER protect_buckets_delete BEFORE DELETE ON storage.buckets FOR EACH STATEMENT EXECUTE FUNCTION storage.protect_delete(); -- -- Name: objects protect_objects_delete; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin -- CREATE TRIGGER protect_objects_delete BEFORE DELETE ON storage.objects FOR EACH STATEMENT EXECUTE FUNCTION storage.protect_delete(); -- -- Name: objects update_objects_updated_at; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin -- CREATE TRIGGER update_objects_updated_at BEFORE UPDATE ON storage.objects FOR EACH ROW EXECUTE FUNCTION storage.update_updated_at_column(); -- -- Name: extensions extensions_tenant_external_id_fkey; Type: FK CONSTRAINT; Schema: _realtime; Owner: supabase_admin -- ALTER TABLE ONLY _realtime.extensions ADD CONSTRAINT extensions_tenant_external_id_fkey FOREIGN KEY (tenant_external_id) REFERENCES _realtime.tenants(external_id) ON DELETE CASCADE; -- -- Name: identities identities_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.identities ADD CONSTRAINT identities_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: mfa_amr_claims mfa_amr_claims_session_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_amr_claims ADD CONSTRAINT mfa_amr_claims_session_id_fkey FOREIGN KEY (session_id) REFERENCES auth.sessions(id) ON DELETE CASCADE; -- -- Name: mfa_challenges mfa_challenges_auth_factor_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_challenges ADD CONSTRAINT mfa_challenges_auth_factor_id_fkey FOREIGN KEY (factor_id) REFERENCES auth.mfa_factors(id) ON DELETE CASCADE; -- -- Name: mfa_factors mfa_factors_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.mfa_factors ADD CONSTRAINT mfa_factors_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: oauth_authorizations oauth_authorizations_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_authorizations ADD CONSTRAINT oauth_authorizations_client_id_fkey FOREIGN KEY (client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE; -- -- Name: oauth_authorizations oauth_authorizations_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_authorizations ADD CONSTRAINT oauth_authorizations_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: oauth_consents oauth_consents_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_consents ADD CONSTRAINT oauth_consents_client_id_fkey FOREIGN KEY (client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE; -- -- Name: oauth_consents oauth_consents_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.oauth_consents ADD CONSTRAINT oauth_consents_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: one_time_tokens one_time_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.one_time_tokens ADD CONSTRAINT one_time_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: refresh_tokens refresh_tokens_session_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.refresh_tokens ADD CONSTRAINT refresh_tokens_session_id_fkey FOREIGN KEY (session_id) REFERENCES auth.sessions(id) ON DELETE CASCADE; -- -- Name: saml_providers saml_providers_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_providers ADD CONSTRAINT saml_providers_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE; -- -- Name: saml_relay_states saml_relay_states_flow_state_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_relay_states ADD CONSTRAINT saml_relay_states_flow_state_id_fkey FOREIGN KEY (flow_state_id) REFERENCES auth.flow_state(id) ON DELETE CASCADE; -- -- Name: saml_relay_states saml_relay_states_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.saml_relay_states ADD CONSTRAINT saml_relay_states_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE; -- -- Name: sessions sessions_oauth_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sessions ADD CONSTRAINT sessions_oauth_client_id_fkey FOREIGN KEY (oauth_client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE; -- -- Name: sessions sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sessions ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: sso_domains sso_domains_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE ONLY auth.sso_domains ADD CONSTRAINT sso_domains_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE; -- -- Name: agenda_bloqueios agenda_bloqueios_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_bloqueios ADD CONSTRAINT agenda_bloqueios_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: agenda_bloqueios agenda_bloqueios_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_bloqueios ADD CONSTRAINT agenda_bloqueios_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE SET NULL; -- -- Name: agenda_configuracoes agenda_configuracoes_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_configuracoes ADD CONSTRAINT agenda_configuracoes_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agenda_eventos agenda_eventos_billing_contract_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_billing_contract_id_fkey FOREIGN KEY (billing_contract_id) REFERENCES public.billing_contracts(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_determined_commitment_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_determined_commitment_fk FOREIGN KEY (determined_commitment_id) REFERENCES public.determined_commitments(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_insurance_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_insurance_plan_id_fkey FOREIGN KEY (insurance_plan_id) REFERENCES public.insurance_plans(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_insurance_plan_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_insurance_plan_service_id_fkey FOREIGN KEY (insurance_plan_service_id) REFERENCES public.insurance_plan_services(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patients(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_recurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_recurrence_id_fkey FOREIGN KEY (recurrence_id) REFERENCES public.recurrence_rules(id) ON DELETE SET NULL; -- -- Name: agenda_eventos agenda_eventos_terapeuta_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_eventos ADD CONSTRAINT agenda_eventos_terapeuta_fk FOREIGN KEY (terapeuta_id) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: agenda_excecoes agenda_excecoes_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_excecoes ADD CONSTRAINT agenda_excecoes_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agenda_online_slots agenda_online_slots_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_online_slots ADD CONSTRAINT agenda_online_slots_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: agenda_online_slots agenda_online_slots_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_online_slots ADD CONSTRAINT agenda_online_slots_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agenda_regras_semanais agenda_regras_semanais_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_regras_semanais ADD CONSTRAINT agenda_regras_semanais_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agenda_slots_bloqueados_semanais agenda_slots_bloqueados_semanais_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_bloqueados_semanais ADD CONSTRAINT agenda_slots_bloqueados_semanais_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agenda_slots_regras agenda_slots_regras_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agenda_slots_regras ADD CONSTRAINT agenda_slots_regras_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agendador_configuracoes agendador_configuracoes_owner_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_configuracoes ADD CONSTRAINT agendador_configuracoes_owner_fk FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: agendador_configuracoes agendador_configuracoes_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_configuracoes ADD CONSTRAINT agendador_configuracoes_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: agendador_solicitacoes agendador_sol_owner_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_solicitacoes ADD CONSTRAINT agendador_sol_owner_fk FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: agendador_solicitacoes agendador_sol_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.agendador_solicitacoes ADD CONSTRAINT agendador_sol_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: billing_contracts billing_contracts_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.billing_contracts ADD CONSTRAINT billing_contracts_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: billing_contracts billing_contracts_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.billing_contracts ADD CONSTRAINT billing_contracts_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patients(id) ON DELETE CASCADE; -- -- Name: commitment_services commitment_services_commitment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_services ADD CONSTRAINT commitment_services_commitment_id_fkey FOREIGN KEY (commitment_id) REFERENCES public.agenda_eventos(id) ON DELETE CASCADE; -- -- Name: commitment_services commitment_services_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_services ADD CONSTRAINT commitment_services_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.services(id) ON DELETE RESTRICT; -- -- Name: commitment_time_logs commitment_time_logs_calendar_event_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_time_logs ADD CONSTRAINT commitment_time_logs_calendar_event_id_fkey FOREIGN KEY (calendar_event_id) REFERENCES public.agenda_eventos(id) ON DELETE SET NULL; -- -- Name: commitment_time_logs commitment_time_logs_commitment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_time_logs ADD CONSTRAINT commitment_time_logs_commitment_id_fkey FOREIGN KEY (commitment_id) REFERENCES public.determined_commitments(id) ON DELETE CASCADE; -- -- Name: commitment_time_logs commitment_time_logs_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.commitment_time_logs ADD CONSTRAINT commitment_time_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: determined_commitment_fields determined_commitment_fields_commitment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitment_fields ADD CONSTRAINT determined_commitment_fields_commitment_id_fkey FOREIGN KEY (commitment_id) REFERENCES public.determined_commitments(id) ON DELETE CASCADE; -- -- Name: determined_commitment_fields determined_commitment_fields_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitment_fields ADD CONSTRAINT determined_commitment_fields_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: determined_commitments determined_commitments_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.determined_commitments ADD CONSTRAINT determined_commitments_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: feriados feriados_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.feriados ADD CONSTRAINT feriados_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: feriados feriados_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.feriados ADD CONSTRAINT feriados_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: financial_exceptions financial_exceptions_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.financial_exceptions ADD CONSTRAINT financial_exceptions_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: insurance_plan_services insurance_plan_services_plan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.insurance_plan_services ADD CONSTRAINT insurance_plan_services_plan_fkey FOREIGN KEY (insurance_plan_id) REFERENCES public.insurance_plans(id) ON DELETE CASCADE; -- -- Name: insurance_plans insurance_plans_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.insurance_plans ADD CONSTRAINT insurance_plans_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: module_features module_features_feature_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.module_features ADD CONSTRAINT module_features_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES public.features(id) ON DELETE CASCADE; -- -- Name: module_features module_features_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.module_features ADD CONSTRAINT module_features_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(id) ON DELETE CASCADE; -- -- Name: patient_discounts patient_discounts_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_discounts ADD CONSTRAINT patient_discounts_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: patient_discounts patient_discounts_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_discounts ADD CONSTRAINT patient_discounts_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patients(id) ON DELETE CASCADE; -- -- Name: patient_group_patient patient_group_patient_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_group_patient ADD CONSTRAINT patient_group_patient_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patients(id) ON DELETE CASCADE; -- -- Name: patient_group_patient patient_group_patient_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_group_patient ADD CONSTRAINT patient_group_patient_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patient_groups patient_groups_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_groups ADD CONSTRAINT patient_groups_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patient_intake_requests patient_intake_requests_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_intake_requests ADD CONSTRAINT patient_intake_requests_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patient_invites patient_invites_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_invites ADD CONSTRAINT patient_invites_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patient_patient_tag patient_patient_tag_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_patient_tag ADD CONSTRAINT patient_patient_tag_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES public.patient_tags(id) ON DELETE CASCADE; -- -- Name: patient_patient_tag patient_patient_tag_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_patient_tag ADD CONSTRAINT patient_patient_tag_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patient_tags patient_tags_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_tags ADD CONSTRAINT patient_tags_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patients patients_responsible_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patients ADD CONSTRAINT patients_responsible_member_id_fkey FOREIGN KEY (responsible_member_id) REFERENCES public.tenant_members(id) ON DELETE RESTRICT; -- -- Name: patients patients_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patients ADD CONSTRAINT patients_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: patients patients_therapist_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patients ADD CONSTRAINT patients_therapist_member_id_fkey FOREIGN KEY (therapist_member_id) REFERENCES public.tenant_members(id); -- -- Name: patients patients_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patients ADD CONSTRAINT patients_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: payment_settings payment_settings_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.payment_settings ADD CONSTRAINT payment_settings_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: payment_settings payment_settings_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.payment_settings ADD CONSTRAINT payment_settings_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: plan_features plan_features_feature_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_features ADD CONSTRAINT plan_features_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES public.features(id) ON DELETE CASCADE; -- -- Name: plan_features plan_features_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_features ADD CONSTRAINT plan_features_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE CASCADE; -- -- Name: plan_prices plan_prices_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_prices ADD CONSTRAINT plan_prices_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE CASCADE; -- -- Name: plan_public_bullets plan_public_bullets_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_public_bullets ADD CONSTRAINT plan_public_bullets_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE CASCADE; -- -- Name: plan_public plan_public_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.plan_public ADD CONSTRAINT plan_public_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE CASCADE; -- -- Name: patient_patient_tag ppt_patient_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_patient_tag ADD CONSTRAINT ppt_patient_fk FOREIGN KEY (patient_id) REFERENCES public.patients(id) ON DELETE CASCADE; -- -- Name: patient_patient_tag ppt_tag_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.patient_patient_tag ADD CONSTRAINT ppt_tag_fk FOREIGN KEY (tag_id) REFERENCES public.patient_tags(id) ON DELETE CASCADE; -- -- Name: professional_pricing professional_pricing_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.professional_pricing ADD CONSTRAINT professional_pricing_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: profiles profiles_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.profiles ADD CONSTRAINT profiles_id_fkey FOREIGN KEY (id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: recurrence_exceptions recurrence_exceptions_agenda_evento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_exceptions ADD CONSTRAINT recurrence_exceptions_agenda_evento_id_fkey FOREIGN KEY (agenda_evento_id) REFERENCES public.agenda_eventos(id) ON DELETE SET NULL; -- -- Name: recurrence_exceptions recurrence_exceptions_recurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_exceptions ADD CONSTRAINT recurrence_exceptions_recurrence_id_fkey FOREIGN KEY (recurrence_id) REFERENCES public.recurrence_rules(id) ON DELETE CASCADE; -- -- Name: recurrence_rule_services recurrence_rule_services_rule_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rule_services ADD CONSTRAINT recurrence_rule_services_rule_id_fkey FOREIGN KEY (rule_id) REFERENCES public.recurrence_rules(id) ON DELETE CASCADE; -- -- Name: recurrence_rule_services recurrence_rule_services_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rule_services ADD CONSTRAINT recurrence_rule_services_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.services(id) ON DELETE RESTRICT; -- -- Name: recurrence_rules recurrence_rules_insurance_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rules ADD CONSTRAINT recurrence_rules_insurance_plan_id_fkey FOREIGN KEY (insurance_plan_id) REFERENCES public.insurance_plans(id) ON DELETE SET NULL; -- -- Name: recurrence_rules recurrence_rules_insurance_plan_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.recurrence_rules ADD CONSTRAINT recurrence_rules_insurance_plan_service_id_fkey FOREIGN KEY (insurance_plan_service_id) REFERENCES public.insurance_plan_services(id) ON DELETE SET NULL; -- -- Name: saas_admins saas_admins_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_admins ADD CONSTRAINT saas_admins_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: saas_doc_votos saas_doc_votos_doc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_doc_votos ADD CONSTRAINT saas_doc_votos_doc_id_fkey FOREIGN KEY (doc_id) REFERENCES public.saas_docs(id) ON DELETE CASCADE; -- -- Name: saas_doc_votos saas_doc_votos_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_doc_votos ADD CONSTRAINT saas_doc_votos_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: saas_faq_itens saas_faq_itens_doc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.saas_faq_itens ADD CONSTRAINT saas_faq_itens_doc_id_fkey FOREIGN KEY (doc_id) REFERENCES public.saas_docs(id) ON DELETE CASCADE; -- -- Name: services services_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.services ADD CONSTRAINT services_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: subscription_intents_personal sint_personal_subscription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_personal ADD CONSTRAINT sint_personal_subscription_id_fkey FOREIGN KEY (subscription_id) REFERENCES public.subscriptions(id) ON DELETE SET NULL; -- -- Name: subscription_intents_tenant sint_tenant_subscription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_tenant ADD CONSTRAINT sint_tenant_subscription_id_fkey FOREIGN KEY (subscription_id) REFERENCES public.subscriptions(id) ON DELETE SET NULL; -- -- Name: subscription_events subscription_events_subscription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_events ADD CONSTRAINT subscription_events_subscription_id_fkey FOREIGN KEY (subscription_id) REFERENCES public.subscriptions(id) ON DELETE CASCADE; -- -- Name: subscription_intents_personal subscription_intents_personal_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_personal ADD CONSTRAINT subscription_intents_personal_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE RESTRICT; -- -- Name: subscription_intents_tenant subscription_intents_tenant_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_tenant ADD CONSTRAINT subscription_intents_tenant_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE RESTRICT; -- -- Name: subscription_intents_legacy subscription_intents_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscription_intents_legacy ADD CONSTRAINT subscription_intents_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: subscriptions subscriptions_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_owner_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: subscriptions subscriptions_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE RESTRICT; -- -- Name: support_sessions support_sessions_admin_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.support_sessions ADD CONSTRAINT support_sessions_admin_fk FOREIGN KEY (admin_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: support_sessions support_sessions_tenant_fk; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.support_sessions ADD CONSTRAINT support_sessions_tenant_fk FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: tenant_features tenant_features_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_features ADD CONSTRAINT tenant_features_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: tenant_invites tenant_invites_accepted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_invites ADD CONSTRAINT tenant_invites_accepted_by_fkey FOREIGN KEY (accepted_by) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: tenant_invites tenant_invites_invited_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_invites ADD CONSTRAINT tenant_invites_invited_by_fkey FOREIGN KEY (invited_by) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: tenant_invites tenant_invites_revoked_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_invites ADD CONSTRAINT tenant_invites_revoked_by_fkey FOREIGN KEY (revoked_by) REFERENCES auth.users(id) ON DELETE SET NULL; -- -- Name: tenant_invites tenant_invites_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_invites ADD CONSTRAINT tenant_invites_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: tenant_members tenant_members_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_members ADD CONSTRAINT tenant_members_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE; -- -- Name: tenant_members tenant_members_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_members ADD CONSTRAINT tenant_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: tenant_modules tenant_modules_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_modules ADD CONSTRAINT tenant_modules_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(id) ON DELETE CASCADE; -- -- Name: tenant_modules tenant_modules_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.tenant_modules ADD CONSTRAINT tenant_modules_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: user_settings user_settings_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase_admin -- ALTER TABLE ONLY public.user_settings ADD CONSTRAINT user_settings_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE; -- -- Name: iceberg_namespaces iceberg_namespaces_catalog_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.iceberg_namespaces ADD CONSTRAINT iceberg_namespaces_catalog_id_fkey FOREIGN KEY (catalog_id) REFERENCES storage.buckets_analytics(id) ON DELETE CASCADE; -- -- Name: iceberg_tables iceberg_tables_catalog_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.iceberg_tables ADD CONSTRAINT iceberg_tables_catalog_id_fkey FOREIGN KEY (catalog_id) REFERENCES storage.buckets_analytics(id) ON DELETE CASCADE; -- -- Name: iceberg_tables iceberg_tables_namespace_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.iceberg_tables ADD CONSTRAINT iceberg_tables_namespace_id_fkey FOREIGN KEY (namespace_id) REFERENCES storage.iceberg_namespaces(id) ON DELETE CASCADE; -- -- Name: objects objects_bucketId_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.objects ADD CONSTRAINT "objects_bucketId_fkey" FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id); -- -- Name: s3_multipart_uploads s3_multipart_uploads_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.s3_multipart_uploads ADD CONSTRAINT s3_multipart_uploads_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id); -- -- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.s3_multipart_uploads_parts ADD CONSTRAINT s3_multipart_uploads_parts_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id); -- -- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_upload_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.s3_multipart_uploads_parts ADD CONSTRAINT s3_multipart_uploads_parts_upload_id_fkey FOREIGN KEY (upload_id) REFERENCES storage.s3_multipart_uploads(id) ON DELETE CASCADE; -- -- Name: vector_indexes vector_indexes_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE ONLY storage.vector_indexes ADD CONSTRAINT vector_indexes_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets_vectors(id); -- -- Name: audit_log_entries; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.audit_log_entries ENABLE ROW LEVEL SECURITY; -- -- Name: flow_state; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.flow_state ENABLE ROW LEVEL SECURITY; -- -- Name: identities; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.identities ENABLE ROW LEVEL SECURITY; -- -- Name: instances; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.instances ENABLE ROW LEVEL SECURITY; -- -- Name: mfa_amr_claims; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.mfa_amr_claims ENABLE ROW LEVEL SECURITY; -- -- Name: mfa_challenges; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.mfa_challenges ENABLE ROW LEVEL SECURITY; -- -- Name: mfa_factors; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.mfa_factors ENABLE ROW LEVEL SECURITY; -- -- Name: one_time_tokens; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.one_time_tokens ENABLE ROW LEVEL SECURITY; -- -- Name: refresh_tokens; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.refresh_tokens ENABLE ROW LEVEL SECURITY; -- -- Name: saml_providers; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.saml_providers ENABLE ROW LEVEL SECURITY; -- -- Name: saml_relay_states; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.saml_relay_states ENABLE ROW LEVEL SECURITY; -- -- Name: schema_migrations; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.schema_migrations ENABLE ROW LEVEL SECURITY; -- -- Name: sessions; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.sessions ENABLE ROW LEVEL SECURITY; -- -- Name: sso_domains; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.sso_domains ENABLE ROW LEVEL SECURITY; -- -- Name: sso_providers; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.sso_providers ENABLE ROW LEVEL SECURITY; -- -- Name: users; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin -- ALTER TABLE auth.users ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_bloqueios; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_bloqueios ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_configuracoes; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_configuracoes ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_configuracoes agenda_configuracoes_clinic_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_configuracoes_clinic_read ON public.agenda_configuracoes FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_configuracoes agenda_configuracoes_clinic_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_configuracoes_clinic_write ON public.agenda_configuracoes USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_configuracoes agenda_configuracoes_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_configuracoes_owner ON public.agenda_configuracoes USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_eventos; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_eventos ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_eventos agenda_eventos_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_eventos_delete ON public.agenda_eventos FOR DELETE USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.delete'::text))); -- -- Name: agenda_eventos agenda_eventos_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_eventos_insert ON public.agenda_eventos FOR INSERT WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.create'::text))); -- -- Name: agenda_eventos agenda_eventos_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_eventos_owner_all ON public.agenda_eventos TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_eventos agenda_eventos_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_eventos_select ON public.agenda_eventos FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_eventos agenda_eventos_update; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_eventos_update ON public.agenda_eventos FOR UPDATE USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_excecoes; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_excecoes ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_excecoes agenda_excecoes_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_excecoes_owner ON public.agenda_excecoes USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_excecoes agenda_excecoes_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_excecoes_select ON public.agenda_excecoes FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_excecoes agenda_excecoes_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_excecoes_write ON public.agenda_excecoes USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_online_slots; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_online_slots ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_online_slots agenda_online_slots_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_online_slots_owner ON public.agenda_online_slots USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_online_slots agenda_online_slots_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_online_slots_select ON public.agenda_online_slots FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_online_slots agenda_online_slots_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_online_slots_write ON public.agenda_online_slots USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_regras_semanais; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_regras_semanais ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_regras_semanais agenda_regras_semanais_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_regras_semanais_owner ON public.agenda_regras_semanais USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_regras_semanais agenda_regras_semanais_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_regras_semanais_select ON public.agenda_regras_semanais FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_regras_semanais agenda_regras_semanais_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_regras_semanais_write ON public.agenda_regras_semanais USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_slots_bloqueados_semanais; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_slots_bloqueados_semanais ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_slots_bloqueados_semanais agenda_slots_bloqueados_semanais_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_slots_bloqueados_semanais_select ON public.agenda_slots_bloqueados_semanais FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_slots_bloqueados_semanais agenda_slots_bloqueados_semanais_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_slots_bloqueados_semanais_write ON public.agenda_slots_bloqueados_semanais USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agenda_slots_regras; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agenda_slots_regras ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_slots_regras agenda_slots_regras_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_slots_regras_select ON public.agenda_slots_regras FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: agenda_slots_regras agenda_slots_regras_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agenda_slots_regras_write ON public.agenda_slots_regras USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: agendador_configuracoes agendador_cfg_public_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_cfg_public_read ON public.agendador_configuracoes FOR SELECT TO anon USING (((ativo = true) AND (link_slug IS NOT NULL))); -- -- Name: agendador_configuracoes agendador_cfg_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_cfg_select ON public.agendador_configuracoes FOR SELECT USING ((auth.uid() = owner_id)); -- -- Name: agendador_configuracoes agendador_cfg_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_cfg_write ON public.agendador_configuracoes USING ((auth.uid() = owner_id)) WITH CHECK ((auth.uid() = owner_id)); -- -- Name: agendador_configuracoes; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agendador_configuracoes ENABLE ROW LEVEL SECURITY; -- -- Name: agendador_solicitacoes agendador_sol_owner_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_sol_owner_select ON public.agendador_solicitacoes FOR SELECT USING ((auth.uid() = owner_id)); -- -- Name: agendador_solicitacoes agendador_sol_owner_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_sol_owner_write ON public.agendador_solicitacoes USING ((auth.uid() = owner_id)) WITH CHECK ((auth.uid() = owner_id)); -- -- Name: agendador_solicitacoes agendador_sol_patient_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_sol_patient_read ON public.agendador_solicitacoes FOR SELECT TO authenticated USING (((auth.uid() = user_id) OR (auth.uid() = owner_id))); -- -- Name: agendador_solicitacoes agendador_sol_public_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY agendador_sol_public_insert ON public.agendador_solicitacoes FOR INSERT TO anon WITH CHECK (true); -- -- Name: agendador_solicitacoes; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.agendador_solicitacoes ENABLE ROW LEVEL SECURITY; -- -- Name: billing_contracts; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.billing_contracts ENABLE ROW LEVEL SECURITY; -- -- Name: billing_contracts billing_contracts: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "billing_contracts: owner full access" ON public.billing_contracts USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_bloqueios bloqueios_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY bloqueios_delete ON public.agenda_bloqueios FOR DELETE TO authenticated USING ((owner_id = auth.uid())); -- -- Name: agenda_bloqueios bloqueios_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY bloqueios_insert ON public.agenda_bloqueios FOR INSERT TO authenticated WITH CHECK ((owner_id = auth.uid())); -- -- Name: agenda_bloqueios bloqueios_select_clinic; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY bloqueios_select_clinic ON public.agenda_bloqueios FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT tenant_members.tenant_id FROM public.tenant_members WHERE ((tenant_members.user_id = auth.uid()) AND (tenant_members.role = ANY (ARRAY['admin'::text, 'clinic_admin'::text, 'tenant_admin'::text, 'secretary'::text])))))); -- -- Name: agenda_bloqueios bloqueios_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY bloqueios_select_own ON public.agenda_bloqueios FOR SELECT TO authenticated USING ((owner_id = auth.uid())); -- -- Name: agenda_bloqueios bloqueios_update; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY bloqueios_update ON public.agenda_bloqueios FOR UPDATE TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: saas_docs clinic_admin_read_all_docs; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY clinic_admin_read_all_docs ON public.saas_docs FOR SELECT TO authenticated USING (((ativo = true) AND (EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = ANY (ARRAY['clinic_admin'::text, 'tenant_admin'::text]))))))); -- -- Name: commitment_services; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.commitment_services ENABLE ROW LEVEL SECURITY; -- -- Name: commitment_services commitment_services: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "commitment_services: owner full access" ON public.commitment_services USING ((EXISTS ( SELECT 1 FROM public.services s WHERE ((s.id = commitment_services.service_id) AND (s.owner_id = auth.uid()))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.services s WHERE ((s.id = commitment_services.service_id) AND (s.owner_id = auth.uid()))))); -- -- Name: commitment_time_logs; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.commitment_time_logs ENABLE ROW LEVEL SECURITY; -- -- Name: commitment_time_logs ctl_delete_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ctl_delete_for_active_member ON public.commitment_time_logs FOR DELETE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = commitment_time_logs.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: commitment_time_logs ctl_insert_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ctl_insert_for_active_member ON public.commitment_time_logs FOR INSERT TO authenticated WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = commitment_time_logs.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: commitment_time_logs ctl_select_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ctl_select_for_active_member ON public.commitment_time_logs FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = commitment_time_logs.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: commitment_time_logs ctl_update_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ctl_update_for_active_member ON public.commitment_time_logs FOR UPDATE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = commitment_time_logs.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = commitment_time_logs.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitments dc_delete_custom_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dc_delete_custom_for_active_member ON public.determined_commitments FOR DELETE TO authenticated USING (((is_native = false) AND (EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitments.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text)))))); -- -- Name: determined_commitments dc_insert_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dc_insert_for_active_member ON public.determined_commitments FOR INSERT TO authenticated WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitments.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitments dc_select_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dc_select_for_active_member ON public.determined_commitments FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitments.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitments dc_update_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dc_update_for_active_member ON public.determined_commitments FOR UPDATE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitments.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitments.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitment_fields dcf_delete_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dcf_delete_for_active_member ON public.determined_commitment_fields FOR DELETE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitment_fields.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitment_fields dcf_insert_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dcf_insert_for_active_member ON public.determined_commitment_fields FOR INSERT TO authenticated WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitment_fields.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitment_fields dcf_select_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dcf_select_for_active_member ON public.determined_commitment_fields FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitment_fields.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: determined_commitment_fields dcf_update_for_active_member; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dcf_update_for_active_member ON public.determined_commitment_fields FOR UPDATE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitment_fields.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = determined_commitment_fields.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text))))); -- -- Name: agenda_bloqueios delete own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "delete own" ON public.agenda_bloqueios FOR DELETE USING ((owner_id = auth.uid())); -- -- Name: determined_commitment_fields; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.determined_commitment_fields ENABLE ROW LEVEL SECURITY; -- -- Name: determined_commitments; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.determined_commitments ENABLE ROW LEVEL SECURITY; -- -- Name: dev_user_credentials dev_creds_select_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dev_creds_select_saas_admin ON public.dev_user_credentials FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.profiles p WHERE ((p.id = auth.uid()) AND (p.role = 'saas_admin'::text))))); -- -- Name: dev_user_credentials dev_creds_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY dev_creds_write_saas_admin ON public.dev_user_credentials TO authenticated USING ((EXISTS ( SELECT 1 FROM public.profiles p WHERE ((p.id = auth.uid()) AND (p.role = 'saas_admin'::text))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.profiles p WHERE ((p.id = auth.uid()) AND (p.role = 'saas_admin'::text))))); -- -- Name: dev_user_credentials; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.dev_user_credentials ENABLE ROW LEVEL SECURITY; -- -- Name: entitlements_invalidation ent_inv_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ent_inv_select_own ON public.entitlements_invalidation FOR SELECT USING (((owner_id = auth.uid()) OR public.is_saas_admin())); -- -- Name: entitlements_invalidation ent_inv_update_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ent_inv_update_saas ON public.entitlements_invalidation FOR UPDATE USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: entitlements_invalidation ent_inv_write_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY ent_inv_write_saas ON public.entitlements_invalidation FOR INSERT WITH CHECK (public.is_saas_admin()); -- -- Name: entitlements_invalidation; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.entitlements_invalidation ENABLE ROW LEVEL SECURITY; -- -- Name: saas_faq faq_admin_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY faq_admin_write ON public.saas_faq TO authenticated USING ((EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = ANY (ARRAY['saas_admin'::text, 'tenant_admin'::text, 'clinic_admin'::text])))))); -- -- Name: saas_faq faq_auth_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY faq_auth_read ON public.saas_faq FOR SELECT TO authenticated USING ((ativo = true)); -- -- Name: saas_faq_itens faq_itens_admin_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY faq_itens_admin_write ON public.saas_faq_itens TO authenticated USING ((EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = ANY (ARRAY['saas_admin'::text, 'tenant_admin'::text, 'clinic_admin'::text])))))); -- -- Name: saas_faq_itens faq_itens_auth_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY faq_itens_auth_read ON public.saas_faq_itens FOR SELECT TO authenticated USING (((ativo = true) AND (EXISTS ( SELECT 1 FROM public.saas_docs d WHERE ((d.id = saas_faq_itens.doc_id) AND (d.ativo = true)))))); -- -- Name: saas_faq faq_public_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY faq_public_read ON public.saas_faq FOR SELECT USING (((publico = true) AND (ativo = true))); -- -- Name: features; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.features ENABLE ROW LEVEL SECURITY; -- -- Name: features features_read_authenticated; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY features_read_authenticated ON public.features FOR SELECT TO authenticated USING (true); -- -- Name: features features_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY features_write_saas_admin ON public.features TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: feriados; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.feriados ENABLE ROW LEVEL SECURITY; -- -- Name: feriados feriados_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_delete ON public.feriados FOR DELETE USING ((owner_id = auth.uid())); -- -- Name: feriados feriados_global_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_global_select ON public.feriados FOR SELECT USING ((tenant_id IS NULL)); -- -- Name: feriados feriados_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_insert ON public.feriados FOR INSERT WITH CHECK ((tenant_id IN ( SELECT tenant_members.tenant_id FROM public.tenant_members WHERE (tenant_members.user_id = auth.uid())))); -- -- Name: feriados feriados_saas_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_saas_delete ON public.feriados FOR DELETE USING ((EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid())))); -- -- Name: feriados feriados_saas_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_saas_insert ON public.feriados FOR INSERT WITH CHECK ((EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid())))); -- -- Name: feriados feriados_saas_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_saas_select ON public.feriados FOR SELECT USING ((EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid())))); -- -- Name: feriados feriados_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY feriados_select ON public.feriados FOR SELECT USING ((tenant_id IN ( SELECT tenant_members.tenant_id FROM public.tenant_members WHERE (tenant_members.user_id = auth.uid())))); -- -- Name: financial_exceptions; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.financial_exceptions ENABLE ROW LEVEL SECURITY; -- -- Name: financial_exceptions financial_exceptions: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "financial_exceptions: owner full access" ON public.financial_exceptions USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: financial_exceptions financial_exceptions: tenant members read clinic rules; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "financial_exceptions: tenant members read clinic rules" ON public.financial_exceptions FOR SELECT USING (((owner_id IS NULL) AND (EXISTS ( SELECT 1 FROM public.owner_users ou WHERE ((ou.owner_id = financial_exceptions.tenant_id) AND (ou.user_id = auth.uid())))))); -- -- Name: agenda_bloqueios insert own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "insert own" ON public.agenda_bloqueios FOR INSERT WITH CHECK ((owner_id = auth.uid())); -- -- Name: insurance_plan_services; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.insurance_plan_services ENABLE ROW LEVEL SECURITY; -- -- Name: insurance_plan_services insurance_plan_services_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY insurance_plan_services_owner ON public.insurance_plan_services USING ((EXISTS ( SELECT 1 FROM public.insurance_plans ip WHERE ((ip.id = insurance_plan_services.insurance_plan_id) AND (ip.owner_id = auth.uid()))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.insurance_plans ip WHERE ((ip.id = insurance_plan_services.insurance_plan_id) AND (ip.owner_id = auth.uid()))))); -- -- Name: insurance_plans; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.insurance_plans ENABLE ROW LEVEL SECURITY; -- -- Name: insurance_plans insurance_plans: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "insurance_plans: owner full access" ON public.insurance_plans USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: module_features; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.module_features ENABLE ROW LEVEL SECURITY; -- -- Name: module_features module_features_read_authenticated; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY module_features_read_authenticated ON public.module_features FOR SELECT TO authenticated USING (true); -- -- Name: module_features module_features_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY module_features_write_saas_admin ON public.module_features TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: modules; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.modules ENABLE ROW LEVEL SECURITY; -- -- Name: modules modules_read_authenticated; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY modules_read_authenticated ON public.modules FOR SELECT TO authenticated USING (true); -- -- Name: modules modules_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY modules_write_saas_admin ON public.modules TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: owner_users; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.owner_users ENABLE ROW LEVEL SECURITY; -- -- Name: owner_users owner_users: user can read own links; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "owner_users: user can read own links" ON public.owner_users FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: patient_discounts; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_discounts ENABLE ROW LEVEL SECURITY; -- -- Name: patient_discounts patient_discounts: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "patient_discounts: owner full access" ON public.patient_discounts USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_group_patient; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_group_patient ENABLE ROW LEVEL SECURITY; -- -- Name: patient_group_patient patient_group_patient_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_group_patient_owner_all ON public.patient_group_patient TO authenticated USING ((EXISTS ( SELECT 1 FROM public.patients p WHERE ((p.id = patient_group_patient.patient_id) AND (p.owner_id = auth.uid()))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.patients p WHERE ((p.id = patient_group_patient.patient_id) AND (p.owner_id = auth.uid()))))); -- -- Name: patient_group_patient patient_group_patient_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_group_patient_select ON public.patient_group_patient FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_group_patient patient_group_patient_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_group_patient_write ON public.patient_group_patient USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patient_groups; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_groups ENABLE ROW LEVEL SECURITY; -- -- Name: patient_groups patient_groups_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_groups_owner_all ON public.patient_groups TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_groups patient_groups_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_groups_select ON public.patient_groups FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_groups patient_groups_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_groups_write ON public.patient_groups USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patient_intake_requests; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_intake_requests ENABLE ROW LEVEL SECURITY; -- -- Name: patient_intake_requests patient_intake_requests_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_intake_requests_owner_all ON public.patient_intake_requests TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_intake_requests patient_intake_requests_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_intake_requests_select ON public.patient_intake_requests FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_intake_requests patient_intake_requests_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_intake_requests_write ON public.patient_intake_requests USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patient_invites; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_invites ENABLE ROW LEVEL SECURITY; -- -- Name: patient_invites patient_invites_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_invites_owner_all ON public.patient_invites TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_invites patient_invites_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_invites_select ON public.patient_invites FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_invites patient_invites_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_invites_write ON public.patient_invites USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patient_patient_tag; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_patient_tag ENABLE ROW LEVEL SECURITY; -- -- Name: patient_patient_tag patient_patient_tag_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_patient_tag_owner_all ON public.patient_patient_tag TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_patient_tag patient_patient_tag_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_patient_tag_select ON public.patient_patient_tag FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_patient_tag patient_patient_tag_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_patient_tag_write ON public.patient_patient_tag USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patient_tags; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patient_tags ENABLE ROW LEVEL SECURITY; -- -- Name: patient_tags patient_tags_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_tags_owner_all ON public.patient_tags TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patient_tags patient_tags_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_tags_select ON public.patient_tags FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patient_tags patient_tags_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patient_tags_write ON public.patient_tags USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: patients; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.patients ENABLE ROW LEVEL SECURITY; -- -- Name: patients patients_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patients_delete ON public.patients FOR DELETE USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.delete'::text))); -- -- Name: patients patients_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patients_insert ON public.patients FOR INSERT WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.create'::text))); -- -- Name: patients patients_owner_all; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patients_owner_all ON public.patients TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: patients patients_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patients_select ON public.patients FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.view'::text))); -- -- Name: patients patients_update; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY patients_update ON public.patients FOR UPDATE USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'patients.edit'::text))); -- -- Name: payment_settings; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.payment_settings ENABLE ROW LEVEL SECURITY; -- -- Name: payment_settings payment_settings: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "payment_settings: owner full access" ON public.payment_settings USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: plan_features; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.plan_features ENABLE ROW LEVEL SECURITY; -- -- Name: plan_features plan_features_read_authenticated; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY plan_features_read_authenticated ON public.plan_features FOR SELECT TO authenticated USING (true); -- -- Name: plan_features plan_features_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY plan_features_write_saas_admin ON public.plan_features TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: plans; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.plans ENABLE ROW LEVEL SECURITY; -- -- Name: plans plans_read_authenticated; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY plans_read_authenticated ON public.plans FOR SELECT TO authenticated USING (true); -- -- Name: plans plans_write_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY plans_write_saas_admin ON public.plans TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: professional_pricing; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.professional_pricing ENABLE ROW LEVEL SECURITY; -- -- Name: professional_pricing professional_pricing: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "professional_pricing: owner full access" ON public.professional_pricing USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: profiles; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY; -- -- Name: profiles profiles_insert_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY profiles_insert_own ON public.profiles FOR INSERT WITH CHECK ((id = auth.uid())); -- -- Name: profiles profiles_read_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY profiles_read_saas_admin ON public.profiles FOR SELECT USING (public.is_saas_admin()); -- -- Name: profiles profiles_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY profiles_select_own ON public.profiles FOR SELECT USING ((id = auth.uid())); -- -- Name: profiles profiles_update_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY profiles_update_own ON public.profiles FOR UPDATE USING ((id = auth.uid())) WITH CHECK ((id = auth.uid())); -- -- Name: features read features (auth); Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "read features (auth)" ON public.features FOR SELECT TO authenticated USING (true); -- -- Name: plan_features read plan_features (auth); Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "read plan_features (auth)" ON public.plan_features FOR SELECT TO authenticated USING (true); -- -- Name: plans read plans (auth); Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "read plans (auth)" ON public.plans FOR SELECT TO authenticated USING (true); -- -- Name: recurrence_exceptions; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.recurrence_exceptions ENABLE ROW LEVEL SECURITY; -- -- Name: recurrence_exceptions recurrence_exceptions_tenant; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY recurrence_exceptions_tenant ON public.recurrence_exceptions TO authenticated USING ((tenant_id IN ( SELECT tenant_members.tenant_id FROM public.tenant_members WHERE (tenant_members.user_id = auth.uid())))) WITH CHECK ((tenant_id IN ( SELECT tenant_members.tenant_id FROM public.tenant_members WHERE (tenant_members.user_id = auth.uid())))); -- -- Name: recurrence_rule_services; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.recurrence_rule_services ENABLE ROW LEVEL SECURITY; -- -- Name: recurrence_rule_services recurrence_rule_services: clinic read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "recurrence_rule_services: clinic read" ON public.recurrence_rule_services FOR SELECT USING ((EXISTS ( SELECT 1 FROM public.recurrence_rules r WHERE ((r.id = recurrence_rule_services.rule_id) AND public.is_clinic_tenant(r.tenant_id) AND public.is_tenant_member(r.tenant_id) AND public.tenant_has_feature(r.tenant_id, 'agenda.view'::text))))); -- -- Name: recurrence_rule_services recurrence_rule_services: clinic write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "recurrence_rule_services: clinic write" ON public.recurrence_rule_services USING ((EXISTS ( SELECT 1 FROM public.recurrence_rules r WHERE ((r.id = recurrence_rule_services.rule_id) AND public.is_clinic_tenant(r.tenant_id) AND public.is_tenant_member(r.tenant_id) AND public.tenant_has_feature(r.tenant_id, 'agenda.edit'::text))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.recurrence_rules r WHERE ((r.id = recurrence_rule_services.rule_id) AND public.is_clinic_tenant(r.tenant_id) AND public.is_tenant_member(r.tenant_id) AND public.tenant_has_feature(r.tenant_id, 'agenda.edit'::text))))); -- -- Name: recurrence_rule_services recurrence_rule_services: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "recurrence_rule_services: owner full access" ON public.recurrence_rule_services TO authenticated USING ((EXISTS ( SELECT 1 FROM public.recurrence_rules r WHERE ((r.id = recurrence_rule_services.rule_id) AND (r.owner_id = auth.uid()))))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.recurrence_rules r WHERE ((r.id = recurrence_rule_services.rule_id) AND (r.owner_id = auth.uid()))))); -- -- Name: recurrence_rules; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.recurrence_rules ENABLE ROW LEVEL SECURITY; -- -- Name: recurrence_rules recurrence_rules_clinic_read; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY recurrence_rules_clinic_read ON public.recurrence_rules FOR SELECT USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.view'::text))); -- -- Name: recurrence_rules recurrence_rules_clinic_write; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY recurrence_rules_clinic_write ON public.recurrence_rules USING ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))) WITH CHECK ((public.is_clinic_tenant(tenant_id) AND public.is_tenant_member(tenant_id) AND public.tenant_has_feature(tenant_id, 'agenda.edit'::text))); -- -- Name: recurrence_rules recurrence_rules_owner; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY recurrence_rules_owner ON public.recurrence_rules TO authenticated USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: subscription_intents_legacy saas_admin can read subscription_intents; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "saas_admin can read subscription_intents" ON public.subscription_intents_legacy FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.saas_admins a WHERE (a.user_id = auth.uid())))); -- -- Name: subscription_intents_legacy saas_admin can update subscription_intents; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "saas_admin can update subscription_intents" ON public.subscription_intents_legacy FOR UPDATE TO authenticated USING ((EXISTS ( SELECT 1 FROM public.saas_admins a WHERE (a.user_id = auth.uid())))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.saas_admins a WHERE (a.user_id = auth.uid())))); -- -- Name: saas_docs saas_admin_full_access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY saas_admin_full_access ON public.saas_docs TO authenticated USING ((EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid())))) WITH CHECK ((EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid())))); -- -- Name: saas_admins; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.saas_admins ENABLE ROW LEVEL SECURITY; -- -- Name: saas_admins saas_admins_select_self; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY saas_admins_select_self ON public.saas_admins FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: saas_doc_votos; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.saas_doc_votos ENABLE ROW LEVEL SECURITY; -- -- Name: saas_docs; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.saas_docs ENABLE ROW LEVEL SECURITY; -- -- Name: saas_faq; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.saas_faq ENABLE ROW LEVEL SECURITY; -- -- Name: saas_faq_itens; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.saas_faq_itens ENABLE ROW LEVEL SECURITY; -- -- Name: agenda_bloqueios select own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "select own" ON public.agenda_bloqueios FOR SELECT USING ((owner_id = auth.uid())); -- -- Name: services; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.services ENABLE ROW LEVEL SECURITY; -- -- Name: services services: owner full access; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "services: owner full access" ON public.services USING ((owner_id = auth.uid())) WITH CHECK ((owner_id = auth.uid())); -- -- Name: subscription_events; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.subscription_events ENABLE ROW LEVEL SECURITY; -- -- Name: subscription_events subscription_events_read_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscription_events_read_saas ON public.subscription_events FOR SELECT USING (public.is_saas_admin()); -- -- Name: subscription_events subscription_events_write_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscription_events_write_saas ON public.subscription_events FOR INSERT WITH CHECK (public.is_saas_admin()); -- -- Name: subscription_intents_legacy subscription_intents_insert_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscription_intents_insert_own ON public.subscription_intents_legacy FOR INSERT TO authenticated WITH CHECK ((user_id = auth.uid())); -- -- Name: subscription_intents_legacy; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.subscription_intents_legacy ENABLE ROW LEVEL SECURITY; -- -- Name: subscription_intents_legacy subscription_intents_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscription_intents_select_own ON public.subscription_intents_legacy FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: subscriptions; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.subscriptions ENABLE ROW LEVEL SECURITY; -- -- Name: subscriptions subscriptions read own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "subscriptions read own" ON public.subscriptions FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: subscriptions subscriptions: read if linked owner_users; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "subscriptions: read if linked owner_users" ON public.subscriptions FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1 FROM public.owner_users ou WHERE ((ou.owner_id = subscriptions.user_id) AND (ou.user_id = auth.uid()))))); -- -- Name: subscriptions subscriptions_insert_own_personal; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_insert_own_personal ON public.subscriptions FOR INSERT TO authenticated WITH CHECK (((user_id = auth.uid()) AND (tenant_id IS NULL))); -- -- Name: subscriptions subscriptions_no_direct_update; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_no_direct_update ON public.subscriptions FOR UPDATE TO authenticated USING (false) WITH CHECK (false); -- -- Name: subscriptions subscriptions_read_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_read_own ON public.subscriptions FOR SELECT TO authenticated USING (((user_id = auth.uid()) OR public.is_saas_admin())); -- -- Name: subscriptions subscriptions_select_for_tenant_members; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_select_for_tenant_members ON public.subscriptions FOR SELECT TO authenticated USING (((tenant_id IS NOT NULL) AND (EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = subscriptions.tenant_id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text)))))); -- -- Name: subscriptions subscriptions_select_own_personal; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_select_own_personal ON public.subscriptions FOR SELECT TO authenticated USING (((user_id = auth.uid()) AND (tenant_id IS NULL))); -- -- Name: subscriptions subscriptions_update_only_saas_admin; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY subscriptions_update_only_saas_admin ON public.subscriptions FOR UPDATE TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: support_sessions; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.support_sessions ENABLE ROW LEVEL SECURITY; -- -- Name: support_sessions support_sessions_saas_delete; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY support_sessions_saas_delete ON public.support_sessions FOR DELETE USING (((auth.uid() = admin_id) AND (EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = 'saas_admin'::text)))))); -- -- Name: support_sessions support_sessions_saas_insert; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY support_sessions_saas_insert ON public.support_sessions FOR INSERT WITH CHECK (((auth.uid() = admin_id) AND (EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = 'saas_admin'::text)))))); -- -- Name: support_sessions support_sessions_saas_select; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY support_sessions_saas_select ON public.support_sessions FOR SELECT USING (((auth.uid() = admin_id) AND (EXISTS ( SELECT 1 FROM public.profiles WHERE ((profiles.id = auth.uid()) AND (profiles.role = 'saas_admin'::text)))))); -- -- Name: tenant_members; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.tenant_members ENABLE ROW LEVEL SECURITY; -- -- Name: tenant_members tenant_members_write_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tenant_members_write_saas ON public.tenant_members TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: tenant_modules; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.tenant_modules ENABLE ROW LEVEL SECURITY; -- -- Name: tenant_modules tenant_modules_read_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tenant_modules_read_own ON public.tenant_modules FOR SELECT TO authenticated USING (((owner_id = auth.uid()) OR public.is_saas_admin())); -- -- Name: tenant_modules tenant_modules_write_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tenant_modules_write_saas ON public.tenant_modules TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: tenants; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.tenants ENABLE ROW LEVEL SECURITY; -- -- Name: tenants tenants_read_members; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tenants_read_members ON public.tenants FOR SELECT TO authenticated USING ((public.is_saas_admin() OR (EXISTS ( SELECT 1 FROM public.tenant_members tm WHERE ((tm.tenant_id = tenants.id) AND (tm.user_id = auth.uid()) AND (tm.status = 'active'::text)))))); -- -- Name: tenants tenants_write_saas; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tenants_write_saas ON public.tenants TO authenticated USING (public.is_saas_admin()) WITH CHECK (public.is_saas_admin()); -- -- Name: tenant_members tm_select_admin_all_members; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tm_select_admin_all_members ON public.tenant_members FOR SELECT TO authenticated USING (public.is_tenant_admin(tenant_id)); -- -- Name: tenant_members tm_select_own_membership; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY tm_select_own_membership ON public.tenant_members FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: agenda_bloqueios update own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY "update own" ON public.agenda_bloqueios FOR UPDATE USING ((owner_id = auth.uid())); -- -- Name: user_settings; Type: ROW SECURITY; Schema: public; Owner: supabase_admin -- ALTER TABLE public.user_settings ENABLE ROW LEVEL SECURITY; -- -- Name: user_settings user_settings_insert_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY user_settings_insert_own ON public.user_settings FOR INSERT WITH CHECK ((user_id = auth.uid())); -- -- Name: user_settings user_settings_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY user_settings_select_own ON public.user_settings FOR SELECT USING ((user_id = auth.uid())); -- -- Name: user_settings user_settings_update_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY user_settings_update_own ON public.user_settings FOR UPDATE USING ((user_id = auth.uid())) WITH CHECK ((user_id = auth.uid())); -- -- Name: saas_docs users_read_usuario_docs; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY users_read_usuario_docs ON public.saas_docs FOR SELECT TO authenticated USING (((ativo = true) AND (tipo_acesso = 'usuario'::text))); -- -- Name: saas_doc_votos votos_select_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY votos_select_own ON public.saas_doc_votos FOR SELECT TO authenticated USING ((user_id = auth.uid())); -- -- Name: saas_doc_votos votos_upsert_own; Type: POLICY; Schema: public; Owner: supabase_admin -- CREATE POLICY votos_upsert_own ON public.saas_doc_votos TO authenticated USING ((user_id = auth.uid())) WITH CHECK ((user_id = auth.uid())); -- -- Name: messages; Type: ROW SECURITY; Schema: realtime; Owner: supabase_realtime_admin -- ALTER TABLE realtime.messages ENABLE ROW LEVEL SECURITY; -- -- Name: objects agendador_storage_owner_delete; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY agendador_storage_owner_delete ON storage.objects FOR DELETE TO authenticated USING (((bucket_id = 'agendador'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text))); -- -- Name: objects agendador_storage_owner_insert; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY agendador_storage_owner_insert ON storage.objects FOR INSERT TO authenticated WITH CHECK (((bucket_id = 'agendador'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text))); -- -- Name: objects agendador_storage_owner_update; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY agendador_storage_owner_update ON storage.objects FOR UPDATE TO authenticated USING (((bucket_id = 'agendador'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text))); -- -- Name: objects agendador_storage_public_read; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY agendador_storage_public_read ON storage.objects FOR SELECT USING ((bucket_id = 'agendador'::text)); -- -- Name: objects avatars_delete_own; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_delete_own ON storage.objects FOR DELETE TO authenticated USING (((bucket_id = 'avatars'::text) AND (name ~~ ((auth.uid())::text || '/%'::text)))); -- -- Name: objects avatars_delete_own_folder; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_delete_own_folder ON storage.objects FOR DELETE USING (((bucket_id = 'avatars'::text) AND (auth.role() = 'authenticated'::text) AND (name ~~ (('owners/'::text || auth.uid()) || '/%'::text)))); -- -- Name: objects avatars_insert_own; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_insert_own ON storage.objects FOR INSERT TO authenticated WITH CHECK (((bucket_id = 'avatars'::text) AND (name ~~ ((auth.uid())::text || '/%'::text)))); -- -- Name: objects avatars_insert_own_folder; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_insert_own_folder ON storage.objects FOR INSERT WITH CHECK (((bucket_id = 'avatars'::text) AND (auth.role() = 'authenticated'::text) AND (name ~~ (('owners/'::text || auth.uid()) || '/%'::text)))); -- -- Name: objects avatars_read; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_read ON storage.objects FOR SELECT USING ((bucket_id = 'avatars'::text)); -- -- Name: objects avatars_select_own; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_select_own ON storage.objects FOR SELECT TO authenticated USING (((bucket_id = 'avatars'::text) AND (name ~~ ((auth.uid())::text || '/%'::text)))); -- -- Name: objects avatars_update_own; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_update_own ON storage.objects FOR UPDATE TO authenticated USING (((bucket_id = 'avatars'::text) AND (name ~~ ((auth.uid())::text || '/%'::text)))) WITH CHECK (((bucket_id = 'avatars'::text) AND (name ~~ ((auth.uid())::text || '/%'::text)))); -- -- Name: objects avatars_update_own_folder; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY avatars_update_own_folder ON storage.objects FOR UPDATE USING (((bucket_id = 'avatars'::text) AND (auth.role() = 'authenticated'::text) AND (name ~~ (('owners/'::text || auth.uid()) || '/%'::text)))) WITH CHECK (((bucket_id = 'avatars'::text) AND (auth.role() = 'authenticated'::text) AND (name ~~ (('owners/'::text || auth.uid()) || '/%'::text)))); -- -- Name: buckets; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.buckets ENABLE ROW LEVEL SECURITY; -- -- Name: buckets_analytics; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.buckets_analytics ENABLE ROW LEVEL SECURITY; -- -- Name: buckets_vectors; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.buckets_vectors ENABLE ROW LEVEL SECURITY; -- -- Name: iceberg_namespaces; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.iceberg_namespaces ENABLE ROW LEVEL SECURITY; -- -- Name: iceberg_tables; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.iceberg_tables ENABLE ROW LEVEL SECURITY; -- -- Name: objects intake_read_anon; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY intake_read_anon ON storage.objects FOR SELECT TO anon USING (((bucket_id = 'avatars'::text) AND (name ~~ 'intakes/%'::text))); -- -- Name: objects intake_read_public; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY intake_read_public ON storage.objects FOR SELECT USING (((bucket_id = 'avatars'::text) AND (name ~~ 'intakes/%'::text))); -- -- Name: objects intake_upload_anon; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY intake_upload_anon ON storage.objects FOR INSERT TO anon WITH CHECK (((bucket_id = 'avatars'::text) AND (name ~~ 'intakes/%'::text))); -- -- Name: objects intake_upload_public; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY intake_upload_public ON storage.objects FOR INSERT WITH CHECK (((bucket_id = 'avatars'::text) AND (name ~~ 'intakes/%'::text))); -- -- Name: migrations; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.migrations ENABLE ROW LEVEL SECURITY; -- -- Name: objects; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY; -- -- Name: objects public_read; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY public_read ON storage.objects FOR SELECT USING ((bucket_id = 'saas-docs'::text)); -- -- Name: s3_multipart_uploads; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.s3_multipart_uploads ENABLE ROW LEVEL SECURITY; -- -- Name: s3_multipart_uploads_parts; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.s3_multipart_uploads_parts ENABLE ROW LEVEL SECURITY; -- -- Name: objects saas_admin_delete; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY saas_admin_delete ON storage.objects FOR DELETE TO authenticated USING (((bucket_id = 'saas-docs'::text) AND (EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid()))))); -- -- Name: objects saas_admin_upload; Type: POLICY; Schema: storage; Owner: supabase_storage_admin -- CREATE POLICY saas_admin_upload ON storage.objects FOR INSERT TO authenticated WITH CHECK (((bucket_id = 'saas-docs'::text) AND (EXISTS ( SELECT 1 FROM public.saas_admins WHERE (saas_admins.user_id = auth.uid()))))); -- -- Name: vector_indexes; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin -- ALTER TABLE storage.vector_indexes ENABLE ROW LEVEL SECURITY; -- -- Name: supabase_realtime; Type: PUBLICATION; Schema: -; Owner: postgres -- CREATE PUBLICATION supabase_realtime WITH (publish = 'insert, update, delete, truncate'); ALTER PUBLICATION supabase_realtime OWNER TO postgres; -- -- Name: SCHEMA auth; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA auth TO anon; GRANT USAGE ON SCHEMA auth TO authenticated; GRANT USAGE ON SCHEMA auth TO service_role; GRANT ALL ON SCHEMA auth TO supabase_auth_admin; GRANT ALL ON SCHEMA auth TO dashboard_user; GRANT USAGE ON SCHEMA auth TO postgres; -- -- Name: SCHEMA extensions; Type: ACL; Schema: -; Owner: postgres -- GRANT USAGE ON SCHEMA extensions TO anon; GRANT USAGE ON SCHEMA extensions TO authenticated; GRANT USAGE ON SCHEMA extensions TO service_role; GRANT ALL ON SCHEMA extensions TO dashboard_user; -- -- Name: SCHEMA net; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA net TO supabase_functions_admin; GRANT USAGE ON SCHEMA net TO postgres; GRANT USAGE ON SCHEMA net TO anon; GRANT USAGE ON SCHEMA net TO authenticated; GRANT USAGE ON SCHEMA net TO service_role; -- -- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner -- GRANT USAGE ON SCHEMA public TO postgres; GRANT USAGE ON SCHEMA public TO anon; GRANT USAGE ON SCHEMA public TO authenticated; GRANT USAGE ON SCHEMA public TO service_role; -- -- Name: SCHEMA realtime; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA realtime TO postgres; GRANT USAGE ON SCHEMA realtime TO anon; GRANT USAGE ON SCHEMA realtime TO authenticated; GRANT USAGE ON SCHEMA realtime TO service_role; GRANT ALL ON SCHEMA realtime TO supabase_realtime_admin; -- -- Name: SCHEMA storage; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA storage TO postgres WITH GRANT OPTION; GRANT USAGE ON SCHEMA storage TO anon; GRANT USAGE ON SCHEMA storage TO authenticated; GRANT USAGE ON SCHEMA storage TO service_role; GRANT ALL ON SCHEMA storage TO supabase_storage_admin WITH GRANT OPTION; GRANT ALL ON SCHEMA storage TO dashboard_user; -- -- Name: SCHEMA supabase_functions; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA supabase_functions TO postgres; GRANT USAGE ON SCHEMA supabase_functions TO anon; GRANT USAGE ON SCHEMA supabase_functions TO authenticated; GRANT USAGE ON SCHEMA supabase_functions TO service_role; GRANT ALL ON SCHEMA supabase_functions TO supabase_functions_admin; -- -- Name: SCHEMA vault; Type: ACL; Schema: -; Owner: supabase_admin -- GRANT USAGE ON SCHEMA vault TO postgres WITH GRANT OPTION; GRANT USAGE ON SCHEMA vault TO service_role; -- -- Name: FUNCTION citextin(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citextin(cstring) TO postgres; GRANT ALL ON FUNCTION public.citextin(cstring) TO anon; GRANT ALL ON FUNCTION public.citextin(cstring) TO authenticated; GRANT ALL ON FUNCTION public.citextin(cstring) TO service_role; -- -- Name: FUNCTION citextout(public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citextout(public.citext) TO postgres; GRANT ALL ON FUNCTION public.citextout(public.citext) TO anon; GRANT ALL ON FUNCTION public.citextout(public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citextout(public.citext) TO service_role; -- -- Name: FUNCTION citextrecv(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citextrecv(internal) TO postgres; GRANT ALL ON FUNCTION public.citextrecv(internal) TO anon; GRANT ALL ON FUNCTION public.citextrecv(internal) TO authenticated; GRANT ALL ON FUNCTION public.citextrecv(internal) TO service_role; -- -- Name: FUNCTION citextsend(public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citextsend(public.citext) TO postgres; GRANT ALL ON FUNCTION public.citextsend(public.citext) TO anon; GRANT ALL ON FUNCTION public.citextsend(public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citextsend(public.citext) TO service_role; -- -- Name: FUNCTION gbtreekey16_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey16_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey16_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey16_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey16_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey16_out(public.gbtreekey16); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey16_out(public.gbtreekey16) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey16_out(public.gbtreekey16) TO anon; GRANT ALL ON FUNCTION public.gbtreekey16_out(public.gbtreekey16) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey16_out(public.gbtreekey16) TO service_role; -- -- Name: FUNCTION gbtreekey2_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey2_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey2_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey2_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey2_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey2_out(public.gbtreekey2); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey2_out(public.gbtreekey2) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey2_out(public.gbtreekey2) TO anon; GRANT ALL ON FUNCTION public.gbtreekey2_out(public.gbtreekey2) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey2_out(public.gbtreekey2) TO service_role; -- -- Name: FUNCTION gbtreekey32_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey32_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey32_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey32_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey32_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey32_out(public.gbtreekey32); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey32_out(public.gbtreekey32) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey32_out(public.gbtreekey32) TO anon; GRANT ALL ON FUNCTION public.gbtreekey32_out(public.gbtreekey32) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey32_out(public.gbtreekey32) TO service_role; -- -- Name: FUNCTION gbtreekey4_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey4_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey4_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey4_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey4_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey4_out(public.gbtreekey4); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey4_out(public.gbtreekey4) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey4_out(public.gbtreekey4) TO anon; GRANT ALL ON FUNCTION public.gbtreekey4_out(public.gbtreekey4) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey4_out(public.gbtreekey4) TO service_role; -- -- Name: FUNCTION gbtreekey8_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey8_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey8_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey8_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey8_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey8_out(public.gbtreekey8); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey8_out(public.gbtreekey8) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey8_out(public.gbtreekey8) TO anon; GRANT ALL ON FUNCTION public.gbtreekey8_out(public.gbtreekey8) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey8_out(public.gbtreekey8) TO service_role; -- -- Name: FUNCTION gbtreekey_var_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey_var_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey_var_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gbtreekey_var_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey_var_in(cstring) TO service_role; -- -- Name: FUNCTION gbtreekey_var_out(public.gbtreekey_var); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbtreekey_var_out(public.gbtreekey_var) TO postgres; GRANT ALL ON FUNCTION public.gbtreekey_var_out(public.gbtreekey_var) TO anon; GRANT ALL ON FUNCTION public.gbtreekey_var_out(public.gbtreekey_var) TO authenticated; GRANT ALL ON FUNCTION public.gbtreekey_var_out(public.gbtreekey_var) TO service_role; -- -- Name: FUNCTION gtrgm_in(cstring); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_in(cstring) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_in(cstring) TO anon; GRANT ALL ON FUNCTION public.gtrgm_in(cstring) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_in(cstring) TO service_role; -- -- Name: FUNCTION gtrgm_out(public.gtrgm); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_out(public.gtrgm) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_out(public.gtrgm) TO anon; GRANT ALL ON FUNCTION public.gtrgm_out(public.gtrgm) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_out(public.gtrgm) TO service_role; -- -- Name: FUNCTION citext(boolean); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext(boolean) TO postgres; GRANT ALL ON FUNCTION public.citext(boolean) TO anon; GRANT ALL ON FUNCTION public.citext(boolean) TO authenticated; GRANT ALL ON FUNCTION public.citext(boolean) TO service_role; -- -- Name: FUNCTION citext(character); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext(character) TO postgres; GRANT ALL ON FUNCTION public.citext(character) TO anon; GRANT ALL ON FUNCTION public.citext(character) TO authenticated; GRANT ALL ON FUNCTION public.citext(character) TO service_role; -- -- Name: FUNCTION citext(inet); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext(inet) TO postgres; GRANT ALL ON FUNCTION public.citext(inet) TO anon; GRANT ALL ON FUNCTION public.citext(inet) TO authenticated; GRANT ALL ON FUNCTION public.citext(inet) TO service_role; -- -- Name: FUNCTION email(); Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON FUNCTION auth.email() TO dashboard_user; -- -- Name: FUNCTION jwt(); Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON FUNCTION auth.jwt() TO postgres; GRANT ALL ON FUNCTION auth.jwt() TO dashboard_user; -- -- Name: FUNCTION role(); Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON FUNCTION auth.role() TO dashboard_user; -- -- Name: FUNCTION uid(); Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON FUNCTION auth.uid() TO dashboard_user; -- -- Name: FUNCTION armor(bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.armor(bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.armor(bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION armor(bytea, text[], text[]); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.armor(bytea, text[], text[]) TO dashboard_user; GRANT ALL ON FUNCTION extensions.armor(bytea, text[], text[]) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION crypt(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.crypt(text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.crypt(text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION dearmor(text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.dearmor(text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.dearmor(text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION decrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.decrypt(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.decrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION decrypt_iv(bytea, bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION digest(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.digest(bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.digest(bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION digest(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.digest(text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.digest(text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION encrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.encrypt(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.encrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION encrypt_iv(bytea, bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION gen_random_bytes(integer); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.gen_random_bytes(integer) TO dashboard_user; GRANT ALL ON FUNCTION extensions.gen_random_bytes(integer) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION gen_random_uuid(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.gen_random_uuid() TO dashboard_user; GRANT ALL ON FUNCTION extensions.gen_random_uuid() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION gen_salt(text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.gen_salt(text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.gen_salt(text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION gen_salt(text, integer); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.gen_salt(text, integer) TO dashboard_user; GRANT ALL ON FUNCTION extensions.gen_salt(text, integer) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION grant_pg_cron_access(); Type: ACL; Schema: extensions; Owner: supabase_admin -- REVOKE ALL ON FUNCTION extensions.grant_pg_cron_access() FROM supabase_admin; GRANT ALL ON FUNCTION extensions.grant_pg_cron_access() TO supabase_admin WITH GRANT OPTION; GRANT ALL ON FUNCTION extensions.grant_pg_cron_access() TO dashboard_user; -- -- Name: FUNCTION grant_pg_graphql_access(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.grant_pg_graphql_access() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION grant_pg_net_access(); Type: ACL; Schema: extensions; Owner: supabase_admin -- REVOKE ALL ON FUNCTION extensions.grant_pg_net_access() FROM supabase_admin; GRANT ALL ON FUNCTION extensions.grant_pg_net_access() TO supabase_admin WITH GRANT OPTION; GRANT ALL ON FUNCTION extensions.grant_pg_net_access() TO dashboard_user; -- -- Name: FUNCTION hmac(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.hmac(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.hmac(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION hmac(text, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.hmac(text, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.hmac(text, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT shared_blk_read_time double precision, OUT shared_blk_write_time double precision, OUT local_blk_read_time double precision, OUT local_blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision, OUT jit_deform_count bigint, OUT jit_deform_time double precision, OUT stats_since timestamp with time zone, OUT minmax_stats_since timestamp with time zone); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT shared_blk_read_time double precision, OUT shared_blk_write_time double precision, OUT local_blk_read_time double precision, OUT local_blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision, OUT jit_deform_count bigint, OUT jit_deform_time double precision, OUT stats_since timestamp with time zone, OUT minmax_stats_since timestamp with time zone) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pg_stat_statements_reset(userid oid, dbid oid, queryid bigint, minmax_only boolean); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pg_stat_statements_reset(userid oid, dbid oid, queryid bigint, minmax_only boolean) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_armor_headers(text, OUT key text, OUT value text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_key_id(bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_key_id(bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_key_id(bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt(bytea, bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_encrypt(text, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_encrypt(text, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_encrypt_bytea(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_decrypt(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_decrypt(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_decrypt_bytea(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_decrypt_bytea(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_encrypt(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_encrypt(text, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_encrypt_bytea(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgp_sym_encrypt_bytea(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgrst_ddl_watch(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgrst_ddl_watch() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION pgrst_drop_watch(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.pgrst_drop_watch() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION set_graphql_placeholder(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.set_graphql_placeholder() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_generate_v1(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_generate_v1() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_generate_v1() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_generate_v1mc(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_generate_v1mc() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_generate_v1mc() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_generate_v3(namespace uuid, name text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_generate_v4(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_generate_v4() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_generate_v4() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_generate_v5(namespace uuid, name text); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_nil(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_nil() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_nil() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_ns_dns(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_ns_dns() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_ns_dns() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_ns_oid(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_ns_oid() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_ns_oid() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_ns_url(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_ns_url() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_ns_url() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION uuid_ns_x500(); Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON FUNCTION extensions.uuid_ns_x500() TO dashboard_user; GRANT ALL ON FUNCTION extensions.uuid_ns_x500() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION graphql("operationName" text, query text, variables jsonb, extensions jsonb); Type: ACL; Schema: graphql_public; Owner: supabase_admin -- GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO postgres; GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO anon; GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO authenticated; GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO service_role; -- -- Name: FUNCTION http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer); Type: ACL; Schema: net; Owner: supabase_admin -- REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin; GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres; GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO anon; GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO authenticated; GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO service_role; -- -- Name: FUNCTION http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer); Type: ACL; Schema: net; Owner: supabase_admin -- REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin; GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres; GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO anon; GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO authenticated; GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO service_role; -- -- Name: FUNCTION pg_reload_conf(); Type: ACL; Schema: pg_catalog; Owner: supabase_admin -- GRANT ALL ON FUNCTION pg_catalog.pg_reload_conf() TO postgres WITH GRANT OPTION; -- -- Name: FUNCTION get_auth(p_usename text); Type: ACL; Schema: pgbouncer; Owner: supabase_admin -- REVOKE ALL ON FUNCTION pgbouncer.get_auth(p_usename text) FROM PUBLIC; GRANT ALL ON FUNCTION pgbouncer.get_auth(p_usename text) TO pgbouncer; -- -- Name: FUNCTION __rls_ping(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.__rls_ping() TO postgres; GRANT ALL ON FUNCTION public.__rls_ping() TO anon; GRANT ALL ON FUNCTION public.__rls_ping() TO authenticated; GRANT ALL ON FUNCTION public.__rls_ping() TO service_role; -- -- Name: TABLE subscriptions; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscriptions TO postgres; GRANT ALL ON TABLE public.subscriptions TO anon; GRANT ALL ON TABLE public.subscriptions TO authenticated; GRANT ALL ON TABLE public.subscriptions TO service_role; -- -- Name: FUNCTION activate_subscription_from_intent(p_intent_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) TO postgres; GRANT ALL ON FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) TO anon; GRANT ALL ON FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.activate_subscription_from_intent(p_intent_id uuid) TO service_role; -- -- Name: FUNCTION admin_fix_plan_target(p_plan_key text, p_new_target text); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) FROM PUBLIC; GRANT ALL ON FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) TO postgres; GRANT ALL ON FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) TO anon; GRANT ALL ON FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) TO authenticated; GRANT ALL ON FUNCTION public.admin_fix_plan_target(p_plan_key text, p_new_target text) TO service_role; -- -- Name: FUNCTION agenda_cfg_sync(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.agenda_cfg_sync() TO postgres; GRANT ALL ON FUNCTION public.agenda_cfg_sync() TO anon; GRANT ALL ON FUNCTION public.agenda_cfg_sync() TO authenticated; GRANT ALL ON FUNCTION public.agenda_cfg_sync() TO service_role; -- -- Name: FUNCTION agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) TO postgres; GRANT ALL ON FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) TO anon; GRANT ALL ON FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) TO authenticated; GRANT ALL ON FUNCTION public.agendador_dias_disponiveis(p_slug text, p_ano integer, p_mes integer) TO service_role; -- -- Name: FUNCTION agendador_gerar_slug(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.agendador_gerar_slug() TO postgres; GRANT ALL ON FUNCTION public.agendador_gerar_slug() TO anon; GRANT ALL ON FUNCTION public.agendador_gerar_slug() TO authenticated; GRANT ALL ON FUNCTION public.agendador_gerar_slug() TO service_role; -- -- Name: FUNCTION agendador_slots_disponiveis(p_slug text, p_data date); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) TO postgres; GRANT ALL ON FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) TO anon; GRANT ALL ON FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) TO authenticated; GRANT ALL ON FUNCTION public.agendador_slots_disponiveis(p_slug text, p_data date) TO service_role; -- -- Name: FUNCTION cancel_recurrence_from(p_recurrence_id uuid, p_from_date date); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) TO postgres; GRANT ALL ON FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) TO anon; GRANT ALL ON FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) TO authenticated; GRANT ALL ON FUNCTION public.cancel_recurrence_from(p_recurrence_id uuid, p_from_date date) TO service_role; -- -- Name: FUNCTION cancel_subscription(p_subscription_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.cancel_subscription(p_subscription_id uuid) TO postgres; GRANT ALL ON FUNCTION public.cancel_subscription(p_subscription_id uuid) TO anon; GRANT ALL ON FUNCTION public.cancel_subscription(p_subscription_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.cancel_subscription(p_subscription_id uuid) TO service_role; -- -- Name: FUNCTION cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) TO postgres; GRANT ALL ON FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) TO anon; GRANT ALL ON FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) TO authenticated; GRANT ALL ON FUNCTION public.cancelar_eventos_serie(p_serie_id uuid, p_a_partir_de timestamp with time zone) TO service_role; -- -- Name: FUNCTION cash_dist(money, money); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.cash_dist(money, money) TO postgres; GRANT ALL ON FUNCTION public.cash_dist(money, money) TO anon; GRANT ALL ON FUNCTION public.cash_dist(money, money) TO authenticated; GRANT ALL ON FUNCTION public.cash_dist(money, money) TO service_role; -- -- Name: FUNCTION change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) TO postgres; GRANT ALL ON FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) TO anon; GRANT ALL ON FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.change_subscription_plan(p_subscription_id uuid, p_new_plan_id uuid) TO service_role; -- -- Name: FUNCTION citext_cmp(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_cmp(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_cmp(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_cmp(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_cmp(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_eq(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_eq(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_eq(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_eq(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_eq(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_ge(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_ge(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_ge(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_ge(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_ge(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_gt(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_gt(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_gt(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_gt(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_gt(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_hash(public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_hash(public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_hash(public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_hash(public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_hash(public.citext) TO service_role; -- -- Name: FUNCTION citext_hash_extended(public.citext, bigint); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_hash_extended(public.citext, bigint) TO postgres; GRANT ALL ON FUNCTION public.citext_hash_extended(public.citext, bigint) TO anon; GRANT ALL ON FUNCTION public.citext_hash_extended(public.citext, bigint) TO authenticated; GRANT ALL ON FUNCTION public.citext_hash_extended(public.citext, bigint) TO service_role; -- -- Name: FUNCTION citext_larger(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_larger(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_larger(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_larger(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_larger(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_le(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_le(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_le(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_le(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_le(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_lt(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_lt(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_lt(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_lt(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_lt(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_ne(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_ne(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_ne(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_ne(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_ne(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_pattern_cmp(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_pattern_cmp(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_pattern_cmp(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_pattern_cmp(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_pattern_cmp(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_pattern_ge(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_pattern_ge(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_pattern_ge(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_pattern_ge(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_pattern_ge(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_pattern_gt(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_pattern_gt(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_pattern_gt(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_pattern_gt(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_pattern_gt(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_pattern_le(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_pattern_le(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_pattern_le(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_pattern_le(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_pattern_le(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_pattern_lt(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_pattern_lt(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_pattern_lt(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_pattern_lt(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_pattern_lt(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION citext_smaller(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.citext_smaller(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.citext_smaller(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.citext_smaller(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.citext_smaller(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION create_clinic_tenant(p_name text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.create_clinic_tenant(p_name text) TO postgres; GRANT ALL ON FUNCTION public.create_clinic_tenant(p_name text) TO anon; GRANT ALL ON FUNCTION public.create_clinic_tenant(p_name text) TO authenticated; GRANT ALL ON FUNCTION public.create_clinic_tenant(p_name text) TO service_role; -- -- Name: FUNCTION create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean) TO postgres; GRANT ALL ON FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean) TO anon; GRANT ALL ON FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean) TO authenticated; GRANT ALL ON FUNCTION public.create_patient_intake_request(p_token text, p_name text, p_email text, p_phone text, p_notes text, p_consent boolean) TO service_role; -- -- Name: FUNCTION create_patient_intake_request_v2(p_token text, p_payload jsonb); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) FROM PUBLIC; GRANT ALL ON FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) TO postgres; GRANT ALL ON FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) TO anon; GRANT ALL ON FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) TO authenticated; GRANT ALL ON FUNCTION public.create_patient_intake_request_v2(p_token text, p_payload jsonb) TO service_role; -- -- Name: FUNCTION create_support_session(p_tenant_id uuid, p_ttl_minutes integer); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer) TO postgres; GRANT ALL ON FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer) TO anon; GRANT ALL ON FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer) TO authenticated; GRANT ALL ON FUNCTION public.create_support_session(p_tenant_id uuid, p_ttl_minutes integer) TO service_role; -- -- Name: FUNCTION current_member_id(p_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.current_member_id(p_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.current_member_id(p_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.current_member_id(p_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.current_member_id(p_tenant_id uuid) TO service_role; -- -- Name: FUNCTION current_member_role(p_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.current_member_role(p_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.current_member_role(p_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.current_member_role(p_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.current_member_role(p_tenant_id uuid) TO service_role; -- -- Name: FUNCTION date_dist(date, date); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.date_dist(date, date) TO postgres; GRANT ALL ON FUNCTION public.date_dist(date, date) TO anon; GRANT ALL ON FUNCTION public.date_dist(date, date) TO authenticated; GRANT ALL ON FUNCTION public.date_dist(date, date) TO service_role; -- -- Name: FUNCTION delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid); Type: ACL; Schema: public; Owner: postgres -- GRANT ALL ON FUNCTION public.delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid) TO anon; GRANT ALL ON FUNCTION public.delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.delete_commitment_full(p_tenant_id uuid, p_commitment_id uuid) TO service_role; -- -- Name: FUNCTION delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) TO postgres; GRANT ALL ON FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) TO anon; GRANT ALL ON FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.delete_determined_commitment(p_tenant_id uuid, p_commitment_id uuid) TO service_role; -- -- Name: FUNCTION dev_list_auth_users(p_limit integer); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.dev_list_auth_users(p_limit integer) TO postgres; GRANT ALL ON FUNCTION public.dev_list_auth_users(p_limit integer) TO anon; GRANT ALL ON FUNCTION public.dev_list_auth_users(p_limit integer) TO authenticated; GRANT ALL ON FUNCTION public.dev_list_auth_users(p_limit integer) TO service_role; -- -- Name: FUNCTION dev_list_custom_users(); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.dev_list_custom_users() FROM PUBLIC; GRANT ALL ON FUNCTION public.dev_list_custom_users() TO postgres; GRANT ALL ON FUNCTION public.dev_list_custom_users() TO anon; GRANT ALL ON FUNCTION public.dev_list_custom_users() TO authenticated; GRANT ALL ON FUNCTION public.dev_list_custom_users() TO service_role; -- -- Name: FUNCTION dev_list_intent_leads(); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.dev_list_intent_leads() FROM PUBLIC; GRANT ALL ON FUNCTION public.dev_list_intent_leads() TO postgres; GRANT ALL ON FUNCTION public.dev_list_intent_leads() TO anon; GRANT ALL ON FUNCTION public.dev_list_intent_leads() TO authenticated; GRANT ALL ON FUNCTION public.dev_list_intent_leads() TO service_role; -- -- Name: FUNCTION dev_public_debug_snapshot(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.dev_public_debug_snapshot() TO postgres; GRANT ALL ON FUNCTION public.dev_public_debug_snapshot() TO anon; GRANT ALL ON FUNCTION public.dev_public_debug_snapshot() TO authenticated; GRANT ALL ON FUNCTION public.dev_public_debug_snapshot() TO service_role; -- -- Name: FUNCTION ensure_personal_tenant(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.ensure_personal_tenant() TO postgres; GRANT ALL ON FUNCTION public.ensure_personal_tenant() TO anon; GRANT ALL ON FUNCTION public.ensure_personal_tenant() TO authenticated; GRANT ALL ON FUNCTION public.ensure_personal_tenant() TO service_role; -- -- Name: FUNCTION ensure_personal_tenant_for_user(p_user_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) TO postgres; GRANT ALL ON FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) TO anon; GRANT ALL ON FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.ensure_personal_tenant_for_user(p_user_id uuid) TO service_role; -- -- Name: FUNCTION faq_votar(faq_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.faq_votar(faq_id uuid) TO postgres; GRANT ALL ON FUNCTION public.faq_votar(faq_id uuid) TO anon; GRANT ALL ON FUNCTION public.faq_votar(faq_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.faq_votar(faq_id uuid) TO service_role; -- -- Name: FUNCTION fix_all_subscription_mismatches(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.fix_all_subscription_mismatches() TO postgres; GRANT ALL ON FUNCTION public.fix_all_subscription_mismatches() TO anon; GRANT ALL ON FUNCTION public.fix_all_subscription_mismatches() TO authenticated; GRANT ALL ON FUNCTION public.fix_all_subscription_mismatches() TO service_role; -- -- Name: FUNCTION float4_dist(real, real); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.float4_dist(real, real) TO postgres; GRANT ALL ON FUNCTION public.float4_dist(real, real) TO anon; GRANT ALL ON FUNCTION public.float4_dist(real, real) TO authenticated; GRANT ALL ON FUNCTION public.float4_dist(real, real) TO service_role; -- -- Name: FUNCTION float8_dist(double precision, double precision); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.float8_dist(double precision, double precision) TO postgres; GRANT ALL ON FUNCTION public.float8_dist(double precision, double precision) TO anon; GRANT ALL ON FUNCTION public.float8_dist(double precision, double precision) TO authenticated; GRANT ALL ON FUNCTION public.float8_dist(double precision, double precision) TO service_role; -- -- Name: FUNCTION fn_agenda_regras_semanais_no_overlap(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.fn_agenda_regras_semanais_no_overlap() TO postgres; GRANT ALL ON FUNCTION public.fn_agenda_regras_semanais_no_overlap() TO anon; GRANT ALL ON FUNCTION public.fn_agenda_regras_semanais_no_overlap() TO authenticated; GRANT ALL ON FUNCTION public.fn_agenda_regras_semanais_no_overlap() TO service_role; -- -- Name: FUNCTION gbt_bit_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_bit_consistent(internal, bit, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_consistent(internal, bit, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_consistent(internal, bit, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_consistent(internal, bit, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_consistent(internal, bit, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_bit_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bit_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bit_same(public.gbtreekey_var, public.gbtreekey_var, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO service_role; -- -- Name: FUNCTION gbt_bit_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bit_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bit_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bit_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bit_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bool_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_bool_consistent(internal, boolean, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_consistent(internal, boolean, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_consistent(internal, boolean, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_consistent(internal, boolean, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_consistent(internal, boolean, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_bool_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_bool_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bool_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bool_same(public.gbtreekey2, public.gbtreekey2, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_same(public.gbtreekey2, public.gbtreekey2, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_same(public.gbtreekey2, public.gbtreekey2, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_same(public.gbtreekey2, public.gbtreekey2, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_same(public.gbtreekey2, public.gbtreekey2, internal) TO service_role; -- -- Name: FUNCTION gbt_bool_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bool_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bool_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bool_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bool_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bpchar_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bpchar_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bpchar_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bpchar_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bpchar_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_bpchar_consistent(internal, character, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bpchar_consistent(internal, character, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bpchar_consistent(internal, character, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bpchar_consistent(internal, character, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bpchar_consistent(internal, character, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_consistent(internal, bytea, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_consistent(internal, bytea, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_consistent(internal, bytea, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_consistent(internal, bytea, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_consistent(internal, bytea, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_same(public.gbtreekey_var, public.gbtreekey_var, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO service_role; -- -- Name: FUNCTION gbt_bytea_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_bytea_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_bytea_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_bytea_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_bytea_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_cash_consistent(internal, money, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_consistent(internal, money, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_consistent(internal, money, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_consistent(internal, money, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_consistent(internal, money, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_distance(internal, money, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_distance(internal, money, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_distance(internal, money, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_distance(internal, money, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_distance(internal, money, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_cash_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_cash_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_cash_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_cash_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_cash_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_cash_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_date_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_date_consistent(internal, date, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_consistent(internal, date, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_consistent(internal, date, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_consistent(internal, date, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_consistent(internal, date, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_date_distance(internal, date, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_distance(internal, date, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_distance(internal, date, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_distance(internal, date, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_distance(internal, date, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_date_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_date_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_date_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_date_same(public.gbtreekey8, public.gbtreekey8, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_same(public.gbtreekey8, public.gbtreekey8, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_same(public.gbtreekey8, public.gbtreekey8, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_same(public.gbtreekey8, public.gbtreekey8, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_same(public.gbtreekey8, public.gbtreekey8, internal) TO service_role; -- -- Name: FUNCTION gbt_date_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_date_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_date_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_date_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_date_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_decompress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_decompress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_decompress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_decompress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_decompress(internal) TO service_role; -- -- Name: FUNCTION gbt_enum_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_enum_consistent(internal, anyenum, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_consistent(internal, anyenum, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_consistent(internal, anyenum, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_consistent(internal, anyenum, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_consistent(internal, anyenum, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_enum_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_enum_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_enum_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_enum_same(public.gbtreekey8, public.gbtreekey8, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_same(public.gbtreekey8, public.gbtreekey8, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_same(public.gbtreekey8, public.gbtreekey8, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_same(public.gbtreekey8, public.gbtreekey8, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_same(public.gbtreekey8, public.gbtreekey8, internal) TO service_role; -- -- Name: FUNCTION gbt_enum_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_enum_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_enum_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_enum_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_enum_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_float4_consistent(internal, real, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_consistent(internal, real, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_consistent(internal, real, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_consistent(internal, real, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_consistent(internal, real, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_distance(internal, real, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_distance(internal, real, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_distance(internal, real, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_distance(internal, real, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_distance(internal, real, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_float4_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_same(public.gbtreekey8, public.gbtreekey8, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_same(public.gbtreekey8, public.gbtreekey8, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_same(public.gbtreekey8, public.gbtreekey8, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_same(public.gbtreekey8, public.gbtreekey8, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_same(public.gbtreekey8, public.gbtreekey8, internal) TO service_role; -- -- Name: FUNCTION gbt_float4_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float4_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float4_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float4_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float4_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_float8_consistent(internal, double precision, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_consistent(internal, double precision, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_consistent(internal, double precision, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_consistent(internal, double precision, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_consistent(internal, double precision, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_distance(internal, double precision, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_distance(internal, double precision, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_distance(internal, double precision, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_distance(internal, double precision, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_distance(internal, double precision, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_float8_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_float8_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_float8_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_float8_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_float8_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_float8_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_inet_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_inet_consistent(internal, inet, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_consistent(internal, inet, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_consistent(internal, inet, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_consistent(internal, inet, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_consistent(internal, inet, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_inet_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_inet_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_inet_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_inet_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_inet_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_inet_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_inet_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_inet_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_int2_consistent(internal, smallint, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_consistent(internal, smallint, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_consistent(internal, smallint, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_consistent(internal, smallint, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_consistent(internal, smallint, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_distance(internal, smallint, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_distance(internal, smallint, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_distance(internal, smallint, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_distance(internal, smallint, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_distance(internal, smallint, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_int2_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_same(public.gbtreekey4, public.gbtreekey4, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_same(public.gbtreekey4, public.gbtreekey4, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_same(public.gbtreekey4, public.gbtreekey4, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_same(public.gbtreekey4, public.gbtreekey4, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_same(public.gbtreekey4, public.gbtreekey4, internal) TO service_role; -- -- Name: FUNCTION gbt_int2_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int2_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int2_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int2_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int2_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_int4_consistent(internal, integer, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_consistent(internal, integer, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_consistent(internal, integer, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_consistent(internal, integer, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_consistent(internal, integer, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_distance(internal, integer, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_distance(internal, integer, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_distance(internal, integer, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_distance(internal, integer, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_distance(internal, integer, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_int4_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_same(public.gbtreekey8, public.gbtreekey8, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_same(public.gbtreekey8, public.gbtreekey8, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_same(public.gbtreekey8, public.gbtreekey8, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_same(public.gbtreekey8, public.gbtreekey8, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_same(public.gbtreekey8, public.gbtreekey8, internal) TO service_role; -- -- Name: FUNCTION gbt_int4_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int4_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int4_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int4_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int4_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_int8_consistent(internal, bigint, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_consistent(internal, bigint, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_consistent(internal, bigint, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_consistent(internal, bigint, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_consistent(internal, bigint, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_distance(internal, bigint, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_distance(internal, bigint, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_distance(internal, bigint, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_distance(internal, bigint, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_distance(internal, bigint, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_int8_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_int8_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_int8_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_int8_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_int8_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_int8_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_intv_consistent(internal, interval, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_consistent(internal, interval, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_consistent(internal, interval, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_consistent(internal, interval, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_consistent(internal, interval, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_decompress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_decompress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_decompress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_decompress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_decompress(internal) TO service_role; -- -- Name: FUNCTION gbt_intv_distance(internal, interval, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_distance(internal, interval, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_distance(internal, interval, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_distance(internal, interval, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_distance(internal, interval, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_intv_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_same(public.gbtreekey32, public.gbtreekey32, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_same(public.gbtreekey32, public.gbtreekey32, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_same(public.gbtreekey32, public.gbtreekey32, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_same(public.gbtreekey32, public.gbtreekey32, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_same(public.gbtreekey32, public.gbtreekey32, internal) TO service_role; -- -- Name: FUNCTION gbt_intv_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_intv_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_intv_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_intv_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_intv_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_consistent(internal, macaddr8, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_consistent(internal, macaddr8, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_consistent(internal, macaddr8, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_consistent(internal, macaddr8, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_consistent(internal, macaddr8, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_macad8_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad8_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad8_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad8_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad8_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_macad_consistent(internal, macaddr, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_consistent(internal, macaddr, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_consistent(internal, macaddr, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_consistent(internal, macaddr, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_consistent(internal, macaddr, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_macad_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_macad_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_macad_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_macad_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_macad_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_macad_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_macad_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_macad_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_consistent(internal, numeric, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_consistent(internal, numeric, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_consistent(internal, numeric, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_consistent(internal, numeric, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_consistent(internal, numeric, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_same(public.gbtreekey_var, public.gbtreekey_var, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO service_role; -- -- Name: FUNCTION gbt_numeric_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_numeric_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_numeric_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_numeric_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_numeric_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_oid_consistent(internal, oid, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_consistent(internal, oid, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_consistent(internal, oid, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_consistent(internal, oid, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_consistent(internal, oid, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_distance(internal, oid, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_distance(internal, oid, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_distance(internal, oid, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_distance(internal, oid, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_distance(internal, oid, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_oid_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_same(public.gbtreekey8, public.gbtreekey8, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_same(public.gbtreekey8, public.gbtreekey8, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_same(public.gbtreekey8, public.gbtreekey8, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_same(public.gbtreekey8, public.gbtreekey8, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_same(public.gbtreekey8, public.gbtreekey8, internal) TO service_role; -- -- Name: FUNCTION gbt_oid_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_oid_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_oid_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_oid_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_oid_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_text_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_text_consistent(internal, text, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_consistent(internal, text, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_consistent(internal, text, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_consistent(internal, text, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_consistent(internal, text, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_text_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_text_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_text_same(public.gbtreekey_var, public.gbtreekey_var, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_same(public.gbtreekey_var, public.gbtreekey_var, internal) TO service_role; -- -- Name: FUNCTION gbt_text_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_text_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_text_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_text_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_text_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_time_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_time_consistent(internal, time without time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_consistent(internal, time without time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_consistent(internal, time without time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_consistent(internal, time without time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_consistent(internal, time without time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_time_distance(internal, time without time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_distance(internal, time without time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_distance(internal, time without time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_distance(internal, time without time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_distance(internal, time without time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_time_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_time_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_time_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_time_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_time_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_time_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_time_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_time_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_time_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_timetz_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_timetz_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_timetz_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_timetz_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_timetz_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_timetz_consistent(internal, time with time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_timetz_consistent(internal, time with time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_timetz_consistent(internal, time with time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_timetz_consistent(internal, time with time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_timetz_consistent(internal, time with time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_ts_consistent(internal, timestamp without time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_consistent(internal, timestamp without time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_consistent(internal, timestamp without time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_consistent(internal, timestamp without time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_consistent(internal, timestamp without time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_distance(internal, timestamp without time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_distance(internal, timestamp without time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_distance(internal, timestamp without time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_distance(internal, timestamp without time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_distance(internal, timestamp without time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_ts_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_same(public.gbtreekey16, public.gbtreekey16, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_same(public.gbtreekey16, public.gbtreekey16, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_same(public.gbtreekey16, public.gbtreekey16, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_same(public.gbtreekey16, public.gbtreekey16, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_same(public.gbtreekey16, public.gbtreekey16, internal) TO service_role; -- -- Name: FUNCTION gbt_ts_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_ts_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_ts_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_ts_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_ts_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_tstz_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_tstz_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_tstz_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_tstz_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_tstz_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_tstz_consistent(internal, timestamp with time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_tstz_consistent(internal, timestamp with time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_tstz_consistent(internal, timestamp with time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_tstz_consistent(internal, timestamp with time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_tstz_consistent(internal, timestamp with time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_tstz_distance(internal, timestamp with time zone, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_tstz_distance(internal, timestamp with time zone, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_tstz_distance(internal, timestamp with time zone, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_tstz_distance(internal, timestamp with time zone, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_tstz_distance(internal, timestamp with time zone, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_compress(internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_consistent(internal, uuid, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_consistent(internal, uuid, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_consistent(internal, uuid, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_consistent(internal, uuid, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_consistent(internal, uuid, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_fetch(internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_same(public.gbtreekey32, public.gbtreekey32, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_same(public.gbtreekey32, public.gbtreekey32, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_same(public.gbtreekey32, public.gbtreekey32, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_same(public.gbtreekey32, public.gbtreekey32, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_same(public.gbtreekey32, public.gbtreekey32, internal) TO service_role; -- -- Name: FUNCTION gbt_uuid_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_uuid_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_uuid_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gbt_uuid_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_uuid_union(internal, internal) TO service_role; -- -- Name: FUNCTION gbt_var_decompress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_var_decompress(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_var_decompress(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_var_decompress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_var_decompress(internal) TO service_role; -- -- Name: FUNCTION gbt_var_fetch(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gbt_var_fetch(internal) TO postgres; GRANT ALL ON FUNCTION public.gbt_var_fetch(internal) TO anon; GRANT ALL ON FUNCTION public.gbt_var_fetch(internal) TO authenticated; GRANT ALL ON FUNCTION public.gbt_var_fetch(internal) TO service_role; -- -- Name: FUNCTION get_my_email(); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.get_my_email() FROM PUBLIC; GRANT ALL ON FUNCTION public.get_my_email() TO postgres; GRANT ALL ON FUNCTION public.get_my_email() TO anon; GRANT ALL ON FUNCTION public.get_my_email() TO authenticated; GRANT ALL ON FUNCTION public.get_my_email() TO service_role; -- -- Name: FUNCTION gin_extract_query_trgm(text, internal, smallint, internal, internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gin_extract_query_trgm(text, internal, smallint, internal, internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gin_extract_query_trgm(text, internal, smallint, internal, internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gin_extract_query_trgm(text, internal, smallint, internal, internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gin_extract_query_trgm(text, internal, smallint, internal, internal, internal, internal) TO service_role; -- -- Name: FUNCTION gin_extract_value_trgm(text, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gin_extract_value_trgm(text, internal) TO postgres; GRANT ALL ON FUNCTION public.gin_extract_value_trgm(text, internal) TO anon; GRANT ALL ON FUNCTION public.gin_extract_value_trgm(text, internal) TO authenticated; GRANT ALL ON FUNCTION public.gin_extract_value_trgm(text, internal) TO service_role; -- -- Name: FUNCTION gin_trgm_consistent(internal, smallint, text, integer, internal, internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gin_trgm_consistent(internal, smallint, text, integer, internal, internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gin_trgm_consistent(internal, smallint, text, integer, internal, internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gin_trgm_consistent(internal, smallint, text, integer, internal, internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gin_trgm_consistent(internal, smallint, text, integer, internal, internal, internal, internal) TO service_role; -- -- Name: FUNCTION gin_trgm_triconsistent(internal, smallint, text, integer, internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gin_trgm_triconsistent(internal, smallint, text, integer, internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gin_trgm_triconsistent(internal, smallint, text, integer, internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gin_trgm_triconsistent(internal, smallint, text, integer, internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gin_trgm_triconsistent(internal, smallint, text, integer, internal, internal, internal) TO service_role; -- -- Name: FUNCTION gtrgm_compress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_compress(internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_compress(internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_compress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_compress(internal) TO service_role; -- -- Name: FUNCTION gtrgm_consistent(internal, text, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_consistent(internal, text, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_consistent(internal, text, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_consistent(internal, text, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_consistent(internal, text, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gtrgm_decompress(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_decompress(internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_decompress(internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_decompress(internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_decompress(internal) TO service_role; -- -- Name: FUNCTION gtrgm_distance(internal, text, smallint, oid, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_distance(internal, text, smallint, oid, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_distance(internal, text, smallint, oid, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_distance(internal, text, smallint, oid, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_distance(internal, text, smallint, oid, internal) TO service_role; -- -- Name: FUNCTION gtrgm_options(internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_options(internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_options(internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_options(internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_options(internal) TO service_role; -- -- Name: FUNCTION gtrgm_penalty(internal, internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_penalty(internal, internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_penalty(internal, internal, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_penalty(internal, internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_penalty(internal, internal, internal) TO service_role; -- -- Name: FUNCTION gtrgm_picksplit(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_picksplit(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_picksplit(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_picksplit(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_picksplit(internal, internal) TO service_role; -- -- Name: FUNCTION gtrgm_same(public.gtrgm, public.gtrgm, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_same(public.gtrgm, public.gtrgm, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_same(public.gtrgm, public.gtrgm, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_same(public.gtrgm, public.gtrgm, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_same(public.gtrgm, public.gtrgm, internal) TO service_role; -- -- Name: FUNCTION gtrgm_union(internal, internal); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.gtrgm_union(internal, internal) TO postgres; GRANT ALL ON FUNCTION public.gtrgm_union(internal, internal) TO anon; GRANT ALL ON FUNCTION public.gtrgm_union(internal, internal) TO authenticated; GRANT ALL ON FUNCTION public.gtrgm_union(internal, internal) TO service_role; -- -- Name: FUNCTION guard_account_type_immutable(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_account_type_immutable() TO postgres; GRANT ALL ON FUNCTION public.guard_account_type_immutable() TO anon; GRANT ALL ON FUNCTION public.guard_account_type_immutable() TO authenticated; GRANT ALL ON FUNCTION public.guard_account_type_immutable() TO service_role; -- -- Name: FUNCTION guard_locked_commitment(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_locked_commitment() TO postgres; GRANT ALL ON FUNCTION public.guard_locked_commitment() TO anon; GRANT ALL ON FUNCTION public.guard_locked_commitment() TO authenticated; GRANT ALL ON FUNCTION public.guard_locked_commitment() TO service_role; -- -- Name: FUNCTION guard_no_change_core_plan_key(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_no_change_core_plan_key() TO postgres; GRANT ALL ON FUNCTION public.guard_no_change_core_plan_key() TO anon; GRANT ALL ON FUNCTION public.guard_no_change_core_plan_key() TO authenticated; GRANT ALL ON FUNCTION public.guard_no_change_core_plan_key() TO service_role; -- -- Name: FUNCTION guard_no_change_plan_target(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_no_change_plan_target() TO postgres; GRANT ALL ON FUNCTION public.guard_no_change_plan_target() TO anon; GRANT ALL ON FUNCTION public.guard_no_change_plan_target() TO authenticated; GRANT ALL ON FUNCTION public.guard_no_change_plan_target() TO service_role; -- -- Name: FUNCTION guard_no_delete_core_plans(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_no_delete_core_plans() TO postgres; GRANT ALL ON FUNCTION public.guard_no_delete_core_plans() TO anon; GRANT ALL ON FUNCTION public.guard_no_delete_core_plans() TO authenticated; GRANT ALL ON FUNCTION public.guard_no_delete_core_plans() TO service_role; -- -- Name: FUNCTION guard_patient_cannot_own_tenant(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_patient_cannot_own_tenant() TO postgres; GRANT ALL ON FUNCTION public.guard_patient_cannot_own_tenant() TO anon; GRANT ALL ON FUNCTION public.guard_patient_cannot_own_tenant() TO authenticated; GRANT ALL ON FUNCTION public.guard_patient_cannot_own_tenant() TO service_role; -- -- Name: FUNCTION guard_tenant_kind_immutable(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.guard_tenant_kind_immutable() TO postgres; GRANT ALL ON FUNCTION public.guard_tenant_kind_immutable() TO anon; GRANT ALL ON FUNCTION public.guard_tenant_kind_immutable() TO authenticated; GRANT ALL ON FUNCTION public.guard_tenant_kind_immutable() TO service_role; -- -- Name: FUNCTION handle_new_user(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.handle_new_user() TO postgres; GRANT ALL ON FUNCTION public.handle_new_user() TO anon; GRANT ALL ON FUNCTION public.handle_new_user() TO authenticated; GRANT ALL ON FUNCTION public.handle_new_user() TO service_role; -- -- Name: FUNCTION handle_new_user_create_personal_tenant(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.handle_new_user_create_personal_tenant() TO postgres; GRANT ALL ON FUNCTION public.handle_new_user_create_personal_tenant() TO anon; GRANT ALL ON FUNCTION public.handle_new_user_create_personal_tenant() TO authenticated; GRANT ALL ON FUNCTION public.handle_new_user_create_personal_tenant() TO service_role; -- -- Name: FUNCTION has_feature(p_owner_id uuid, p_feature_key text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) TO postgres; GRANT ALL ON FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) TO anon; GRANT ALL ON FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) TO authenticated; GRANT ALL ON FUNCTION public.has_feature(p_owner_id uuid, p_feature_key text) TO service_role; -- -- Name: FUNCTION int2_dist(smallint, smallint); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.int2_dist(smallint, smallint) TO postgres; GRANT ALL ON FUNCTION public.int2_dist(smallint, smallint) TO anon; GRANT ALL ON FUNCTION public.int2_dist(smallint, smallint) TO authenticated; GRANT ALL ON FUNCTION public.int2_dist(smallint, smallint) TO service_role; -- -- Name: FUNCTION int4_dist(integer, integer); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.int4_dist(integer, integer) TO postgres; GRANT ALL ON FUNCTION public.int4_dist(integer, integer) TO anon; GRANT ALL ON FUNCTION public.int4_dist(integer, integer) TO authenticated; GRANT ALL ON FUNCTION public.int4_dist(integer, integer) TO service_role; -- -- Name: FUNCTION int8_dist(bigint, bigint); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.int8_dist(bigint, bigint) TO postgres; GRANT ALL ON FUNCTION public.int8_dist(bigint, bigint) TO anon; GRANT ALL ON FUNCTION public.int8_dist(bigint, bigint) TO authenticated; GRANT ALL ON FUNCTION public.int8_dist(bigint, bigint) TO service_role; -- -- Name: FUNCTION interval_dist(interval, interval); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.interval_dist(interval, interval) TO postgres; GRANT ALL ON FUNCTION public.interval_dist(interval, interval) TO anon; GRANT ALL ON FUNCTION public.interval_dist(interval, interval) TO authenticated; GRANT ALL ON FUNCTION public.interval_dist(interval, interval) TO service_role; -- -- Name: FUNCTION is_clinic_tenant(_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.is_clinic_tenant(_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.is_clinic_tenant(_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.is_clinic_tenant(_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.is_clinic_tenant(_tenant_id uuid) TO service_role; -- -- Name: FUNCTION is_saas_admin(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.is_saas_admin() TO postgres; GRANT ALL ON FUNCTION public.is_saas_admin() TO anon; GRANT ALL ON FUNCTION public.is_saas_admin() TO authenticated; GRANT ALL ON FUNCTION public.is_saas_admin() TO service_role; -- -- Name: FUNCTION is_tenant_admin(p_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.is_tenant_admin(p_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.is_tenant_admin(p_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.is_tenant_admin(p_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.is_tenant_admin(p_tenant_id uuid) TO service_role; -- -- Name: FUNCTION is_tenant_member(_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.is_tenant_member(_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.is_tenant_member(_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.is_tenant_member(_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.is_tenant_member(_tenant_id uuid) TO service_role; -- -- Name: FUNCTION is_therapist_tenant(_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.is_therapist_tenant(_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.is_therapist_tenant(_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.is_therapist_tenant(_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.is_therapist_tenant(_tenant_id uuid) TO service_role; -- -- Name: FUNCTION jwt_email(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.jwt_email() TO postgres; GRANT ALL ON FUNCTION public.jwt_email() TO anon; GRANT ALL ON FUNCTION public.jwt_email() TO authenticated; GRANT ALL ON FUNCTION public.jwt_email() TO service_role; -- -- Name: FUNCTION my_tenants(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.my_tenants() TO postgres; GRANT ALL ON FUNCTION public.my_tenants() TO anon; GRANT ALL ON FUNCTION public.my_tenants() TO authenticated; GRANT ALL ON FUNCTION public.my_tenants() TO service_role; -- -- Name: FUNCTION oid_dist(oid, oid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.oid_dist(oid, oid) TO postgres; GRANT ALL ON FUNCTION public.oid_dist(oid, oid) TO anon; GRANT ALL ON FUNCTION public.oid_dist(oid, oid) TO authenticated; GRANT ALL ON FUNCTION public.oid_dist(oid, oid) TO service_role; -- -- Name: FUNCTION on_new_user_seed_patient_groups(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.on_new_user_seed_patient_groups() TO postgres; GRANT ALL ON FUNCTION public.on_new_user_seed_patient_groups() TO anon; GRANT ALL ON FUNCTION public.on_new_user_seed_patient_groups() TO authenticated; GRANT ALL ON FUNCTION public.on_new_user_seed_patient_groups() TO service_role; -- -- Name: FUNCTION patients_validate_member_consistency(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.patients_validate_member_consistency() TO postgres; GRANT ALL ON FUNCTION public.patients_validate_member_consistency() TO anon; GRANT ALL ON FUNCTION public.patients_validate_member_consistency() TO authenticated; GRANT ALL ON FUNCTION public.patients_validate_member_consistency() TO service_role; -- -- Name: FUNCTION patients_validate_responsible_member_tenant(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.patients_validate_responsible_member_tenant() TO postgres; GRANT ALL ON FUNCTION public.patients_validate_responsible_member_tenant() TO anon; GRANT ALL ON FUNCTION public.patients_validate_responsible_member_tenant() TO authenticated; GRANT ALL ON FUNCTION public.patients_validate_responsible_member_tenant() TO service_role; -- -- Name: FUNCTION prevent_promoting_to_system(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.prevent_promoting_to_system() TO postgres; GRANT ALL ON FUNCTION public.prevent_promoting_to_system() TO anon; GRANT ALL ON FUNCTION public.prevent_promoting_to_system() TO authenticated; GRANT ALL ON FUNCTION public.prevent_promoting_to_system() TO service_role; -- -- Name: FUNCTION prevent_saas_membership(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.prevent_saas_membership() TO postgres; GRANT ALL ON FUNCTION public.prevent_saas_membership() TO anon; GRANT ALL ON FUNCTION public.prevent_saas_membership() TO authenticated; GRANT ALL ON FUNCTION public.prevent_saas_membership() TO service_role; -- -- Name: FUNCTION prevent_system_group_changes(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.prevent_system_group_changes() TO postgres; GRANT ALL ON FUNCTION public.prevent_system_group_changes() TO anon; GRANT ALL ON FUNCTION public.prevent_system_group_changes() TO authenticated; GRANT ALL ON FUNCTION public.prevent_system_group_changes() TO service_role; -- -- Name: FUNCTION provision_account_tenant(p_user_id uuid, p_kind text, p_name text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) TO postgres; GRANT ALL ON FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) TO anon; GRANT ALL ON FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) TO authenticated; GRANT ALL ON FUNCTION public.provision_account_tenant(p_user_id uuid, p_kind text, p_name text) TO service_role; -- -- Name: FUNCTION reactivate_subscription(p_subscription_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.reactivate_subscription(p_subscription_id uuid) TO postgres; GRANT ALL ON FUNCTION public.reactivate_subscription(p_subscription_id uuid) TO anon; GRANT ALL ON FUNCTION public.reactivate_subscription(p_subscription_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.reactivate_subscription(p_subscription_id uuid) TO service_role; -- -- Name: FUNCTION rebuild_owner_entitlements(p_owner_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) TO postgres; GRANT ALL ON FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) TO anon; GRANT ALL ON FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.rebuild_owner_entitlements(p_owner_id uuid) TO service_role; -- -- Name: FUNCTION regexp_match(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION regexp_match(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_match(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION regexp_matches(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION regexp_matches(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_matches(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION regexp_replace(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION regexp_replace(public.citext, public.citext, text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text, text) TO anon; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_replace(public.citext, public.citext, text, text) TO service_role; -- -- Name: FUNCTION regexp_split_to_array(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION regexp_split_to_array(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_split_to_array(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION regexp_split_to_table(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION regexp_split_to_table(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.regexp_split_to_table(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION replace(public.citext, public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.replace(public.citext, public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.replace(public.citext, public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.replace(public.citext, public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.replace(public.citext, public.citext, public.citext) TO service_role; -- -- Name: FUNCTION revoke_support_session(p_token text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.revoke_support_session(p_token text) TO postgres; GRANT ALL ON FUNCTION public.revoke_support_session(p_token text) TO anon; GRANT ALL ON FUNCTION public.revoke_support_session(p_token text) TO authenticated; GRANT ALL ON FUNCTION public.revoke_support_session(p_token text) TO service_role; -- -- Name: FUNCTION rotate_patient_invite_token(p_new_token text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.rotate_patient_invite_token(p_new_token text) TO postgres; GRANT ALL ON FUNCTION public.rotate_patient_invite_token(p_new_token text) TO anon; GRANT ALL ON FUNCTION public.rotate_patient_invite_token(p_new_token text) TO authenticated; GRANT ALL ON FUNCTION public.rotate_patient_invite_token(p_new_token text) TO service_role; -- -- Name: FUNCTION saas_votar_doc(p_doc_id uuid, p_util boolean); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) TO postgres; GRANT ALL ON FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) TO anon; GRANT ALL ON FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) TO authenticated; GRANT ALL ON FUNCTION public.saas_votar_doc(p_doc_id uuid, p_util boolean) TO service_role; -- -- Name: FUNCTION seed_determined_commitments(p_tenant_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.seed_determined_commitments(p_tenant_id uuid) TO postgres; GRANT ALL ON FUNCTION public.seed_determined_commitments(p_tenant_id uuid) TO anon; GRANT ALL ON FUNCTION public.seed_determined_commitments(p_tenant_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.seed_determined_commitments(p_tenant_id uuid) TO service_role; -- -- Name: FUNCTION set_insurance_plans_updated_at(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_insurance_plans_updated_at() TO postgres; GRANT ALL ON FUNCTION public.set_insurance_plans_updated_at() TO anon; GRANT ALL ON FUNCTION public.set_insurance_plans_updated_at() TO authenticated; GRANT ALL ON FUNCTION public.set_insurance_plans_updated_at() TO service_role; -- -- Name: FUNCTION set_limit(real); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_limit(real) TO postgres; GRANT ALL ON FUNCTION public.set_limit(real) TO anon; GRANT ALL ON FUNCTION public.set_limit(real) TO authenticated; GRANT ALL ON FUNCTION public.set_limit(real) TO service_role; -- -- Name: FUNCTION set_owner_id(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_owner_id() TO postgres; GRANT ALL ON FUNCTION public.set_owner_id() TO anon; GRANT ALL ON FUNCTION public.set_owner_id() TO authenticated; GRANT ALL ON FUNCTION public.set_owner_id() TO service_role; -- -- Name: FUNCTION set_services_updated_at(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_services_updated_at() TO postgres; GRANT ALL ON FUNCTION public.set_services_updated_at() TO anon; GRANT ALL ON FUNCTION public.set_services_updated_at() TO authenticated; GRANT ALL ON FUNCTION public.set_services_updated_at() TO service_role; -- -- Name: FUNCTION set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text) TO postgres; GRANT ALL ON FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text) TO anon; GRANT ALL ON FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text) TO authenticated; GRANT ALL ON FUNCTION public.set_tenant_feature_exception(p_tenant_id uuid, p_feature_key text, p_enabled boolean, p_reason text) TO service_role; -- -- Name: FUNCTION set_updated_at(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_updated_at() TO postgres; GRANT ALL ON FUNCTION public.set_updated_at() TO anon; GRANT ALL ON FUNCTION public.set_updated_at() TO authenticated; GRANT ALL ON FUNCTION public.set_updated_at() TO service_role; -- -- Name: FUNCTION set_updated_at_recurrence(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.set_updated_at_recurrence() TO postgres; GRANT ALL ON FUNCTION public.set_updated_at_recurrence() TO anon; GRANT ALL ON FUNCTION public.set_updated_at_recurrence() TO authenticated; GRANT ALL ON FUNCTION public.set_updated_at_recurrence() TO service_role; -- -- Name: FUNCTION show_limit(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.show_limit() TO postgres; GRANT ALL ON FUNCTION public.show_limit() TO anon; GRANT ALL ON FUNCTION public.show_limit() TO authenticated; GRANT ALL ON FUNCTION public.show_limit() TO service_role; -- -- Name: FUNCTION show_trgm(text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.show_trgm(text) TO postgres; GRANT ALL ON FUNCTION public.show_trgm(text) TO anon; GRANT ALL ON FUNCTION public.show_trgm(text) TO authenticated; GRANT ALL ON FUNCTION public.show_trgm(text) TO service_role; -- -- Name: FUNCTION similarity(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.similarity(text, text) TO postgres; GRANT ALL ON FUNCTION public.similarity(text, text) TO anon; GRANT ALL ON FUNCTION public.similarity(text, text) TO authenticated; GRANT ALL ON FUNCTION public.similarity(text, text) TO service_role; -- -- Name: FUNCTION similarity_dist(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.similarity_dist(text, text) TO postgres; GRANT ALL ON FUNCTION public.similarity_dist(text, text) TO anon; GRANT ALL ON FUNCTION public.similarity_dist(text, text) TO authenticated; GRANT ALL ON FUNCTION public.similarity_dist(text, text) TO service_role; -- -- Name: FUNCTION similarity_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.similarity_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.similarity_op(text, text) TO anon; GRANT ALL ON FUNCTION public.similarity_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.similarity_op(text, text) TO service_role; -- -- Name: FUNCTION split_part(public.citext, public.citext, integer); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.split_part(public.citext, public.citext, integer) TO postgres; GRANT ALL ON FUNCTION public.split_part(public.citext, public.citext, integer) TO anon; GRANT ALL ON FUNCTION public.split_part(public.citext, public.citext, integer) TO authenticated; GRANT ALL ON FUNCTION public.split_part(public.citext, public.citext, integer) TO service_role; -- -- Name: FUNCTION split_recurrence_at(p_recurrence_id uuid, p_from_date date); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) TO postgres; GRANT ALL ON FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) TO anon; GRANT ALL ON FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) TO authenticated; GRANT ALL ON FUNCTION public.split_recurrence_at(p_recurrence_id uuid, p_from_date date) TO service_role; -- -- Name: FUNCTION strict_word_similarity(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strict_word_similarity(text, text) TO postgres; GRANT ALL ON FUNCTION public.strict_word_similarity(text, text) TO anon; GRANT ALL ON FUNCTION public.strict_word_similarity(text, text) TO authenticated; GRANT ALL ON FUNCTION public.strict_word_similarity(text, text) TO service_role; -- -- Name: FUNCTION strict_word_similarity_commutator_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strict_word_similarity_commutator_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.strict_word_similarity_commutator_op(text, text) TO anon; GRANT ALL ON FUNCTION public.strict_word_similarity_commutator_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.strict_word_similarity_commutator_op(text, text) TO service_role; -- -- Name: FUNCTION strict_word_similarity_dist_commutator_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strict_word_similarity_dist_commutator_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_commutator_op(text, text) TO anon; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_commutator_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_commutator_op(text, text) TO service_role; -- -- Name: FUNCTION strict_word_similarity_dist_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strict_word_similarity_dist_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_op(text, text) TO anon; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.strict_word_similarity_dist_op(text, text) TO service_role; -- -- Name: FUNCTION strict_word_similarity_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strict_word_similarity_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.strict_word_similarity_op(text, text) TO anon; GRANT ALL ON FUNCTION public.strict_word_similarity_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.strict_word_similarity_op(text, text) TO service_role; -- -- Name: FUNCTION strpos(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.strpos(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.strpos(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.strpos(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.strpos(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION subscription_intents_view_insert(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.subscription_intents_view_insert() TO postgres; GRANT ALL ON FUNCTION public.subscription_intents_view_insert() TO anon; GRANT ALL ON FUNCTION public.subscription_intents_view_insert() TO authenticated; GRANT ALL ON FUNCTION public.subscription_intents_view_insert() TO service_role; -- -- Name: FUNCTION subscriptions_validate_scope(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.subscriptions_validate_scope() TO postgres; GRANT ALL ON FUNCTION public.subscriptions_validate_scope() TO anon; GRANT ALL ON FUNCTION public.subscriptions_validate_scope() TO authenticated; GRANT ALL ON FUNCTION public.subscriptions_validate_scope() TO service_role; -- -- Name: FUNCTION sync_busy_mirror_agenda_eventos(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.sync_busy_mirror_agenda_eventos() TO postgres; GRANT ALL ON FUNCTION public.sync_busy_mirror_agenda_eventos() TO anon; GRANT ALL ON FUNCTION public.sync_busy_mirror_agenda_eventos() TO authenticated; GRANT ALL ON FUNCTION public.sync_busy_mirror_agenda_eventos() TO service_role; -- -- Name: FUNCTION tenant_accept_invite(p_token uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_accept_invite(p_token uuid) TO postgres; GRANT ALL ON FUNCTION public.tenant_accept_invite(p_token uuid) TO anon; GRANT ALL ON FUNCTION public.tenant_accept_invite(p_token uuid) TO authenticated; GRANT ALL ON FUNCTION public.tenant_accept_invite(p_token uuid) TO service_role; -- -- Name: TABLE tenant_members; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenant_members TO postgres; GRANT SELECT,REFERENCES,TRIGGER,TRUNCATE,MAINTAIN ON TABLE public.tenant_members TO authenticated; GRANT ALL ON TABLE public.tenant_members TO service_role; -- -- Name: FUNCTION tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO postgres; GRANT ALL ON FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO anon; GRANT ALL ON FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_add_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO service_role; -- -- Name: FUNCTION tenant_feature_allowed(p_tenant_id uuid, p_feature_key text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) TO postgres; GRANT ALL ON FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) TO anon; GRANT ALL ON FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_feature_allowed(p_tenant_id uuid, p_feature_key text) TO service_role; -- -- Name: FUNCTION tenant_feature_enabled(p_tenant_id uuid, p_feature_key text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) TO postgres; GRANT ALL ON FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) TO anon; GRANT ALL ON FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_feature_enabled(p_tenant_id uuid, p_feature_key text) TO service_role; -- -- Name: FUNCTION tenant_features_guard_with_plan(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_features_guard_with_plan() TO postgres; GRANT ALL ON FUNCTION public.tenant_features_guard_with_plan() TO anon; GRANT ALL ON FUNCTION public.tenant_features_guard_with_plan() TO authenticated; GRANT ALL ON FUNCTION public.tenant_features_guard_with_plan() TO service_role; -- -- Name: FUNCTION tenant_has_feature(_tenant_id uuid, _feature text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) TO postgres; GRANT ALL ON FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) TO anon; GRANT ALL ON FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_has_feature(_tenant_id uuid, _feature text) TO service_role; -- -- Name: FUNCTION tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text); Type: ACL; Schema: public; Owner: supabase_admin -- REVOKE ALL ON FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) FROM PUBLIC; GRANT ALL ON FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO postgres; GRANT ALL ON FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO anon; GRANT ALL ON FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_invite_member_by_email(p_tenant_id uuid, p_email text, p_role text) TO service_role; -- -- Name: FUNCTION tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) TO postgres; GRANT ALL ON FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) TO anon; GRANT ALL ON FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.tenant_reactivate_member(p_tenant_id uuid, p_member_user_id uuid) TO service_role; -- -- Name: FUNCTION tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) TO postgres; GRANT ALL ON FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) TO anon; GRANT ALL ON FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.tenant_remove_member(p_tenant_id uuid, p_member_user_id uuid) TO service_role; -- -- Name: FUNCTION tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) TO postgres; GRANT ALL ON FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) TO anon; GRANT ALL ON FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) TO authenticated; GRANT ALL ON FUNCTION public.tenant_remove_member_soft(p_tenant_id uuid, p_member_user_id uuid) TO service_role; -- -- Name: FUNCTION tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) TO postgres; GRANT ALL ON FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) TO anon; GRANT ALL ON FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_revoke_invite(p_tenant_id uuid, p_email text, p_role text) TO service_role; -- -- Name: FUNCTION tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) TO postgres; GRANT ALL ON FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) TO anon; GRANT ALL ON FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_set_member_status(p_tenant_id uuid, p_member_user_id uuid, p_new_status text) TO service_role; -- -- Name: FUNCTION tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) TO postgres; GRANT ALL ON FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) TO anon; GRANT ALL ON FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) TO authenticated; GRANT ALL ON FUNCTION public.tenant_update_member_role(p_tenant_id uuid, p_member_user_id uuid, p_new_role text) TO service_role; -- -- Name: FUNCTION texticlike(public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticlike(public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.texticlike(public.citext, text) TO anon; GRANT ALL ON FUNCTION public.texticlike(public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.texticlike(public.citext, text) TO service_role; -- -- Name: FUNCTION texticlike(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticlike(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.texticlike(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.texticlike(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.texticlike(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION texticnlike(public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticnlike(public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.texticnlike(public.citext, text) TO anon; GRANT ALL ON FUNCTION public.texticnlike(public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.texticnlike(public.citext, text) TO service_role; -- -- Name: FUNCTION texticnlike(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticnlike(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.texticnlike(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.texticnlike(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.texticnlike(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION texticregexeq(public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticregexeq(public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, text) TO anon; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, text) TO service_role; -- -- Name: FUNCTION texticregexeq(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticregexeq(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.texticregexeq(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION texticregexne(public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticregexne(public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.texticregexne(public.citext, text) TO anon; GRANT ALL ON FUNCTION public.texticregexne(public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.texticregexne(public.citext, text) TO service_role; -- -- Name: FUNCTION texticregexne(public.citext, public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.texticregexne(public.citext, public.citext) TO postgres; GRANT ALL ON FUNCTION public.texticregexne(public.citext, public.citext) TO anon; GRANT ALL ON FUNCTION public.texticregexne(public.citext, public.citext) TO authenticated; GRANT ALL ON FUNCTION public.texticregexne(public.citext, public.citext) TO service_role; -- -- Name: FUNCTION time_dist(time without time zone, time without time zone); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.time_dist(time without time zone, time without time zone) TO postgres; GRANT ALL ON FUNCTION public.time_dist(time without time zone, time without time zone) TO anon; GRANT ALL ON FUNCTION public.time_dist(time without time zone, time without time zone) TO authenticated; GRANT ALL ON FUNCTION public.time_dist(time without time zone, time without time zone) TO service_role; -- -- Name: FUNCTION toggle_plan(owner uuid); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.toggle_plan(owner uuid) TO postgres; GRANT ALL ON FUNCTION public.toggle_plan(owner uuid) TO anon; GRANT ALL ON FUNCTION public.toggle_plan(owner uuid) TO authenticated; GRANT ALL ON FUNCTION public.toggle_plan(owner uuid) TO service_role; -- -- Name: FUNCTION transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb) TO postgres; GRANT ALL ON FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb) TO anon; GRANT ALL ON FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb) TO authenticated; GRANT ALL ON FUNCTION public.transition_subscription(p_subscription_id uuid, p_to_status text, p_reason text, p_metadata jsonb) TO service_role; -- -- Name: FUNCTION translate(public.citext, public.citext, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.translate(public.citext, public.citext, text) TO postgres; GRANT ALL ON FUNCTION public.translate(public.citext, public.citext, text) TO anon; GRANT ALL ON FUNCTION public.translate(public.citext, public.citext, text) TO authenticated; GRANT ALL ON FUNCTION public.translate(public.citext, public.citext, text) TO service_role; -- -- Name: FUNCTION ts_dist(timestamp without time zone, timestamp without time zone); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.ts_dist(timestamp without time zone, timestamp without time zone) TO postgres; GRANT ALL ON FUNCTION public.ts_dist(timestamp without time zone, timestamp without time zone) TO anon; GRANT ALL ON FUNCTION public.ts_dist(timestamp without time zone, timestamp without time zone) TO authenticated; GRANT ALL ON FUNCTION public.ts_dist(timestamp without time zone, timestamp without time zone) TO service_role; -- -- Name: FUNCTION tstz_dist(timestamp with time zone, timestamp with time zone); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.tstz_dist(timestamp with time zone, timestamp with time zone) TO postgres; GRANT ALL ON FUNCTION public.tstz_dist(timestamp with time zone, timestamp with time zone) TO anon; GRANT ALL ON FUNCTION public.tstz_dist(timestamp with time zone, timestamp with time zone) TO authenticated; GRANT ALL ON FUNCTION public.tstz_dist(timestamp with time zone, timestamp with time zone) TO service_role; -- -- Name: FUNCTION update_payment_settings_updated_at(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.update_payment_settings_updated_at() TO postgres; GRANT ALL ON FUNCTION public.update_payment_settings_updated_at() TO anon; GRANT ALL ON FUNCTION public.update_payment_settings_updated_at() TO authenticated; GRANT ALL ON FUNCTION public.update_payment_settings_updated_at() TO service_role; -- -- Name: FUNCTION update_professional_pricing_updated_at(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.update_professional_pricing_updated_at() TO postgres; GRANT ALL ON FUNCTION public.update_professional_pricing_updated_at() TO anon; GRANT ALL ON FUNCTION public.update_professional_pricing_updated_at() TO authenticated; GRANT ALL ON FUNCTION public.update_professional_pricing_updated_at() TO service_role; -- -- Name: FUNCTION user_has_feature(_user_id uuid, _feature text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.user_has_feature(_user_id uuid, _feature text) TO postgres; GRANT ALL ON FUNCTION public.user_has_feature(_user_id uuid, _feature text) TO anon; GRANT ALL ON FUNCTION public.user_has_feature(_user_id uuid, _feature text) TO authenticated; GRANT ALL ON FUNCTION public.user_has_feature(_user_id uuid, _feature text) TO service_role; -- -- Name: FUNCTION validate_support_session(p_token text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.validate_support_session(p_token text) TO postgres; GRANT ALL ON FUNCTION public.validate_support_session(p_token text) TO anon; GRANT ALL ON FUNCTION public.validate_support_session(p_token text) TO authenticated; GRANT ALL ON FUNCTION public.validate_support_session(p_token text) TO service_role; -- -- Name: FUNCTION whoami(); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.whoami() TO postgres; GRANT ALL ON FUNCTION public.whoami() TO anon; GRANT ALL ON FUNCTION public.whoami() TO authenticated; GRANT ALL ON FUNCTION public.whoami() TO service_role; -- -- Name: FUNCTION word_similarity(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.word_similarity(text, text) TO postgres; GRANT ALL ON FUNCTION public.word_similarity(text, text) TO anon; GRANT ALL ON FUNCTION public.word_similarity(text, text) TO authenticated; GRANT ALL ON FUNCTION public.word_similarity(text, text) TO service_role; -- -- Name: FUNCTION word_similarity_commutator_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.word_similarity_commutator_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.word_similarity_commutator_op(text, text) TO anon; GRANT ALL ON FUNCTION public.word_similarity_commutator_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.word_similarity_commutator_op(text, text) TO service_role; -- -- Name: FUNCTION word_similarity_dist_commutator_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.word_similarity_dist_commutator_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.word_similarity_dist_commutator_op(text, text) TO anon; GRANT ALL ON FUNCTION public.word_similarity_dist_commutator_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.word_similarity_dist_commutator_op(text, text) TO service_role; -- -- Name: FUNCTION word_similarity_dist_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.word_similarity_dist_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.word_similarity_dist_op(text, text) TO anon; GRANT ALL ON FUNCTION public.word_similarity_dist_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.word_similarity_dist_op(text, text) TO service_role; -- -- Name: FUNCTION word_similarity_op(text, text); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.word_similarity_op(text, text) TO postgres; GRANT ALL ON FUNCTION public.word_similarity_op(text, text) TO anon; GRANT ALL ON FUNCTION public.word_similarity_op(text, text) TO authenticated; GRANT ALL ON FUNCTION public.word_similarity_op(text, text) TO service_role; -- -- Name: FUNCTION apply_rls(wal jsonb, max_record_bytes integer); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO postgres; GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO dashboard_user; GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO anon; GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO authenticated; GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO service_role; GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO supabase_realtime_admin; -- -- Name: FUNCTION broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) TO postgres; GRANT ALL ON FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) TO dashboard_user; -- -- Name: FUNCTION build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO postgres; GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO dashboard_user; GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO anon; GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO authenticated; GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO service_role; GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO supabase_realtime_admin; -- -- Name: FUNCTION "cast"(val text, type_ regtype); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO postgres; GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO dashboard_user; GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO anon; GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO authenticated; GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO service_role; GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO supabase_realtime_admin; -- -- Name: FUNCTION check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO postgres; GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO dashboard_user; GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO anon; GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO authenticated; GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO service_role; GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO supabase_realtime_admin; -- -- Name: FUNCTION is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO postgres; GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO dashboard_user; GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO anon; GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO authenticated; GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO service_role; GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO supabase_realtime_admin; -- -- Name: FUNCTION list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO postgres; GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO dashboard_user; GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO anon; GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO authenticated; GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO service_role; GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO supabase_realtime_admin; -- -- Name: FUNCTION quote_wal2json(entity regclass); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO postgres; GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO dashboard_user; GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO anon; GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO authenticated; GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO service_role; GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO supabase_realtime_admin; -- -- Name: FUNCTION send(payload jsonb, event text, topic text, private boolean); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) TO postgres; GRANT ALL ON FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) TO dashboard_user; -- -- Name: FUNCTION subscription_check_filters(); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO postgres; GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO dashboard_user; GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO anon; GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO authenticated; GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO service_role; GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO supabase_realtime_admin; -- -- Name: FUNCTION to_regrole(role_name text); Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO postgres; GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO dashboard_user; GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO anon; GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO authenticated; GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO service_role; GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO supabase_realtime_admin; -- -- Name: FUNCTION topic(); Type: ACL; Schema: realtime; Owner: supabase_realtime_admin -- GRANT ALL ON FUNCTION realtime.topic() TO postgres; GRANT ALL ON FUNCTION realtime.topic() TO dashboard_user; -- -- Name: FUNCTION http_request(); Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin -- REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC; GRANT ALL ON FUNCTION supabase_functions.http_request() TO postgres; GRANT ALL ON FUNCTION supabase_functions.http_request() TO anon; GRANT ALL ON FUNCTION supabase_functions.http_request() TO authenticated; GRANT ALL ON FUNCTION supabase_functions.http_request() TO service_role; -- -- Name: FUNCTION _crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea); Type: ACL; Schema: vault; Owner: supabase_admin -- GRANT ALL ON FUNCTION vault._crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea) TO postgres WITH GRANT OPTION; GRANT ALL ON FUNCTION vault._crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea) TO service_role; -- -- Name: FUNCTION create_secret(new_secret text, new_name text, new_description text, new_key_id uuid); Type: ACL; Schema: vault; Owner: supabase_admin -- GRANT ALL ON FUNCTION vault.create_secret(new_secret text, new_name text, new_description text, new_key_id uuid) TO postgres WITH GRANT OPTION; GRANT ALL ON FUNCTION vault.create_secret(new_secret text, new_name text, new_description text, new_key_id uuid) TO service_role; -- -- Name: FUNCTION update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid); Type: ACL; Schema: vault; Owner: supabase_admin -- GRANT ALL ON FUNCTION vault.update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid) TO postgres WITH GRANT OPTION; GRANT ALL ON FUNCTION vault.update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid) TO service_role; -- -- Name: FUNCTION max(public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.max(public.citext) TO postgres; GRANT ALL ON FUNCTION public.max(public.citext) TO anon; GRANT ALL ON FUNCTION public.max(public.citext) TO authenticated; GRANT ALL ON FUNCTION public.max(public.citext) TO service_role; -- -- Name: FUNCTION min(public.citext); Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON FUNCTION public.min(public.citext) TO postgres; GRANT ALL ON FUNCTION public.min(public.citext) TO anon; GRANT ALL ON FUNCTION public.min(public.citext) TO authenticated; GRANT ALL ON FUNCTION public.min(public.citext) TO service_role; -- -- Name: TABLE audit_log_entries; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.audit_log_entries TO dashboard_user; GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.audit_log_entries TO postgres; GRANT SELECT ON TABLE auth.audit_log_entries TO postgres WITH GRANT OPTION; -- -- Name: TABLE flow_state; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.flow_state TO postgres; GRANT SELECT ON TABLE auth.flow_state TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.flow_state TO dashboard_user; -- -- Name: TABLE identities; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.identities TO postgres; GRANT SELECT ON TABLE auth.identities TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.identities TO dashboard_user; -- -- Name: TABLE instances; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.instances TO dashboard_user; GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.instances TO postgres; GRANT SELECT ON TABLE auth.instances TO postgres WITH GRANT OPTION; -- -- Name: TABLE mfa_amr_claims; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_amr_claims TO postgres; GRANT SELECT ON TABLE auth.mfa_amr_claims TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.mfa_amr_claims TO dashboard_user; -- -- Name: TABLE mfa_challenges; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_challenges TO postgres; GRANT SELECT ON TABLE auth.mfa_challenges TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.mfa_challenges TO dashboard_user; -- -- Name: TABLE mfa_factors; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_factors TO postgres; GRANT SELECT ON TABLE auth.mfa_factors TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.mfa_factors TO dashboard_user; -- -- Name: TABLE oauth_authorizations; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.oauth_authorizations TO postgres; GRANT ALL ON TABLE auth.oauth_authorizations TO dashboard_user; -- -- Name: TABLE oauth_client_states; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.oauth_client_states TO postgres; GRANT ALL ON TABLE auth.oauth_client_states TO dashboard_user; -- -- Name: TABLE oauth_clients; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.oauth_clients TO postgres; GRANT ALL ON TABLE auth.oauth_clients TO dashboard_user; -- -- Name: TABLE oauth_consents; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.oauth_consents TO postgres; GRANT ALL ON TABLE auth.oauth_consents TO dashboard_user; -- -- Name: TABLE one_time_tokens; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.one_time_tokens TO postgres; GRANT SELECT ON TABLE auth.one_time_tokens TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.one_time_tokens TO dashboard_user; -- -- Name: TABLE refresh_tokens; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.refresh_tokens TO dashboard_user; GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.refresh_tokens TO postgres; GRANT SELECT ON TABLE auth.refresh_tokens TO postgres WITH GRANT OPTION; -- -- Name: SEQUENCE refresh_tokens_id_seq; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON SEQUENCE auth.refresh_tokens_id_seq TO dashboard_user; GRANT ALL ON SEQUENCE auth.refresh_tokens_id_seq TO postgres; -- -- Name: TABLE saml_providers; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.saml_providers TO postgres; GRANT SELECT ON TABLE auth.saml_providers TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.saml_providers TO dashboard_user; -- -- Name: TABLE saml_relay_states; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.saml_relay_states TO postgres; GRANT SELECT ON TABLE auth.saml_relay_states TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.saml_relay_states TO dashboard_user; -- -- Name: TABLE schema_migrations; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT SELECT ON TABLE auth.schema_migrations TO postgres WITH GRANT OPTION; -- -- Name: TABLE sessions; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sessions TO postgres; GRANT SELECT ON TABLE auth.sessions TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.sessions TO dashboard_user; -- -- Name: TABLE sso_domains; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sso_domains TO postgres; GRANT SELECT ON TABLE auth.sso_domains TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.sso_domains TO dashboard_user; -- -- Name: TABLE sso_providers; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sso_providers TO postgres; GRANT SELECT ON TABLE auth.sso_providers TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE auth.sso_providers TO dashboard_user; -- -- Name: TABLE users; Type: ACL; Schema: auth; Owner: supabase_auth_admin -- GRANT ALL ON TABLE auth.users TO dashboard_user; GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.users TO postgres; GRANT SELECT ON TABLE auth.users TO postgres WITH GRANT OPTION; -- -- Name: TABLE pg_stat_statements; Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON TABLE extensions.pg_stat_statements TO postgres WITH GRANT OPTION; -- -- Name: TABLE pg_stat_statements_info; Type: ACL; Schema: extensions; Owner: supabase_admin -- GRANT ALL ON TABLE extensions.pg_stat_statements_info TO postgres WITH GRANT OPTION; -- -- Name: TABLE agenda_bloqueios; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_bloqueios TO postgres; GRANT ALL ON TABLE public.agenda_bloqueios TO anon; GRANT ALL ON TABLE public.agenda_bloqueios TO authenticated; GRANT ALL ON TABLE public.agenda_bloqueios TO service_role; -- -- Name: TABLE agenda_configuracoes; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_configuracoes TO postgres; GRANT ALL ON TABLE public.agenda_configuracoes TO anon; GRANT ALL ON TABLE public.agenda_configuracoes TO authenticated; GRANT ALL ON TABLE public.agenda_configuracoes TO service_role; -- -- Name: TABLE agenda_eventos; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_eventos TO postgres; GRANT ALL ON TABLE public.agenda_eventos TO anon; GRANT ALL ON TABLE public.agenda_eventos TO authenticated; GRANT ALL ON TABLE public.agenda_eventos TO service_role; -- -- Name: TABLE agenda_excecoes; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_excecoes TO postgres; GRANT ALL ON TABLE public.agenda_excecoes TO anon; GRANT ALL ON TABLE public.agenda_excecoes TO authenticated; GRANT ALL ON TABLE public.agenda_excecoes TO service_role; -- -- Name: TABLE agenda_online_slots; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_online_slots TO postgres; GRANT ALL ON TABLE public.agenda_online_slots TO anon; GRANT ALL ON TABLE public.agenda_online_slots TO authenticated; GRANT ALL ON TABLE public.agenda_online_slots TO service_role; -- -- Name: SEQUENCE agenda_online_slots_id_seq; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON SEQUENCE public.agenda_online_slots_id_seq TO postgres; GRANT ALL ON SEQUENCE public.agenda_online_slots_id_seq TO anon; GRANT ALL ON SEQUENCE public.agenda_online_slots_id_seq TO authenticated; GRANT ALL ON SEQUENCE public.agenda_online_slots_id_seq TO service_role; -- -- Name: TABLE agenda_regras_semanais; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_regras_semanais TO postgres; GRANT ALL ON TABLE public.agenda_regras_semanais TO anon; GRANT ALL ON TABLE public.agenda_regras_semanais TO authenticated; GRANT ALL ON TABLE public.agenda_regras_semanais TO service_role; -- -- Name: TABLE agenda_slots_bloqueados_semanais; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_slots_bloqueados_semanais TO postgres; GRANT ALL ON TABLE public.agenda_slots_bloqueados_semanais TO anon; GRANT ALL ON TABLE public.agenda_slots_bloqueados_semanais TO authenticated; GRANT ALL ON TABLE public.agenda_slots_bloqueados_semanais TO service_role; -- -- Name: TABLE agenda_slots_regras; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agenda_slots_regras TO postgres; GRANT ALL ON TABLE public.agenda_slots_regras TO anon; GRANT ALL ON TABLE public.agenda_slots_regras TO authenticated; GRANT ALL ON TABLE public.agenda_slots_regras TO service_role; -- -- Name: TABLE agendador_configuracoes; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agendador_configuracoes TO postgres; GRANT ALL ON TABLE public.agendador_configuracoes TO anon; GRANT ALL ON TABLE public.agendador_configuracoes TO authenticated; GRANT ALL ON TABLE public.agendador_configuracoes TO service_role; -- -- Name: TABLE agendador_solicitacoes; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.agendador_solicitacoes TO postgres; GRANT ALL ON TABLE public.agendador_solicitacoes TO anon; GRANT ALL ON TABLE public.agendador_solicitacoes TO authenticated; GRANT ALL ON TABLE public.agendador_solicitacoes TO service_role; -- -- Name: TABLE billing_contracts; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.billing_contracts TO postgres; GRANT ALL ON TABLE public.billing_contracts TO anon; GRANT ALL ON TABLE public.billing_contracts TO authenticated; GRANT ALL ON TABLE public.billing_contracts TO service_role; -- -- Name: TABLE commitment_services; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.commitment_services TO postgres; GRANT ALL ON TABLE public.commitment_services TO anon; GRANT ALL ON TABLE public.commitment_services TO authenticated; GRANT ALL ON TABLE public.commitment_services TO service_role; -- -- Name: TABLE commitment_time_logs; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.commitment_time_logs TO postgres; GRANT ALL ON TABLE public.commitment_time_logs TO anon; GRANT ALL ON TABLE public.commitment_time_logs TO authenticated; GRANT ALL ON TABLE public.commitment_time_logs TO service_role; -- -- Name: TABLE current_tenant_id; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.current_tenant_id TO postgres; GRANT ALL ON TABLE public.current_tenant_id TO anon; GRANT ALL ON TABLE public.current_tenant_id TO authenticated; GRANT ALL ON TABLE public.current_tenant_id TO service_role; -- -- Name: TABLE determined_commitment_fields; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.determined_commitment_fields TO postgres; GRANT ALL ON TABLE public.determined_commitment_fields TO anon; GRANT ALL ON TABLE public.determined_commitment_fields TO authenticated; GRANT ALL ON TABLE public.determined_commitment_fields TO service_role; -- -- Name: TABLE determined_commitments; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.determined_commitments TO postgres; GRANT ALL ON TABLE public.determined_commitments TO anon; GRANT ALL ON TABLE public.determined_commitments TO authenticated; GRANT ALL ON TABLE public.determined_commitments TO service_role; -- -- Name: TABLE dev_user_credentials; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.dev_user_credentials TO postgres; GRANT ALL ON TABLE public.dev_user_credentials TO anon; GRANT ALL ON TABLE public.dev_user_credentials TO authenticated; GRANT ALL ON TABLE public.dev_user_credentials TO service_role; -- -- Name: TABLE entitlements_invalidation; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.entitlements_invalidation TO postgres; GRANT ALL ON TABLE public.entitlements_invalidation TO anon; GRANT ALL ON TABLE public.entitlements_invalidation TO authenticated; GRANT ALL ON TABLE public.entitlements_invalidation TO service_role; -- -- Name: TABLE features; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.features TO postgres; GRANT ALL ON TABLE public.features TO anon; GRANT ALL ON TABLE public.features TO authenticated; GRANT ALL ON TABLE public.features TO service_role; -- -- Name: TABLE feriados; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.feriados TO postgres; GRANT ALL ON TABLE public.feriados TO anon; GRANT ALL ON TABLE public.feriados TO authenticated; GRANT ALL ON TABLE public.feriados TO service_role; -- -- Name: TABLE financial_exceptions; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.financial_exceptions TO postgres; GRANT ALL ON TABLE public.financial_exceptions TO anon; GRANT ALL ON TABLE public.financial_exceptions TO authenticated; GRANT ALL ON TABLE public.financial_exceptions TO service_role; -- -- Name: TABLE insurance_plan_services; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.insurance_plan_services TO postgres; GRANT ALL ON TABLE public.insurance_plan_services TO anon; GRANT ALL ON TABLE public.insurance_plan_services TO authenticated; GRANT ALL ON TABLE public.insurance_plan_services TO service_role; -- -- Name: TABLE insurance_plans; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.insurance_plans TO postgres; GRANT ALL ON TABLE public.insurance_plans TO anon; GRANT ALL ON TABLE public.insurance_plans TO authenticated; GRANT ALL ON TABLE public.insurance_plans TO service_role; -- -- Name: TABLE module_features; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.module_features TO postgres; GRANT ALL ON TABLE public.module_features TO anon; GRANT ALL ON TABLE public.module_features TO authenticated; GRANT ALL ON TABLE public.module_features TO service_role; -- -- Name: TABLE modules; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.modules TO postgres; GRANT ALL ON TABLE public.modules TO anon; GRANT ALL ON TABLE public.modules TO authenticated; GRANT ALL ON TABLE public.modules TO service_role; -- -- Name: TABLE plan_features; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.plan_features TO postgres; GRANT ALL ON TABLE public.plan_features TO anon; GRANT ALL ON TABLE public.plan_features TO authenticated; GRANT ALL ON TABLE public.plan_features TO service_role; -- -- Name: TABLE tenant_modules; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenant_modules TO postgres; GRANT ALL ON TABLE public.tenant_modules TO anon; GRANT ALL ON TABLE public.tenant_modules TO authenticated; GRANT ALL ON TABLE public.tenant_modules TO service_role; -- -- Name: TABLE owner_feature_entitlements; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.owner_feature_entitlements TO postgres; GRANT ALL ON TABLE public.owner_feature_entitlements TO anon; GRANT ALL ON TABLE public.owner_feature_entitlements TO authenticated; GRANT ALL ON TABLE public.owner_feature_entitlements TO service_role; -- -- Name: TABLE owner_users; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.owner_users TO postgres; GRANT ALL ON TABLE public.owner_users TO anon; GRANT ALL ON TABLE public.owner_users TO authenticated; GRANT ALL ON TABLE public.owner_users TO service_role; -- -- Name: TABLE patient_discounts; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_discounts TO postgres; GRANT ALL ON TABLE public.patient_discounts TO anon; GRANT ALL ON TABLE public.patient_discounts TO authenticated; GRANT ALL ON TABLE public.patient_discounts TO service_role; -- -- Name: TABLE patient_group_patient; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_group_patient TO postgres; GRANT ALL ON TABLE public.patient_group_patient TO anon; GRANT ALL ON TABLE public.patient_group_patient TO authenticated; GRANT ALL ON TABLE public.patient_group_patient TO service_role; -- -- Name: TABLE patient_groups; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_groups TO postgres; GRANT ALL ON TABLE public.patient_groups TO anon; GRANT ALL ON TABLE public.patient_groups TO authenticated; GRANT ALL ON TABLE public.patient_groups TO service_role; -- -- Name: TABLE patient_intake_requests; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_intake_requests TO postgres; GRANT ALL ON TABLE public.patient_intake_requests TO authenticated; GRANT ALL ON TABLE public.patient_intake_requests TO service_role; -- -- Name: TABLE patient_invites; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_invites TO postgres; GRANT ALL ON TABLE public.patient_invites TO authenticated; GRANT ALL ON TABLE public.patient_invites TO service_role; -- -- Name: TABLE patient_patient_tag; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_patient_tag TO postgres; GRANT ALL ON TABLE public.patient_patient_tag TO anon; GRANT ALL ON TABLE public.patient_patient_tag TO authenticated; GRANT ALL ON TABLE public.patient_patient_tag TO service_role; -- -- Name: TABLE patient_tags; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patient_tags TO postgres; GRANT ALL ON TABLE public.patient_tags TO anon; GRANT ALL ON TABLE public.patient_tags TO authenticated; GRANT ALL ON TABLE public.patient_tags TO service_role; -- -- Name: TABLE patients; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.patients TO postgres; GRANT ALL ON TABLE public.patients TO anon; GRANT ALL ON TABLE public.patients TO authenticated; GRANT ALL ON TABLE public.patients TO service_role; -- -- Name: TABLE payment_settings; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.payment_settings TO postgres; GRANT ALL ON TABLE public.payment_settings TO anon; GRANT ALL ON TABLE public.payment_settings TO authenticated; GRANT ALL ON TABLE public.payment_settings TO service_role; -- -- Name: TABLE plan_prices; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.plan_prices TO postgres; GRANT ALL ON TABLE public.plan_prices TO anon; GRANT ALL ON TABLE public.plan_prices TO authenticated; GRANT ALL ON TABLE public.plan_prices TO service_role; -- -- Name: TABLE plan_public; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.plan_public TO postgres; GRANT ALL ON TABLE public.plan_public TO anon; GRANT ALL ON TABLE public.plan_public TO authenticated; GRANT ALL ON TABLE public.plan_public TO service_role; -- -- Name: TABLE plan_public_bullets; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.plan_public_bullets TO postgres; GRANT ALL ON TABLE public.plan_public_bullets TO anon; GRANT ALL ON TABLE public.plan_public_bullets TO authenticated; GRANT ALL ON TABLE public.plan_public_bullets TO service_role; -- -- Name: TABLE plans; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.plans TO postgres; GRANT ALL ON TABLE public.plans TO anon; GRANT ALL ON TABLE public.plans TO authenticated; GRANT ALL ON TABLE public.plans TO service_role; -- -- Name: TABLE professional_pricing; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.professional_pricing TO postgres; GRANT ALL ON TABLE public.professional_pricing TO anon; GRANT ALL ON TABLE public.professional_pricing TO authenticated; GRANT ALL ON TABLE public.professional_pricing TO service_role; -- -- Name: TABLE profiles; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.profiles TO postgres; GRANT ALL ON TABLE public.profiles TO anon; GRANT ALL ON TABLE public.profiles TO authenticated; GRANT ALL ON TABLE public.profiles TO service_role; -- -- Name: TABLE recurrence_exceptions; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.recurrence_exceptions TO postgres; GRANT ALL ON TABLE public.recurrence_exceptions TO anon; GRANT ALL ON TABLE public.recurrence_exceptions TO authenticated; GRANT ALL ON TABLE public.recurrence_exceptions TO service_role; -- -- Name: TABLE recurrence_rule_services; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.recurrence_rule_services TO postgres; GRANT ALL ON TABLE public.recurrence_rule_services TO anon; GRANT ALL ON TABLE public.recurrence_rule_services TO authenticated; GRANT ALL ON TABLE public.recurrence_rule_services TO service_role; -- -- Name: TABLE recurrence_rules; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.recurrence_rules TO postgres; GRANT ALL ON TABLE public.recurrence_rules TO anon; GRANT ALL ON TABLE public.recurrence_rules TO authenticated; GRANT ALL ON TABLE public.recurrence_rules TO service_role; -- -- Name: TABLE saas_admins; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.saas_admins TO postgres; GRANT ALL ON TABLE public.saas_admins TO anon; GRANT ALL ON TABLE public.saas_admins TO authenticated; GRANT ALL ON TABLE public.saas_admins TO service_role; -- -- Name: TABLE saas_doc_votos; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.saas_doc_votos TO postgres; GRANT ALL ON TABLE public.saas_doc_votos TO anon; GRANT ALL ON TABLE public.saas_doc_votos TO authenticated; GRANT ALL ON TABLE public.saas_doc_votos TO service_role; -- -- Name: TABLE saas_docs; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.saas_docs TO postgres; GRANT ALL ON TABLE public.saas_docs TO anon; GRANT ALL ON TABLE public.saas_docs TO authenticated; GRANT ALL ON TABLE public.saas_docs TO service_role; -- -- Name: TABLE saas_faq; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.saas_faq TO postgres; GRANT ALL ON TABLE public.saas_faq TO anon; GRANT ALL ON TABLE public.saas_faq TO authenticated; GRANT ALL ON TABLE public.saas_faq TO service_role; -- -- Name: TABLE saas_faq_itens; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.saas_faq_itens TO postgres; GRANT ALL ON TABLE public.saas_faq_itens TO anon; GRANT ALL ON TABLE public.saas_faq_itens TO authenticated; GRANT ALL ON TABLE public.saas_faq_itens TO service_role; -- -- Name: TABLE services; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.services TO postgres; GRANT ALL ON TABLE public.services TO anon; GRANT ALL ON TABLE public.services TO authenticated; GRANT ALL ON TABLE public.services TO service_role; -- -- Name: TABLE subscription_events; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscription_events TO postgres; GRANT ALL ON TABLE public.subscription_events TO anon; GRANT ALL ON TABLE public.subscription_events TO authenticated; GRANT ALL ON TABLE public.subscription_events TO service_role; -- -- Name: TABLE subscription_intents_personal; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscription_intents_personal TO postgres; GRANT ALL ON TABLE public.subscription_intents_personal TO anon; GRANT ALL ON TABLE public.subscription_intents_personal TO authenticated; GRANT ALL ON TABLE public.subscription_intents_personal TO service_role; -- -- Name: TABLE subscription_intents_tenant; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscription_intents_tenant TO postgres; GRANT ALL ON TABLE public.subscription_intents_tenant TO anon; GRANT ALL ON TABLE public.subscription_intents_tenant TO authenticated; GRANT ALL ON TABLE public.subscription_intents_tenant TO service_role; -- -- Name: TABLE subscription_intents; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscription_intents TO postgres; GRANT ALL ON TABLE public.subscription_intents TO anon; GRANT ALL ON TABLE public.subscription_intents TO authenticated; GRANT ALL ON TABLE public.subscription_intents TO service_role; -- -- Name: TABLE subscription_intents_legacy; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.subscription_intents_legacy TO postgres; GRANT ALL ON TABLE public.subscription_intents_legacy TO anon; GRANT ALL ON TABLE public.subscription_intents_legacy TO authenticated; GRANT ALL ON TABLE public.subscription_intents_legacy TO service_role; -- -- Name: TABLE support_sessions; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.support_sessions TO postgres; GRANT ALL ON TABLE public.support_sessions TO anon; GRANT ALL ON TABLE public.support_sessions TO authenticated; GRANT ALL ON TABLE public.support_sessions TO service_role; -- -- Name: TABLE tenant_feature_exceptions_log; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenant_feature_exceptions_log TO postgres; GRANT ALL ON TABLE public.tenant_feature_exceptions_log TO anon; GRANT ALL ON TABLE public.tenant_feature_exceptions_log TO authenticated; GRANT ALL ON TABLE public.tenant_feature_exceptions_log TO service_role; -- -- Name: TABLE tenant_features; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenant_features TO postgres; GRANT ALL ON TABLE public.tenant_features TO anon; GRANT ALL ON TABLE public.tenant_features TO authenticated; GRANT ALL ON TABLE public.tenant_features TO service_role; -- -- Name: TABLE tenant_invites; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenant_invites TO postgres; GRANT ALL ON TABLE public.tenant_invites TO authenticated; GRANT ALL ON TABLE public.tenant_invites TO service_role; -- -- Name: TABLE tenants; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.tenants TO postgres; GRANT ALL ON TABLE public.tenants TO anon; GRANT ALL ON TABLE public.tenants TO authenticated; GRANT ALL ON TABLE public.tenants TO service_role; -- -- Name: TABLE user_settings; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.user_settings TO postgres; GRANT ALL ON TABLE public.user_settings TO anon; GRANT ALL ON TABLE public.user_settings TO authenticated; GRANT ALL ON TABLE public.user_settings TO service_role; -- -- Name: TABLE v_auth_users_public; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_auth_users_public TO postgres; GRANT ALL ON TABLE public.v_auth_users_public TO anon; GRANT ALL ON TABLE public.v_auth_users_public TO authenticated; GRANT ALL ON TABLE public.v_auth_users_public TO service_role; -- -- Name: TABLE v_commitment_totals; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_commitment_totals TO postgres; GRANT ALL ON TABLE public.v_commitment_totals TO anon; GRANT ALL ON TABLE public.v_commitment_totals TO authenticated; GRANT ALL ON TABLE public.v_commitment_totals TO service_role; -- -- Name: TABLE v_patient_groups_with_counts; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_patient_groups_with_counts TO postgres; GRANT ALL ON TABLE public.v_patient_groups_with_counts TO anon; GRANT ALL ON TABLE public.v_patient_groups_with_counts TO authenticated; GRANT ALL ON TABLE public.v_patient_groups_with_counts TO service_role; -- -- Name: TABLE v_plan_active_prices; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_plan_active_prices TO postgres; GRANT ALL ON TABLE public.v_plan_active_prices TO anon; GRANT ALL ON TABLE public.v_plan_active_prices TO authenticated; GRANT ALL ON TABLE public.v_plan_active_prices TO service_role; -- -- Name: TABLE v_public_pricing; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_public_pricing TO postgres; GRANT ALL ON TABLE public.v_public_pricing TO anon; GRANT ALL ON TABLE public.v_public_pricing TO authenticated; GRANT ALL ON TABLE public.v_public_pricing TO service_role; -- -- Name: TABLE v_subscription_feature_mismatch; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_subscription_feature_mismatch TO postgres; GRANT ALL ON TABLE public.v_subscription_feature_mismatch TO anon; GRANT ALL ON TABLE public.v_subscription_feature_mismatch TO authenticated; GRANT ALL ON TABLE public.v_subscription_feature_mismatch TO service_role; -- -- Name: TABLE v_subscription_health; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_subscription_health TO postgres; GRANT ALL ON TABLE public.v_subscription_health TO anon; GRANT ALL ON TABLE public.v_subscription_health TO authenticated; GRANT ALL ON TABLE public.v_subscription_health TO service_role; -- -- Name: TABLE v_subscription_health_v2; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_subscription_health_v2 TO postgres; GRANT ALL ON TABLE public.v_subscription_health_v2 TO anon; GRANT ALL ON TABLE public.v_subscription_health_v2 TO authenticated; GRANT ALL ON TABLE public.v_subscription_health_v2 TO service_role; -- -- Name: TABLE v_tag_patient_counts; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tag_patient_counts TO postgres; GRANT ALL ON TABLE public.v_tag_patient_counts TO anon; GRANT ALL ON TABLE public.v_tag_patient_counts TO authenticated; GRANT ALL ON TABLE public.v_tag_patient_counts TO service_role; -- -- Name: TABLE v_tenant_active_subscription; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_active_subscription TO postgres; GRANT ALL ON TABLE public.v_tenant_active_subscription TO anon; GRANT ALL ON TABLE public.v_tenant_active_subscription TO authenticated; GRANT ALL ON TABLE public.v_tenant_active_subscription TO service_role; -- -- Name: TABLE v_tenant_entitlements; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_entitlements TO postgres; GRANT ALL ON TABLE public.v_tenant_entitlements TO anon; GRANT ALL ON TABLE public.v_tenant_entitlements TO authenticated; GRANT ALL ON TABLE public.v_tenant_entitlements TO service_role; -- -- Name: TABLE v_tenant_entitlements_full; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_entitlements_full TO postgres; GRANT ALL ON TABLE public.v_tenant_entitlements_full TO anon; GRANT ALL ON TABLE public.v_tenant_entitlements_full TO authenticated; GRANT ALL ON TABLE public.v_tenant_entitlements_full TO service_role; -- -- Name: TABLE v_tenant_entitlements_json; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_entitlements_json TO postgres; GRANT ALL ON TABLE public.v_tenant_entitlements_json TO anon; GRANT ALL ON TABLE public.v_tenant_entitlements_json TO authenticated; GRANT ALL ON TABLE public.v_tenant_entitlements_json TO service_role; -- -- Name: TABLE v_tenant_feature_exceptions; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_feature_exceptions TO postgres; GRANT ALL ON TABLE public.v_tenant_feature_exceptions TO anon; GRANT ALL ON TABLE public.v_tenant_feature_exceptions TO authenticated; GRANT ALL ON TABLE public.v_tenant_feature_exceptions TO service_role; -- -- Name: TABLE v_tenant_feature_mismatch; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_feature_mismatch TO postgres; GRANT ALL ON TABLE public.v_tenant_feature_mismatch TO anon; GRANT ALL ON TABLE public.v_tenant_feature_mismatch TO authenticated; GRANT ALL ON TABLE public.v_tenant_feature_mismatch TO service_role; -- -- Name: TABLE v_tenant_members_with_profiles; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_members_with_profiles TO postgres; GRANT ALL ON TABLE public.v_tenant_members_with_profiles TO anon; GRANT ALL ON TABLE public.v_tenant_members_with_profiles TO authenticated; GRANT ALL ON TABLE public.v_tenant_members_with_profiles TO service_role; -- -- Name: TABLE v_tenant_people; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_people TO postgres; GRANT ALL ON TABLE public.v_tenant_people TO anon; GRANT ALL ON TABLE public.v_tenant_people TO authenticated; GRANT ALL ON TABLE public.v_tenant_people TO service_role; -- -- Name: TABLE v_tenant_staff; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_tenant_staff TO postgres; GRANT ALL ON TABLE public.v_tenant_staff TO anon; GRANT ALL ON TABLE public.v_tenant_staff TO authenticated; GRANT ALL ON TABLE public.v_tenant_staff TO service_role; -- -- Name: TABLE v_user_active_subscription; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_user_active_subscription TO postgres; GRANT ALL ON TABLE public.v_user_active_subscription TO anon; GRANT ALL ON TABLE public.v_user_active_subscription TO authenticated; GRANT ALL ON TABLE public.v_user_active_subscription TO service_role; -- -- Name: TABLE v_user_entitlements; Type: ACL; Schema: public; Owner: supabase_admin -- GRANT ALL ON TABLE public.v_user_entitlements TO postgres; GRANT ALL ON TABLE public.v_user_entitlements TO anon; GRANT ALL ON TABLE public.v_user_entitlements TO authenticated; GRANT ALL ON TABLE public.v_user_entitlements TO service_role; -- -- Name: TABLE messages; Type: ACL; Schema: realtime; Owner: supabase_realtime_admin -- GRANT ALL ON TABLE realtime.messages TO postgres; GRANT ALL ON TABLE realtime.messages TO dashboard_user; GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO anon; GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO authenticated; GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO service_role; -- -- Name: TABLE messages_2026_03_12; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_12 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_12 TO dashboard_user; -- -- Name: TABLE messages_2026_03_13; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_13 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_13 TO dashboard_user; -- -- Name: TABLE messages_2026_03_14; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_14 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_14 TO dashboard_user; -- -- Name: TABLE messages_2026_03_15; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_15 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_15 TO dashboard_user; -- -- Name: TABLE messages_2026_03_16; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_16 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_16 TO dashboard_user; -- -- Name: TABLE messages_2026_03_17; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_17 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_17 TO dashboard_user; -- -- Name: TABLE messages_2026_03_18; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.messages_2026_03_18 TO postgres; GRANT ALL ON TABLE realtime.messages_2026_03_18 TO dashboard_user; -- -- Name: TABLE schema_migrations; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.schema_migrations TO postgres; GRANT ALL ON TABLE realtime.schema_migrations TO dashboard_user; GRANT SELECT ON TABLE realtime.schema_migrations TO anon; GRANT SELECT ON TABLE realtime.schema_migrations TO authenticated; GRANT SELECT ON TABLE realtime.schema_migrations TO service_role; GRANT ALL ON TABLE realtime.schema_migrations TO supabase_realtime_admin; -- -- Name: TABLE subscription; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON TABLE realtime.subscription TO postgres; GRANT ALL ON TABLE realtime.subscription TO dashboard_user; GRANT SELECT ON TABLE realtime.subscription TO anon; GRANT SELECT ON TABLE realtime.subscription TO authenticated; GRANT SELECT ON TABLE realtime.subscription TO service_role; GRANT ALL ON TABLE realtime.subscription TO supabase_realtime_admin; -- -- Name: SEQUENCE subscription_id_seq; Type: ACL; Schema: realtime; Owner: supabase_admin -- GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO postgres; GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO dashboard_user; GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO anon; GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO authenticated; GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO service_role; GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO supabase_realtime_admin; -- -- Name: TABLE buckets; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.buckets TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE storage.buckets TO service_role; GRANT ALL ON TABLE storage.buckets TO authenticated; GRANT ALL ON TABLE storage.buckets TO anon; -- -- Name: TABLE buckets_analytics; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.buckets_analytics TO service_role; GRANT ALL ON TABLE storage.buckets_analytics TO authenticated; GRANT ALL ON TABLE storage.buckets_analytics TO anon; -- -- Name: TABLE buckets_vectors; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT SELECT ON TABLE storage.buckets_vectors TO service_role; GRANT SELECT ON TABLE storage.buckets_vectors TO authenticated; GRANT SELECT ON TABLE storage.buckets_vectors TO anon; -- -- Name: TABLE iceberg_namespaces; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.iceberg_namespaces TO service_role; GRANT SELECT ON TABLE storage.iceberg_namespaces TO authenticated; GRANT SELECT ON TABLE storage.iceberg_namespaces TO anon; -- -- Name: TABLE iceberg_tables; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.iceberg_tables TO service_role; GRANT SELECT ON TABLE storage.iceberg_tables TO authenticated; GRANT SELECT ON TABLE storage.iceberg_tables TO anon; -- -- Name: TABLE objects; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.objects TO postgres WITH GRANT OPTION; GRANT ALL ON TABLE storage.objects TO service_role; GRANT ALL ON TABLE storage.objects TO authenticated; GRANT ALL ON TABLE storage.objects TO anon; -- -- Name: TABLE s3_multipart_uploads; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.s3_multipart_uploads TO service_role; GRANT SELECT ON TABLE storage.s3_multipart_uploads TO authenticated; GRANT SELECT ON TABLE storage.s3_multipart_uploads TO anon; -- -- Name: TABLE s3_multipart_uploads_parts; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT ALL ON TABLE storage.s3_multipart_uploads_parts TO service_role; GRANT SELECT ON TABLE storage.s3_multipart_uploads_parts TO authenticated; GRANT SELECT ON TABLE storage.s3_multipart_uploads_parts TO anon; -- -- Name: TABLE vector_indexes; Type: ACL; Schema: storage; Owner: supabase_storage_admin -- GRANT SELECT ON TABLE storage.vector_indexes TO service_role; GRANT SELECT ON TABLE storage.vector_indexes TO authenticated; GRANT SELECT ON TABLE storage.vector_indexes TO anon; -- -- Name: TABLE hooks; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin -- GRANT ALL ON TABLE supabase_functions.hooks TO postgres; GRANT ALL ON TABLE supabase_functions.hooks TO anon; GRANT ALL ON TABLE supabase_functions.hooks TO authenticated; GRANT ALL ON TABLE supabase_functions.hooks TO service_role; -- -- Name: SEQUENCE hooks_id_seq; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin -- GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO postgres; GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO anon; GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO authenticated; GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO service_role; -- -- Name: TABLE migrations; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin -- GRANT ALL ON TABLE supabase_functions.migrations TO postgres; GRANT ALL ON TABLE supabase_functions.migrations TO anon; GRANT ALL ON TABLE supabase_functions.migrations TO authenticated; GRANT ALL ON TABLE supabase_functions.migrations TO service_role; -- -- Name: TABLE secrets; Type: ACL; Schema: vault; Owner: supabase_admin -- GRANT SELECT,REFERENCES,DELETE,TRUNCATE ON TABLE vault.secrets TO postgres WITH GRANT OPTION; GRANT SELECT,DELETE ON TABLE vault.secrets TO service_role; -- -- Name: TABLE decrypted_secrets; Type: ACL; Schema: vault; Owner: supabase_admin -- GRANT SELECT,REFERENCES,DELETE,TRUNCATE ON TABLE vault.decrypted_secrets TO postgres WITH GRANT OPTION; GRANT SELECT,DELETE ON TABLE vault.decrypted_secrets TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON SEQUENCES TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON FUNCTIONS TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON TABLES TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON SEQUENCES TO postgres WITH GRANT OPTION; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON FUNCTIONS TO postgres WITH GRANT OPTION; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON TABLES TO postgres WITH GRANT OPTION; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON SEQUENCES TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON FUNCTIONS TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON TABLES TO dashboard_user; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: storage; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: storage; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: storage; Owner: postgres -- ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO service_role; -- -- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin -- ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO postgres; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO anon; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO authenticated; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO service_role; -- -- Name: issue_graphql_placeholder; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER issue_graphql_placeholder ON sql_drop WHEN TAG IN ('DROP EXTENSION') EXECUTE FUNCTION extensions.set_graphql_placeholder(); ALTER EVENT TRIGGER issue_graphql_placeholder OWNER TO supabase_admin; -- -- Name: issue_pg_cron_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER issue_pg_cron_access ON ddl_command_end WHEN TAG IN ('CREATE EXTENSION') EXECUTE FUNCTION extensions.grant_pg_cron_access(); ALTER EVENT TRIGGER issue_pg_cron_access OWNER TO supabase_admin; -- -- Name: issue_pg_graphql_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER issue_pg_graphql_access ON ddl_command_end WHEN TAG IN ('CREATE FUNCTION') EXECUTE FUNCTION extensions.grant_pg_graphql_access(); ALTER EVENT TRIGGER issue_pg_graphql_access OWNER TO supabase_admin; -- -- Name: issue_pg_net_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER issue_pg_net_access ON ddl_command_end WHEN TAG IN ('CREATE EXTENSION') EXECUTE FUNCTION extensions.grant_pg_net_access(); ALTER EVENT TRIGGER issue_pg_net_access OWNER TO supabase_admin; -- -- Name: pgrst_ddl_watch; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER pgrst_ddl_watch ON ddl_command_end EXECUTE FUNCTION extensions.pgrst_ddl_watch(); ALTER EVENT TRIGGER pgrst_ddl_watch OWNER TO supabase_admin; -- -- Name: pgrst_drop_watch; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin -- CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop EXECUTE FUNCTION extensions.pgrst_drop_watch(); ALTER EVENT TRIGGER pgrst_drop_watch OWNER TO supabase_admin; -- -- PostgreSQL database dump complete -- \unrestrict jIaZyygk9Cg9Z4ELczVcfs8ceh7EIWutd6NCBTzG3dunNfjBgnAm5uGtlm0D4Zf