Files
medreport_mrb2b/supabase/migrations/20250707150416_membership_confirmation.sql
Danel Kungla 9371ff7710 feat: update API and database structure for membership confirmation and wallet integration
- Refactor API calls to use 'medreport' schema for membership confirmation and account updates
- Enhance success notification component to include wallet balance and expiration details
- Modify database types to reflect new 'medreport' schema and add product-related tables
- Update localization files to support new wallet messages
- Adjust SQL migration scripts for proper schema references and function definitions
2025-07-09 10:01:12 +03:00

42 lines
1.1 KiB
PL/PgSQL

alter table "medreport"."accounts_memberships" add column "has_seen_confirmation" boolean not null default false;
set check_function_bodies = off;
CREATE OR REPLACE FUNCTION medreport.has_unseen_membership_confirmation(p_user_id uuid DEFAULT auth.uid())
RETURNS boolean
LANGUAGE sql
SECURITY DEFINER
SET search_path TO 'medreport', 'extensions'
AS $function$
select exists (
select 1
from medreport.accounts_memberships am
where am.user_id = p_user_id
and am.has_seen_confirmation = false
);
$function$
;
grant execute on function medreport.has_unseen_membership_confirmation(uuid)
to authenticated, anon;
drop function if exists "medreport"."has_personal_code"(account_id uuid);
CREATE OR REPLACE FUNCTION medreport.has_consent_personal_data(account_id uuid)
RETURNS boolean
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = ''
AS $function$BEGIN
RETURN EXISTS (
SELECT 1
FROM medreport.accounts
WHERE id = account_id
AND has_consent_personal_data IS TRUE
);
END;$function$
;
grant execute on function medreport.has_consent_personal_data(uuid)
to authenticated, anon;