feat: finalize ticket merging and speaker-aware imports

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-10 13:28:18 +02:00
1 parent 7f340b4c08
commit fbc827c2b8
35 files changed
+1772 -348

No files matched your search

+4 -4
View File
@@ -246,11 +246,11 @@ otp_expiry = 3600
# Local Auth explicitly opts into real email delivery; password stays in a private env file.
[auth.email.smtp]
enabled = true
host = "heracles.mxrouting.net"
port = 465
user = "[email protected]"
host = "smtp-relay.brevo.com"
port = 587
user = "[email protected]"
pass = "env(CONVIVO_SMTP_PASSWORD)"
admin_email = "convivo@lago.dev"
admin_email = "info@convivo.appe.at"
sender_name = "Convivo APP"
# Uncomment to customize email template
@@ -0,0 +1,19 @@
create or replace function public.can_request_admin_magic_link(p_email text)
returns boolean
language sql stable security definer
set search_path = ''
as $$
select exists (
select 1
from public.contacts as contact
where contact.email = lower(btrim(p_email))
and (contact.is_admin or contact.email like '%@appe.at')
and exists (
select 1 from auth.users as auth_user
where auth_user.email = contact.email
)
);
$$;
revoke all on function public.can_request_admin_magic_link(text) from public;
grant execute on function public.can_request_admin_magic_link(text) to anon, authenticated;
@@ -0,0 +1,200 @@
alter table public.registrations add column import_source text
check (import_source in ('sessionize'));
update public.registrations registration set import_source = 'sessionize'
from public.contacts contact
where contact.email = registration.contact_email
and nullif(btrim(contact.external_id), '') is not null
and nullif(btrim(registration.qr_token), '') is null
and nullif(btrim(registration.external_id), '') is null
and registration.type in ('speaker', 'staff');
create table public.ticket_merges (
event_id uuid not null references public.events(id) on delete cascade,
source_email text not null references public.contacts(email) on delete cascade,
target_email text not null references public.contacts(email) on delete cascade,
transferred_type public.registration_type not null,
merged_by uuid not null,
merged_at timestamptz not null default now(),
primary key (event_id, source_email),
check (source_email <> target_email),
check (transferred_type in ('speaker', 'staff'))
);
alter table public.ticket_merges enable row level security;
revoke all on public.ticket_merges from public, anon, authenticated;
grant select on public.ticket_merges to authenticated;
create policy ticket_merges_admin_read on public.ticket_merges
for select to authenticated using (public.is_admin());
create function public._ticket_email(p_event_id uuid, p_email text)
returns text language sql stable security definer set search_path = '' as $$
select coalesce((select target_email from public.ticket_merges
where event_id = p_event_id and source_email = p_email), p_email);
$$;
revoke all on function public._ticket_email(uuid, text) from public, anon, authenticated;
create function public._apply_ticket_merge_registration()
returns trigger language plpgsql security definer set search_path = '' as $$
declare
mapping public.ticket_merges;
begin
select * into mapping from public.ticket_merges
where event_id = new.event_id and source_email = new.contact_email;
if found then
if nullif(btrim(new.qr_token), '') is not null then
raise exception 'This imported account was merged; reconcile its new ticket manually';
end if;
update public.registrations set type = case
when type = 'staff' or mapping.transferred_type = 'staff' then 'staff'::public.registration_type
else 'speaker'::public.registration_type end
where event_id = mapping.event_id and contact_email = mapping.target_email;
if not found then raise exception 'Merged ticket no longer exists'; end if;
return null;
end if;
select * into mapping from public.ticket_merges
where event_id = new.event_id and target_email = new.contact_email
order by (transferred_type = 'staff') desc limit 1;
if found then
new.type := case when new.type = 'staff' or mapping.transferred_type = 'staff'
then 'staff'::public.registration_type else 'speaker'::public.registration_type end;
end if;
return new;
end;
$$;
revoke all on function public._apply_ticket_merge_registration() from public, anon, authenticated;
create trigger ticket_merge_registration before insert or update on public.registrations
for each row execute function public._apply_ticket_merge_registration();
do $$
declare
function_name text;
definition text;
needle text := E'insert into public.registrations (event_id, contact_email, type)\n values (p_event_id, v_email, ''speaker''::public.registration_type)';
begin
foreach function_name in array array['sync_sessionize_event', 'sync_sessionize_excel'] loop
definition := pg_get_functiondef(to_regprocedure('public.' || function_name || '(uuid,jsonb)'));
if function_name = 'sync_sessionize_excel' and position(needle in definition) = 0 then
raise exception 'Unexpected Sessionize registration definition: %', function_name;
end if;
if position('values (v_session.id, v_spk)' in definition) = 0
or position('where e = ss.contact_email' in definition) = 0 then
raise exception 'Unexpected Sessionize speaker definition: %', function_name;
end if;
definition := replace(definition, needle,
E'insert into public.registrations (event_id, contact_email, type, import_source)\n values (p_event_id, v_email, ''speaker''::public.registration_type, ''sessionize'')');
if function_name = 'sync_sessionize_excel' then
definition := replace(definition, E' v_email := v_item ->> ''email'';',
E' v_email := public._ticket_email(p_event_id, v_item ->> ''email'');');
definition := replace(definition, 'set type = case when public.registrations.type',
E'set import_source = ''sessionize'',\n type = case when public.registrations.type');
definition := replace(definition, E'\n where public.registrations.type not in (''staff'', ''sponsor'');', ';');
end if;
definition := replace(definition, 'values (v_session.id, v_spk)',
'values (v_session.id, public._ticket_email(p_event_id, v_spk))');
definition := replace(definition, 'where e = ss.contact_email',
'where public._ticket_email(p_event_id, e) = ss.contact_email');
execute definition;
end loop;
end;
$$;
create or replace function public._recalc_event_aggregates(p_event_id uuid) returns void
language plpgsql security definer set search_path = '' as $$
begin
update public.events set
num_sessions = (select count(*) from public.sessions where event_id = p_event_id),
num_speakers = (select count(distinct speaker.contact_email) from public.session_speakers speaker
join public.sessions talk on talk.id = speaker.session_id where talk.event_id = p_event_id),
num_registrations = (select count(*) from public.registrations
where event_id = p_event_id and nullif(btrim(qr_token), '') is not null),
num_checked_in_registrations = (select count(*) from public.registrations
where event_id = p_event_id and checked_in and nullif(btrim(qr_token), '') is not null),
avg_feedback = (select avg(rating) from public.feedback where event_id = p_event_id)
where id = p_event_id;
end;
$$;
create function public.merge_tickets(p_source_id uuid, p_target_id uuid)
returns jsonb language plpgsql security definer set search_path = '' as $$
declare
source_registration public.registrations;
target_registration public.registrations;
transferred_type public.registration_type;
session_count integer;
begin
if auth.uid() is null or not public.is_admin() then
raise exception 'admin only' using errcode = '42501';
end if;
if p_source_id is null or p_target_id is null or p_source_id = p_target_id then
raise exception 'Pick two different registrations';
end if;
select * into source_registration from public.registrations where id = p_source_id;
if not found then raise exception 'Imported registration no longer exists'; end if;
perform 1 from public.events where id = source_registration.event_id for update;
perform 1 from public.registrations where id in (p_source_id, p_target_id) order by id for update;
select * into source_registration from public.registrations where id = p_source_id;
if not found then raise exception 'Imported registration no longer exists'; end if;
select * into target_registration from public.registrations where id = p_target_id;
if not found then raise exception 'Ticket no longer exists'; end if;
if source_registration.event_id <> target_registration.event_id then
raise exception 'Tickets must belong to the same event';
end if;
if source_registration.import_source is distinct from 'sessionize'
or nullif(btrim(source_registration.qr_token), '') is not null
or source_registration.type not in ('speaker', 'staff') then
raise exception 'Source must be an imported speaker/staff registration without a QR';
end if;
if nullif(btrim(target_registration.qr_token), '') is null
or nullif(btrim(target_registration.external_id), '') is null then
raise exception 'Destination must be a purchased Pretix ticket';
end if;
if exists (select 1 from public.ticket_merges where event_id = source_registration.event_id
and (target_email = source_registration.contact_email or source_email = target_registration.contact_email)) then
raise exception 'Merge chains are not supported';
end if;
perform 1 from public.contacts
where email in (source_registration.contact_email, target_registration.contact_email)
order by email for update;
if source_registration.checked_in or source_registration.points <> 0
or exists (select 1 from public.preferences where event_id = source_registration.event_id and contact_email = source_registration.contact_email)
or exists (select 1 from public.checkins where event_id = source_registration.event_id and contact_email = source_registration.contact_email)
or exists (select 1 from public.feedback where event_id = source_registration.event_id and contact_email = source_registration.contact_email)
or exists (select 1 from public.points_log where event_id = source_registration.event_id and contact_email = source_registration.contact_email)
or exists (select 1 from public.connections where event_id = source_registration.event_id
and (from_email = source_registration.contact_email or to_email = source_registration.contact_email)) then
raise exception 'Imported account has attendee activity; reconcile it before merging';
end if;
transferred_type := case when source_registration.type = 'staff' or target_registration.type = 'staff'
then 'staff'::public.registration_type else 'speaker'::public.registration_type end;
perform 1 from public.sessions where event_id = source_registration.event_id order by id for update;
perform 1 from public.session_speakers speaker join public.sessions talk on talk.id = speaker.session_id
where talk.event_id = source_registration.event_id order by speaker.session_id, speaker.contact_email for update of speaker;
select count(*) into session_count from public.session_speakers speaker
join public.sessions talk on talk.id = speaker.session_id
where talk.event_id = source_registration.event_id and speaker.contact_email = source_registration.contact_email;
insert into public.session_speakers(session_id, contact_email)
select speaker.session_id, target_registration.contact_email from public.session_speakers speaker
join public.sessions talk on talk.id = speaker.session_id
where talk.event_id = source_registration.event_id and speaker.contact_email = source_registration.contact_email
on conflict (session_id, contact_email) do nothing;
delete from public.session_speakers speaker using public.sessions talk
where talk.id = speaker.session_id and talk.event_id = source_registration.event_id
and speaker.contact_email = source_registration.contact_email;
update public.registrations set type = transferred_type where id = p_target_id;
insert into public.ticket_merges(event_id, source_email, target_email, transferred_type, merged_by)
values (source_registration.event_id, source_registration.contact_email, target_registration.contact_email, transferred_type, auth.uid());
delete from public.registrations where id = p_source_id;
delete from public.leaderboard where event_id = source_registration.event_id and contact_email = source_registration.contact_email;
return jsonb_build_object('source_id', p_source_id, 'target_id', p_target_id,
'target_email', target_registration.contact_email, 'type', transferred_type, 'sessions_transferred', session_count);
end;
$$;
revoke all on function public.merge_tickets(uuid, uuid) from public, anon, authenticated;
grant execute on function public.merge_tickets(uuid, uuid) to authenticated;
do $$ declare event_row record; begin
for event_row in select id from public.events loop
perform public._recalc_event_aggregates(event_row.id);
end loop;
end; $$;
notify pgrst, 'reload schema';
@@ -0,0 +1,51 @@
create function public._preserve_assigned_speaker_role()
returns trigger language plpgsql security definer set search_path = '' as $$
begin
if new.type = 'attendee' and exists (
select 1 from public.session_speakers speaker
join public.sessions talk on talk.id = speaker.session_id
join public.slots slot on slot.id = talk.slot_id and slot.event_id = talk.event_id
where speaker.contact_email = new.contact_email
and talk.event_id = new.event_id and slot.type = 'session'
) then
new.type := 'speaker'::public.registration_type;
end if;
return new;
end;
$$;
revoke all on function public._preserve_assigned_speaker_role() from public, anon, authenticated;
create trigger trg_registrations_assigned_speaker
before insert or update on public.registrations
for each row execute function public._preserve_assigned_speaker_role();
create or replace function public._trg_speaker_promote()
returns trigger language plpgsql security definer set search_path = '' as $$
begin
update public.registrations registration set type = 'speaker'::public.registration_type
from public.sessions talk join public.slots slot
on slot.id = talk.slot_id and slot.event_id = talk.event_id
where talk.id = new.session_id and slot.type = 'session'
and registration.event_id = talk.event_id
and registration.contact_email = new.contact_email
and registration.type = 'attendee';
return new;
end;
$$;
revoke all on function public._trg_speaker_promote() from public, anon, authenticated;
drop trigger session_speakers_speaker_promote on public.session_speakers;
create trigger session_speakers_speaker_promote
after insert or update on public.session_speakers
for each row execute function public._trg_speaker_promote();
update public.registrations registration set type = 'speaker'::public.registration_type
where registration.type = 'attendee' and exists (
select 1 from public.session_speakers speaker
join public.sessions talk on talk.id = speaker.session_id
join public.slots slot on slot.id = talk.slot_id and slot.event_id = talk.event_id
where speaker.contact_email = registration.contact_email
and talk.event_id = registration.event_id and slot.type = 'session'
);
notify pgrst, 'reload schema';
+4 -259
View File
@@ -6,180 +6,30 @@
-- "Sessions and speakers (advanced)" .xlsx (imported via the Interfaces menu,
-- which creates the speaker contacts + registrations + links by email).
--
-- Seeded here: the event (with its Sessionize endpoint), 50 attendees, 4 staff
-- Seeded here: the event (with its Sessionize endpoint), 4 staff
-- (admin role), and the agenda. Speaker contacts/registrations are NOT seeded —
-- run the Excel import to add them.
-- =============================================================================
-- -----------------------------------------------------------------------------
-- AUTH USERS (QR token = password). 50 attendees + 4 staff.
-- AUTH USERS (staff password). 4 staff.
-- -----------------------------------------------------------------------------
insert into auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, confirmation_token, recovery_token, email_change_token_new, email_change, raw_app_meta_data, raw_user_meta_data, created_at, updated_at, confirmation_sent_at, last_sign_in_at) values
('00000000-0000-0000-0000-000000000000', 'a40737e3-11ca-48e0-9445-4f72096cdcd4', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1000', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lena Huber"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '298d54fd-6e35-460d-aabf-135e2eefac00', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1001', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Felix Berger"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '446a6e86-73da-41ae-8134-7609556dca96', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1002', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Mia Moser"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '6abea183-d84e-4502-9eb8-b5bc751a3ca4', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1003', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Jonas Unger"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'c18e5356-3c14-4a43-8e0b-0739ff0fc1c0', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1004', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Emma Dorfer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'cf916c0c-b501-4c1b-bd1b-366fbe5fe4d8', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1005', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Paul Klein"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'c322e223-6965-4a98-860e-367acfa21202', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1006', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Hannah Steiner"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '52f0e634-09a4-444d-a6e6-cbd9e4ee5b9f', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1007', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lukas Fischer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '4546c422-584b-4108-8a5b-25c832fc0114', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1008', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Sofia Oberhuber"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'd2ea8708-22a9-446b-8fb8-833f2f9a733c', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1009', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"David Winkler"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '296330bd-a169-4798-8df1-38221381d2e0', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1010', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Clara Falk"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '935f1800-1b99-4894-8891-db2c86491a5b', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1011', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Max Wagner"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '2ce35e62-822a-4e5b-b3c9-e6b5b6cc7531', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1012', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Ella Hofer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '2d1a4f08-19dc-4239-bf3d-27fb912500aa', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1013', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Finn Hofmann"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'e27a487b-df20-4bf6-83a8-41d17533cbb5', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1014', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Livia Rainer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '2daa1a3f-2b27-4532-9d4d-dd1fbe37d3b5', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1015', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Noah Aigner"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '67938a9a-5041-4882-8947-4274e78a0bcb', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1016', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Mara Hartl"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'eb7570a3-9ffc-4260-bfca-d45bfe128c26', 'authenticated', 'authenticated', 'elias.mü[email protected]', crypt('CVV-ATT-1017', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Elias Müller"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '584eed6e-d953-4672-b7c8-891d0674e7f9', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1018', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Nora Pichler"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '74a99e87-42b3-4d0a-bc5c-635b22dc2023', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1019', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Ben Lederer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '311399c5-d98c-4785-a94c-617982503e14', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1020', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Ida Tausch"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '78be51e6-65f0-46ad-80d5-2399390ff501', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1021', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Oscar Cerny"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '05a54110-7182-4095-93de-85306ce572d4', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1022', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Freja Jank"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'cd6bc4d5-afb0-4da2-99b9-f3e5bb7c5f32', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1023', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Hugo Gruber"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'd66f79b9-9dec-4a6a-94e7-82f4b0ad01c0', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1024', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Alma Egger"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'bb7736de-d32a-41d7-b2d9-ee64275b145e', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1025', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Theo Nagl"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'f09aca1d-4d95-49a6-a9e0-6f1362fe8361', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Greta Vogler"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'd1bbda95-3df1-4c3b-95ee-ed1eb523d30e', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1027', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Milo Eisen"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'e9fa34ff-9215-4397-8c1e-1f00ced2fecd', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1028', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Vera Lorenz"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '83766fe2-2e9f-41ca-9862-3a7459fdea9f', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1029', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Arno Maier"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '6801de1c-802d-4ec6-9781-17f5ffd20cbe', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1030', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lotte Graf"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '67cddcb9-c467-48cf-a3dc-4d48fdd1cd4b', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1031', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Kai Pfeiffer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'f1e37d99-2f8e-4a92-8138-68ef50bb94d9', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1032', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Mira Zech"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'a6d3f6a1-a01e-431a-9338-28d55b69b0d6', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1033', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Erik Gassner"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'c4fece75-2a7d-46c3-b968-d76c5ec97d47', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1034', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Anna Schmidt"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '692cd876-e621-44d4-b152-f36397684392', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1035', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Tobias Wolfer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '0e4d3be9-f1c6-4278-9e6e-2f7f80956830', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1036', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lena Keller"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '299e0882-fb69-43b2-b496-04a628865953', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1037', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Samuel Sailer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '8d3d4484-4f82-4ac4-85b0-89aa01d415f1', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1038', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Julia Bauer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '51a4fecc-e038-4ffb-b715-a3d4e1c1e7d7', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1039', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Moritz Ismail"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '88907380-da12-4ccb-9f33-b8ab4a00d6d0', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1040', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Eva Huber"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'b3275d03-3b89-477c-9881-2b0a0e2e3ce9', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1041', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Leon Berger"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '74b47dc2-0eb7-44b5-8faa-6ceaae4d8a3d', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1042', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Klara Moser"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '66d71898-d8c4-4d95-847a-496e899d8e9a', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1043', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Felix Unger"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'bed7dceb-8be7-4a71-a4aa-3b344da4dbb9', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1044', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Nina Dorfer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '3ff5d5d5-204b-46fe-a5cc-2db6e8c643f0', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1045', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Jan Klein"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '3c39579c-4216-4206-9346-46fe69c2c280', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1046', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lena Steiner"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '661359f0-8771-4dc8-a517-58822e2f60be', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1047', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Paul Fischer"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'e1a2c232-2dcd-462f-afc8-01b2e4c1646d', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1048', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Sara Oberhuber"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '8bb02227-1008-436c-93ae-d4dbe8c8a063', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ATT-1049', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Markus Winkler"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '8ca780f4-dea0-4848-80d0-12f7529193a6', 'authenticated', 'authenticated', '[email protected]', crypt('appe-admin-2026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Amelia Hernandez"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'a6607c2b-9adc-4eaf-95d1-357076b8ef96', 'authenticated', 'authenticated', '[email protected]', crypt('appe-admin-2026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Sabrina Hota"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', '2eb5e467-eb1e-4c96-a1c8-748173676da4', 'authenticated', 'authenticated', '[email protected]', crypt('appe-admin-2026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Jose Lago"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'c46da711-f429-4410-adde-21d7c6846aef', 'authenticated', 'authenticated', '[email protected]', crypt('appe-admin-2026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Markus Franz"}', now(), now(), now(), now()) on conflict (id) do nothing;
insert into auth.identities (id, provider_id, identity_data, provider, user_id, created_at, updated_at, last_sign_in_at) values
('a40737e3-11ca-48e0-9445-4f72096cdcd4', 'a40737e3-11ca-48e0-9445-4f72096cdcd4', '{"sub":"a40737e3-11ca-48e0-9445-4f72096cdcd4","email":"[email protected]"}', 'email', 'a40737e3-11ca-48e0-9445-4f72096cdcd4', now(), now(), now()),
('298d54fd-6e35-460d-aabf-135e2eefac00', '298d54fd-6e35-460d-aabf-135e2eefac00', '{"sub":"298d54fd-6e35-460d-aabf-135e2eefac00","email":"[email protected]"}', 'email', '298d54fd-6e35-460d-aabf-135e2eefac00', now(), now(), now()),
('446a6e86-73da-41ae-8134-7609556dca96', '446a6e86-73da-41ae-8134-7609556dca96', '{"sub":"446a6e86-73da-41ae-8134-7609556dca96","email":"[email protected]"}', 'email', '446a6e86-73da-41ae-8134-7609556dca96', now(), now(), now()),
('6abea183-d84e-4502-9eb8-b5bc751a3ca4', '6abea183-d84e-4502-9eb8-b5bc751a3ca4', '{"sub":"6abea183-d84e-4502-9eb8-b5bc751a3ca4","email":"[email protected]"}', 'email', '6abea183-d84e-4502-9eb8-b5bc751a3ca4', now(), now(), now()),
('c18e5356-3c14-4a43-8e0b-0739ff0fc1c0', 'c18e5356-3c14-4a43-8e0b-0739ff0fc1c0', '{"sub":"c18e5356-3c14-4a43-8e0b-0739ff0fc1c0","email":"[email protected]"}', 'email', 'c18e5356-3c14-4a43-8e0b-0739ff0fc1c0', now(), now(), now()),
('cf916c0c-b501-4c1b-bd1b-366fbe5fe4d8', 'cf916c0c-b501-4c1b-bd1b-366fbe5fe4d8', '{"sub":"cf916c0c-b501-4c1b-bd1b-366fbe5fe4d8","email":"[email protected]"}', 'email', 'cf916c0c-b501-4c1b-bd1b-366fbe5fe4d8', now(), now(), now()),
('c322e223-6965-4a98-860e-367acfa21202', 'c322e223-6965-4a98-860e-367acfa21202', '{"sub":"c322e223-6965-4a98-860e-367acfa21202","email":"[email protected]"}', 'email', 'c322e223-6965-4a98-860e-367acfa21202', now(), now(), now()),
('52f0e634-09a4-444d-a6e6-cbd9e4ee5b9f', '52f0e634-09a4-444d-a6e6-cbd9e4ee5b9f', '{"sub":"52f0e634-09a4-444d-a6e6-cbd9e4ee5b9f","email":"[email protected]"}', 'email', '52f0e634-09a4-444d-a6e6-cbd9e4ee5b9f', now(), now(), now()),
('4546c422-584b-4108-8a5b-25c832fc0114', '4546c422-584b-4108-8a5b-25c832fc0114', '{"sub":"4546c422-584b-4108-8a5b-25c832fc0114","email":"[email protected]"}', 'email', '4546c422-584b-4108-8a5b-25c832fc0114', now(), now(), now()),
('d2ea8708-22a9-446b-8fb8-833f2f9a733c', 'd2ea8708-22a9-446b-8fb8-833f2f9a733c', '{"sub":"d2ea8708-22a9-446b-8fb8-833f2f9a733c","email":"[email protected]"}', 'email', 'd2ea8708-22a9-446b-8fb8-833f2f9a733c', now(), now(), now()),
('296330bd-a169-4798-8df1-38221381d2e0', '296330bd-a169-4798-8df1-38221381d2e0', '{"sub":"296330bd-a169-4798-8df1-38221381d2e0","email":"[email protected]"}', 'email', '296330bd-a169-4798-8df1-38221381d2e0', now(), now(), now()),
('935f1800-1b99-4894-8891-db2c86491a5b', '935f1800-1b99-4894-8891-db2c86491a5b', '{"sub":"935f1800-1b99-4894-8891-db2c86491a5b","email":"[email protected]"}', 'email', '935f1800-1b99-4894-8891-db2c86491a5b', now(), now(), now()),
('2ce35e62-822a-4e5b-b3c9-e6b5b6cc7531', '2ce35e62-822a-4e5b-b3c9-e6b5b6cc7531', '{"sub":"2ce35e62-822a-4e5b-b3c9-e6b5b6cc7531","email":"[email protected]"}', 'email', '2ce35e62-822a-4e5b-b3c9-e6b5b6cc7531', now(), now(), now()),
('2d1a4f08-19dc-4239-bf3d-27fb912500aa', '2d1a4f08-19dc-4239-bf3d-27fb912500aa', '{"sub":"2d1a4f08-19dc-4239-bf3d-27fb912500aa","email":"[email protected]"}', 'email', '2d1a4f08-19dc-4239-bf3d-27fb912500aa', now(), now(), now()),
('e27a487b-df20-4bf6-83a8-41d17533cbb5', 'e27a487b-df20-4bf6-83a8-41d17533cbb5', '{"sub":"e27a487b-df20-4bf6-83a8-41d17533cbb5","email":"[email protected]"}', 'email', 'e27a487b-df20-4bf6-83a8-41d17533cbb5', now(), now(), now()),
('2daa1a3f-2b27-4532-9d4d-dd1fbe37d3b5', '2daa1a3f-2b27-4532-9d4d-dd1fbe37d3b5', '{"sub":"2daa1a3f-2b27-4532-9d4d-dd1fbe37d3b5","email":"[email protected]"}', 'email', '2daa1a3f-2b27-4532-9d4d-dd1fbe37d3b5', now(), now(), now()),
('67938a9a-5041-4882-8947-4274e78a0bcb', '67938a9a-5041-4882-8947-4274e78a0bcb', '{"sub":"67938a9a-5041-4882-8947-4274e78a0bcb","email":"[email protected]"}', 'email', '67938a9a-5041-4882-8947-4274e78a0bcb', now(), now(), now()),
('eb7570a3-9ffc-4260-bfca-d45bfe128c26', 'eb7570a3-9ffc-4260-bfca-d45bfe128c26', '{"sub":"eb7570a3-9ffc-4260-bfca-d45bfe128c26","email":"elias.mü[email protected]"}', 'email', 'eb7570a3-9ffc-4260-bfca-d45bfe128c26', now(), now(), now()),
('584eed6e-d953-4672-b7c8-891d0674e7f9', '584eed6e-d953-4672-b7c8-891d0674e7f9', '{"sub":"584eed6e-d953-4672-b7c8-891d0674e7f9","email":"[email protected]"}', 'email', '584eed6e-d953-4672-b7c8-891d0674e7f9', now(), now(), now()),
('74a99e87-42b3-4d0a-bc5c-635b22dc2023', '74a99e87-42b3-4d0a-bc5c-635b22dc2023', '{"sub":"74a99e87-42b3-4d0a-bc5c-635b22dc2023","email":"[email protected]"}', 'email', '74a99e87-42b3-4d0a-bc5c-635b22dc2023', now(), now(), now()),
('311399c5-d98c-4785-a94c-617982503e14', '311399c5-d98c-4785-a94c-617982503e14', '{"sub":"311399c5-d98c-4785-a94c-617982503e14","email":"[email protected]"}', 'email', '311399c5-d98c-4785-a94c-617982503e14', now(), now(), now()),
('78be51e6-65f0-46ad-80d5-2399390ff501', '78be51e6-65f0-46ad-80d5-2399390ff501', '{"sub":"78be51e6-65f0-46ad-80d5-2399390ff501","email":"[email protected]"}', 'email', '78be51e6-65f0-46ad-80d5-2399390ff501', now(), now(), now()),
('05a54110-7182-4095-93de-85306ce572d4', '05a54110-7182-4095-93de-85306ce572d4', '{"sub":"05a54110-7182-4095-93de-85306ce572d4","email":"[email protected]"}', 'email', '05a54110-7182-4095-93de-85306ce572d4', now(), now(), now()),
('cd6bc4d5-afb0-4da2-99b9-f3e5bb7c5f32', 'cd6bc4d5-afb0-4da2-99b9-f3e5bb7c5f32', '{"sub":"cd6bc4d5-afb0-4da2-99b9-f3e5bb7c5f32","email":"[email protected]"}', 'email', 'cd6bc4d5-afb0-4da2-99b9-f3e5bb7c5f32', now(), now(), now()),
('d66f79b9-9dec-4a6a-94e7-82f4b0ad01c0', 'd66f79b9-9dec-4a6a-94e7-82f4b0ad01c0', '{"sub":"d66f79b9-9dec-4a6a-94e7-82f4b0ad01c0","email":"[email protected]"}', 'email', 'd66f79b9-9dec-4a6a-94e7-82f4b0ad01c0', now(), now(), now()),
('bb7736de-d32a-41d7-b2d9-ee64275b145e', 'bb7736de-d32a-41d7-b2d9-ee64275b145e', '{"sub":"bb7736de-d32a-41d7-b2d9-ee64275b145e","email":"[email protected]"}', 'email', 'bb7736de-d32a-41d7-b2d9-ee64275b145e', now(), now(), now()),
('f09aca1d-4d95-49a6-a9e0-6f1362fe8361', 'f09aca1d-4d95-49a6-a9e0-6f1362fe8361', '{"sub":"f09aca1d-4d95-49a6-a9e0-6f1362fe8361","email":"[email protected]"}', 'email', 'f09aca1d-4d95-49a6-a9e0-6f1362fe8361', now(), now(), now()),
('d1bbda95-3df1-4c3b-95ee-ed1eb523d30e', 'd1bbda95-3df1-4c3b-95ee-ed1eb523d30e', '{"sub":"d1bbda95-3df1-4c3b-95ee-ed1eb523d30e","email":"[email protected]"}', 'email', 'd1bbda95-3df1-4c3b-95ee-ed1eb523d30e', now(), now(), now()),
('e9fa34ff-9215-4397-8c1e-1f00ced2fecd', 'e9fa34ff-9215-4397-8c1e-1f00ced2fecd', '{"sub":"e9fa34ff-9215-4397-8c1e-1f00ced2fecd","email":"[email protected]"}', 'email', 'e9fa34ff-9215-4397-8c1e-1f00ced2fecd', now(), now(), now()),
('83766fe2-2e9f-41ca-9862-3a7459fdea9f', '83766fe2-2e9f-41ca-9862-3a7459fdea9f', '{"sub":"83766fe2-2e9f-41ca-9862-3a7459fdea9f","email":"[email protected]"}', 'email', '83766fe2-2e9f-41ca-9862-3a7459fdea9f', now(), now(), now()),
('6801de1c-802d-4ec6-9781-17f5ffd20cbe', '6801de1c-802d-4ec6-9781-17f5ffd20cbe', '{"sub":"6801de1c-802d-4ec6-9781-17f5ffd20cbe","email":"[email protected]"}', 'email', '6801de1c-802d-4ec6-9781-17f5ffd20cbe', now(), now(), now()),
('67cddcb9-c467-48cf-a3dc-4d48fdd1cd4b', '67cddcb9-c467-48cf-a3dc-4d48fdd1cd4b', '{"sub":"67cddcb9-c467-48cf-a3dc-4d48fdd1cd4b","email":"[email protected]"}', 'email', '67cddcb9-c467-48cf-a3dc-4d48fdd1cd4b', now(), now(), now()),
('f1e37d99-2f8e-4a92-8138-68ef50bb94d9', 'f1e37d99-2f8e-4a92-8138-68ef50bb94d9', '{"sub":"f1e37d99-2f8e-4a92-8138-68ef50bb94d9","email":"[email protected]"}', 'email', 'f1e37d99-2f8e-4a92-8138-68ef50bb94d9', now(), now(), now()),
('a6d3f6a1-a01e-431a-9338-28d55b69b0d6', 'a6d3f6a1-a01e-431a-9338-28d55b69b0d6', '{"sub":"a6d3f6a1-a01e-431a-9338-28d55b69b0d6","email":"[email protected]"}', 'email', 'a6d3f6a1-a01e-431a-9338-28d55b69b0d6', now(), now(), now()),
('c4fece75-2a7d-46c3-b968-d76c5ec97d47', 'c4fece75-2a7d-46c3-b968-d76c5ec97d47', '{"sub":"c4fece75-2a7d-46c3-b968-d76c5ec97d47","email":"[email protected]"}', 'email', 'c4fece75-2a7d-46c3-b968-d76c5ec97d47', now(), now(), now()),
('692cd876-e621-44d4-b152-f36397684392', '692cd876-e621-44d4-b152-f36397684392', '{"sub":"692cd876-e621-44d4-b152-f36397684392","email":"[email protected]"}', 'email', '692cd876-e621-44d4-b152-f36397684392', now(), now(), now()),
('0e4d3be9-f1c6-4278-9e6e-2f7f80956830', '0e4d3be9-f1c6-4278-9e6e-2f7f80956830', '{"sub":"0e4d3be9-f1c6-4278-9e6e-2f7f80956830","email":"[email protected]"}', 'email', '0e4d3be9-f1c6-4278-9e6e-2f7f80956830', now(), now(), now()),
('299e0882-fb69-43b2-b496-04a628865953', '299e0882-fb69-43b2-b496-04a628865953', '{"sub":"299e0882-fb69-43b2-b496-04a628865953","email":"[email protected]"}', 'email', '299e0882-fb69-43b2-b496-04a628865953', now(), now(), now()),
('8d3d4484-4f82-4ac4-85b0-89aa01d415f1', '8d3d4484-4f82-4ac4-85b0-89aa01d415f1', '{"sub":"8d3d4484-4f82-4ac4-85b0-89aa01d415f1","email":"[email protected]"}', 'email', '8d3d4484-4f82-4ac4-85b0-89aa01d415f1', now(), now(), now()),
('51a4fecc-e038-4ffb-b715-a3d4e1c1e7d7', '51a4fecc-e038-4ffb-b715-a3d4e1c1e7d7', '{"sub":"51a4fecc-e038-4ffb-b715-a3d4e1c1e7d7","email":"[email protected]"}', 'email', '51a4fecc-e038-4ffb-b715-a3d4e1c1e7d7', now(), now(), now()),
('88907380-da12-4ccb-9f33-b8ab4a00d6d0', '88907380-da12-4ccb-9f33-b8ab4a00d6d0', '{"sub":"88907380-da12-4ccb-9f33-b8ab4a00d6d0","email":"[email protected]"}', 'email', '88907380-da12-4ccb-9f33-b8ab4a00d6d0', now(), now(), now()),
('b3275d03-3b89-477c-9881-2b0a0e2e3ce9', 'b3275d03-3b89-477c-9881-2b0a0e2e3ce9', '{"sub":"b3275d03-3b89-477c-9881-2b0a0e2e3ce9","email":"[email protected]"}', 'email', 'b3275d03-3b89-477c-9881-2b0a0e2e3ce9', now(), now(), now()),
('74b47dc2-0eb7-44b5-8faa-6ceaae4d8a3d', '74b47dc2-0eb7-44b5-8faa-6ceaae4d8a3d', '{"sub":"74b47dc2-0eb7-44b5-8faa-6ceaae4d8a3d","email":"[email protected]"}', 'email', '74b47dc2-0eb7-44b5-8faa-6ceaae4d8a3d', now(), now(), now()),
('66d71898-d8c4-4d95-847a-496e899d8e9a', '66d71898-d8c4-4d95-847a-496e899d8e9a', '{"sub":"66d71898-d8c4-4d95-847a-496e899d8e9a","email":"[email protected]"}', 'email', '66d71898-d8c4-4d95-847a-496e899d8e9a', now(), now(), now()),
('bed7dceb-8be7-4a71-a4aa-3b344da4dbb9', 'bed7dceb-8be7-4a71-a4aa-3b344da4dbb9', '{"sub":"bed7dceb-8be7-4a71-a4aa-3b344da4dbb9","email":"[email protected]"}', 'email', 'bed7dceb-8be7-4a71-a4aa-3b344da4dbb9', now(), now(), now()),
('3ff5d5d5-204b-46fe-a5cc-2db6e8c643f0', '3ff5d5d5-204b-46fe-a5cc-2db6e8c643f0', '{"sub":"3ff5d5d5-204b-46fe-a5cc-2db6e8c643f0","email":"[email protected]"}', 'email', '3ff5d5d5-204b-46fe-a5cc-2db6e8c643f0', now(), now(), now()),
('3c39579c-4216-4206-9346-46fe69c2c280', '3c39579c-4216-4206-9346-46fe69c2c280', '{"sub":"3c39579c-4216-4206-9346-46fe69c2c280","email":"[email protected]"}', 'email', '3c39579c-4216-4206-9346-46fe69c2c280', now(), now(), now()),
('661359f0-8771-4dc8-a517-58822e2f60be', '661359f0-8771-4dc8-a517-58822e2f60be', '{"sub":"661359f0-8771-4dc8-a517-58822e2f60be","email":"[email protected]"}', 'email', '661359f0-8771-4dc8-a517-58822e2f60be', now(), now(), now()),
('e1a2c232-2dcd-462f-afc8-01b2e4c1646d', 'e1a2c232-2dcd-462f-afc8-01b2e4c1646d', '{"sub":"e1a2c232-2dcd-462f-afc8-01b2e4c1646d","email":"[email protected]"}', 'email', 'e1a2c232-2dcd-462f-afc8-01b2e4c1646d', now(), now(), now()),
('8bb02227-1008-436c-93ae-d4dbe8c8a063', '8bb02227-1008-436c-93ae-d4dbe8c8a063', '{"sub":"8bb02227-1008-436c-93ae-d4dbe8c8a063","email":"[email protected]"}', 'email', '8bb02227-1008-436c-93ae-d4dbe8c8a063', now(), now(), now()),
('8ca780f4-dea0-4848-80d0-12f7529193a6', '8ca780f4-dea0-4848-80d0-12f7529193a6', '{"sub":"8ca780f4-dea0-4848-80d0-12f7529193a6","email":"[email protected]"}', 'email', '8ca780f4-dea0-4848-80d0-12f7529193a6', now(), now(), now()),
('a6607c2b-9adc-4eaf-95d1-357076b8ef96', 'a6607c2b-9adc-4eaf-95d1-357076b8ef96', '{"sub":"a6607c2b-9adc-4eaf-95d1-357076b8ef96","email":"[email protected]"}', 'email', 'a6607c2b-9adc-4eaf-95d1-357076b8ef96', now(), now(), now()),
('2eb5e467-eb1e-4c96-a1c8-748173676da4', '2eb5e467-eb1e-4c96-a1c8-748173676da4', '{"sub":"2eb5e467-eb1e-4c96-a1c8-748173676da4","email":"[email protected]"}', 'email', '2eb5e467-eb1e-4c96-a1c8-748173676da4', now(), now(), now()),
('c46da711-f429-4410-adde-21d7c6846aef', 'c46da711-f429-4410-adde-21d7c6846aef', '{"sub":"c46da711-f429-4410-adde-21d7c6846aef","email":"[email protected]"}', 'email', 'c46da711-f429-4410-adde-21d7c6846aef', now(), now(), now()) on conflict (id) do nothing;
-- -----------------------------------------------------------------------------
-- CONTACTS (PK = email). 50 attendees + 4 staff (is_admin = admin role).
-- CONTACTS (PK = email). 4 staff (is_admin = admin role).
-- -----------------------------------------------------------------------------
insert into public.contacts (email, full_name, linkedin_url, show_email, show_linkedin, is_admin, password) values
('[email protected]', 'Lena Huber', null, false, false, false, null),
('[email protected]', 'Felix Berger', null, false, false, false, null),
('[email protected]', 'Mia Moser', null, false, false, false, null),
('[email protected]', 'Jonas Unger', null, false, false, false, null),
('[email protected]', 'Emma Dorfer', null, false, false, false, null),
('[email protected]', 'Paul Klein', null, false, false, false, null),
('[email protected]', 'Hannah Steiner', null, false, false, false, null),
('[email protected]', 'Lukas Fischer', null, false, false, false, null),
('[email protected]', 'Sofia Oberhuber', null, false, false, false, null),
('[email protected]', 'David Winkler', null, false, false, false, null),
('[email protected]', 'Clara Falk', null, false, false, false, null),
('[email protected]', 'Max Wagner', null, false, false, false, null),
('[email protected]', 'Ella Hofer', null, false, false, false, null),
('[email protected]', 'Finn Hofmann', null, false, false, false, null),
('[email protected]', 'Livia Rainer', null, false, false, false, null),
('[email protected]', 'Noah Aigner', null, false, false, false, null),
('[email protected]', 'Mara Hartl', null, false, false, false, null),
('elias.mü[email protected]', 'Elias Müller', null, false, false, false, null),
('[email protected]', 'Nora Pichler', null, false, false, false, null),
('[email protected]', 'Ben Lederer', null, false, false, false, null),
('[email protected]', 'Ida Tausch', null, false, false, false, null),
('[email protected]', 'Oscar Cerny', null, false, false, false, null),
('[email protected]', 'Freja Jank', null, false, false, false, null),
('[email protected]', 'Hugo Gruber', null, false, false, false, null),
('[email protected]', 'Alma Egger', null, false, false, false, null),
('[email protected]', 'Theo Nagl', null, false, false, false, null),
('[email protected]', 'Greta Vogler', null, false, false, false, null),
('[email protected]', 'Milo Eisen', null, false, false, false, null),
('[email protected]', 'Vera Lorenz', null, false, false, false, null),
('[email protected]', 'Arno Maier', null, false, false, false, null),
('[email protected]', 'Lotte Graf', null, false, false, false, null),
('[email protected]', 'Kai Pfeiffer', null, false, false, false, null),
('[email protected]', 'Mira Zech', null, false, false, false, null),
('[email protected]', 'Erik Gassner', null, false, false, false, null),
('[email protected]', 'Anna Schmidt', null, false, false, false, null),
('[email protected]', 'Tobias Wolfer', null, false, false, false, null),
('[email protected]', 'Lena Keller', null, false, false, false, null),
('[email protected]', 'Samuel Sailer', null, false, false, false, null),
('[email protected]', 'Julia Bauer', null, false, false, false, null),
('[email protected]', 'Moritz Ismail', null, false, false, false, null),
('[email protected]', 'Eva Huber', null, false, false, false, null),
('[email protected]', 'Leon Berger', null, false, false, false, null),
('[email protected]', 'Klara Moser', null, false, false, false, null),
('[email protected]', 'Felix Unger', null, false, false, false, null),
('[email protected]', 'Nina Dorfer', null, false, false, false, null),
('[email protected]', 'Jan Klein', null, false, false, false, null),
('[email protected]', 'Lena Steiner', null, false, false, false, null),
('[email protected]', 'Paul Fischer', null, false, false, false, null),
('[email protected]', 'Sara Oberhuber', null, false, false, false, null),
('[email protected]', 'Markus Winkler', null, false, false, false, null),
('[email protected]', 'Amelia Hernandez', null, false, false, true, 'appe-admin-2026'),
('[email protected]', 'Sabrina Hota', null, false, false, true, 'appe-admin-2026'),
('[email protected]', 'Jose Lago', null, false, false, true, 'appe-admin-2026'),
@@ -193,60 +43,10 @@ insert into public.events (id, name, start_date, end_date, location, is_active,
on conflict (id) do update set name = excluded.name, start_date = excluded.start_date, end_date = excluded.end_date, location = excluded.location, is_active = true, sessionize_endpoint = excluded.sessionize_endpoint;
-- -----------------------------------------------------------------------------
-- REGISTRATIONS (50 attendee + 4 staff). Speaker registrations are created by
-- REGISTRATIONS (4 staff). Speaker registrations are created by
-- the Excel import (matched by email).
-- -----------------------------------------------------------------------------
insert into public.registrations (event_id, contact_email, type, checked_in, points, qr_token) values
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1000'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1001'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1002'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1003'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1004'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1005'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1006'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1007'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1008'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1009'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1010'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1011'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1012'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1013'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1014'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1015'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1016'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', 'elias.mü[email protected]', 'attendee', false, 0, 'CVV-ATT-1017'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1018'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1019'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1020'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1021'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1022'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1023'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1024'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1025'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1026'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1027'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1028'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1029'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1030'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1031'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1032'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1033'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1034'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1035'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1036'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1037'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1038'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1039'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1040'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1041'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1042'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1043'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1044'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1045'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1046'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1047'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1048'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'attendee', false, 0, 'CVV-ATT-1049'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'staff', false, 0, 'CVV-STF-2000'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'staff', false, 0, 'CVV-STF-2001'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 'staff', false, 0, 'CVV-STF-2002'),
@@ -458,58 +258,3 @@ from public.registrations r
join public.contacts c on c.email = r.contact_email
where r.type <> 'staff'
on conflict (event_id, contact_email) do update set full_name = excluded.full_name, points = excluded.points, updated_at = now();
-- -----------------------------------------------------------------------------
-- POINTS LOG (a small starting balance per attendee so the board is alive).
-- -----------------------------------------------------------------------------
insert into public.points_log (event_id, contact_email, delta, category) values
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 5, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 12, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 19, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 26, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 33, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 40, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 7, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 14, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 21, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 28, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 35, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 42, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 9, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 16, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 23, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 30, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 37, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', 'elias.mü[email protected]', 44, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 11, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 18, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 25, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 32, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 39, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 6, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 13, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 20, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 27, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 34, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 41, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 8, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 15, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 22, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 29, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 36, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 43, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 10, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 17, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 24, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 31, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 38, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 5, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 12, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 19, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 26, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 33, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 40, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 7, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 14, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 21, 'admin'),
('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', '[email protected]', 28, 'admin');
@@ -0,0 +1,67 @@
\set ON_ERROR_STOP on
begin;
create function pg_temp.assert_admin_entry(p_condition boolean, p_name text)
returns void language plpgsql as $$
begin
if p_condition is distinct from true then raise exception 'FAIL: %', p_name; end if;
raise notice 'PASS: %', p_name;
end;
$$;
create temporary table admin_entry_identity as
select kind, gen_random_uuid() as user_id,
'entry-' || kind || '-' || gen_random_uuid() ||
case when kind = 'domain' then '@appe.at' else '@example.invalid' end as email
from unnest(array['admin', 'domain', 'attendee', 'speaker', 'noauth', 'authonly']) as kind;
grant select on admin_entry_identity to anon, authenticated;
create temporary table admin_entry_before as
select
(select coalesce(jsonb_agg(to_jsonb(registration) order by registration.id), '[]') from public.registrations registration) as registrations,
(select coalesce(jsonb_agg(to_jsonb(checkin) order by checkin.id), '[]') from public.checkins checkin) as checkins,
(select coalesce(jsonb_agg(to_jsonb(points) order by points.id), '[]') from public.points_log points) as points_log;
insert into auth.users(id, instance_id, aud, role, email, encrypted_password, email_confirmed_at, raw_app_meta_data, raw_user_meta_data, created_at, updated_at)
select user_id, '00000000-0000-0000-0000-000000000000'::uuid, 'authenticated', 'authenticated', email,
'', now(), '{}'::jsonb, '{"is_admin":true}'::jsonb, now(), now()
from admin_entry_identity where kind <> 'noauth';
insert into public.contacts(email, full_name, is_admin)
select email, 'Entry regression ' || kind, kind in ('admin', 'noauth')
from admin_entry_identity where kind <> 'authonly';
select pg_temp.assert_admin_entry(has_function_privilege('anon', 'public.can_request_admin_magic_link(text)', 'execute'), 'anonymous eligibility lookup allowed');
select pg_temp.assert_admin_entry(has_function_privilege('authenticated', 'public.can_request_admin_magic_link(text)', 'execute'), 'authenticated eligibility lookup allowed');
select pg_temp.assert_admin_entry(not exists (
select 1 from pg_proc as routine, lateral aclexplode(routine.proacl) as privilege
where routine.oid = 'public.can_request_admin_magic_link(text)'::regprocedure and privilege.grantee = 0
), 'no PUBLIC execution grant');
set local role anon;
select pg_temp.assert_admin_entry(public.can_request_admin_magic_link(email), 'flagged admin with Auth user eligible without registration') from admin_entry_identity where kind = 'admin';
select pg_temp.assert_admin_entry(public.can_request_admin_magic_link(email), 'existing domain admin eligible') from admin_entry_identity where kind = 'domain';
select pg_temp.assert_admin_entry(public.can_request_admin_magic_link(' ' || upper(email) || ' '), 'email normalization supported') from admin_entry_identity where kind = 'admin';
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(email), 'non-admin attendee denied despite user metadata') from admin_entry_identity where kind = 'attendee';
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(email), 'non-admin speaker denied despite user metadata') from admin_entry_identity where kind = 'speaker';
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(email), 'admin contact without Auth user denied') from admin_entry_identity where kind = 'noauth';
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(email), 'Auth user without contact denied') from admin_entry_identity where kind = 'authonly';
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(null), 'null denied');
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(''), 'empty denied');
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link('[email protected]'), 'unknown denied');
reset role;
select set_config('request.jwt.claims', json_build_object('email', email, 'role', 'authenticated', 'user_metadata', json_build_object('is_admin', true))::text, true)
from admin_entry_identity where kind = 'attendee';
set local role authenticated;
select pg_temp.assert_admin_entry(not public.is_admin(), 'callback authorization ignores editable metadata');
select pg_temp.assert_admin_entry(not public.can_request_admin_magic_link(email), 'authenticated non-admin still ineligible') from admin_entry_identity where kind = 'attendee';
reset role;
select pg_temp.assert_admin_entry(
(select registrations from admin_entry_before) = (select coalesce(jsonb_agg(to_jsonb(registration) order by registration.id), '[]') from public.registrations registration), 'registrations and attendance unchanged');
select pg_temp.assert_admin_entry(
(select checkins from admin_entry_before) = (select coalesce(jsonb_agg(to_jsonb(checkin) order by checkin.id), '[]') from public.checkins checkin), 'session checkins unchanged');
select pg_temp.assert_admin_entry(
(select points_log from admin_entry_before) = (select coalesce(jsonb_agg(to_jsonb(points) order by points.id), '[]') from public.points_log points), 'points log unchanged');
rollback;
@@ -0,0 +1,95 @@
\set ON_ERROR_STOP on
create function pg_temp.assert_speaker_role(p_condition boolean, p_name text) returns void
language plpgsql as $$ begin
if p_condition is distinct from true then raise exception 'FAIL: %', p_name; end if;
raise notice 'PASS: %', p_name;
end; $$;
create temp table role_fixture as select
gen_random_uuid() event_a, gen_random_uuid() event_b,
gen_random_uuid() talk, gen_random_uuid() service,
gen_random_uuid() reverse_talk,
'role-ticket-' || gen_random_uuid() || '@example.invalid' ticket_email,
'role-first-' || gen_random_uuid() || '@example.invalid' first_email,
'role-normal-' || gen_random_uuid() || '@example.invalid' normal_email,
'role-staff-' || gen_random_uuid() || '@example.invalid' staff_email,
'role-sponsor-' || gen_random_uuid() || '@example.invalid' sponsor_email,
'role-service-' || gen_random_uuid() || '@example.invalid' service_email,
-5000000-floor(random()*1000000)::integer talk_slot,
-7000000-floor(random()*1000000)::integer service_slot;
insert into public.events(id,name,start_date,end_date)
select event_a,'Role A',date '2026-11-01',date '2026-11-01' from role_fixture
union all select event_b,'Role B',date '2026-11-01',date '2026-11-01' from role_fixture;
insert into public.contacts(email,full_name)
select ticket_email,'Ticket Speaker' from role_fixture
union all select first_email,'First Speaker' from role_fixture
union all select normal_email,'Normal Attendee' from role_fixture
union all select staff_email,'Staff' from role_fixture
union all select sponsor_email,'Sponsor' from role_fixture
union all select service_email,'Service Only' from role_fixture;
insert into public.slots(id,event_id,type,name,slot_date,start_time,end_time)
select talk_slot,event_a,'session'::public.slot_type,'Talk',date '2026-11-01',time '09:00',time '10:00' from role_fixture
union all select service_slot,event_a,'service_session','Break',date '2026-11-01',time '10:00',time '11:00' from role_fixture;
insert into public.sessions(id,event_id,slot_id,title,external_id)
select talk,event_a,talk_slot,'Role talk',talk::text from role_fixture
union all select reverse_talk,event_a,talk_slot,'Reverse talk',reverse_talk::text from role_fixture
union all select service,event_a,service_slot,'Role break',service::text from role_fixture;
insert into public.session_speakers(session_id,contact_email)
select reverse_talk,first_email from role_fixture
union all select service,service_email from role_fixture;
select set_config('request.jwt.claims','{"role":"service_role"}',true);
create temp table role_sync_result as
select public.sync_pretix_attendees(event_a,jsonb_build_array(
jsonb_build_object('email',ticket_email,'full_name','Ticket Speaker','ticket_type','attendee','qr_token','role-ticket-qr','external_id','pretix-role'),
jsonb_build_object('email',first_email,'full_name','First Speaker','ticket_type','attendee','qr_token','role-first-qr','external_id','pretix-first'),
jsonb_build_object('email',normal_email,'full_name','Normal Attendee','ticket_type','attendee','qr_token','role-normal-qr','external_id','pretix-normal'),
jsonb_build_object('email',service_email,'full_name','Service Only','ticket_type','attendee','qr_token','role-service-qr','external_id','pretix-service')
)) result from role_fixture;
select pg_temp.assert_speaker_role(jsonb_array_length(result->'errors')=0,'initial Pretix sync succeeds') from role_sync_result;
select pg_temp.assert_speaker_role((select type='attendee' from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'ordinary ticket starts as attendee') from role_fixture f;
select pg_temp.assert_speaker_role((select type='speaker' from public.registrations where event_id=f.event_a and contact_email=f.first_email),'existing assignment promotes new Pretix registration') from role_fixture f;
select pg_temp.assert_speaker_role((select type='attendee' from public.registrations where event_id=f.event_a and contact_email=f.service_email),'service-only assignment does not promote attendee') from role_fixture f;
update public.registrations set points=23,checked_in=true where contact_email=(select ticket_email from role_fixture);
insert into public.sponsors(event_id,type,name,contact_email)
select event_a,'community','Role Sponsor',sponsor_email from role_fixture;
insert into public.registrations(event_id,contact_email,type)
select event_a,staff_email,'staff'::public.registration_type from role_fixture
union all select event_a,sponsor_email,'sponsor' from role_fixture
union all select event_b,ticket_email,'attendee' from role_fixture;
insert into public.session_speakers(session_id,contact_email)
select talk,ticket_email from role_fixture
union all select talk,staff_email from role_fixture
union all select talk,sponsor_email from role_fixture;
select pg_temp.assert_speaker_role((select type='speaker' from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'assignment promotes purchased ticket') from role_fixture f;
select pg_temp.assert_speaker_role((select type='attendee' from public.registrations where event_id=f.event_b and contact_email=f.ticket_email),'other event remains attendee') from role_fixture f;
select pg_temp.assert_speaker_role((select type='staff' from public.registrations where contact_email=f.staff_email),'staff role preserved') from role_fixture f;
select pg_temp.assert_speaker_role((select type='sponsor' from public.registrations where contact_email=f.sponsor_email),'sponsor role preserved') from role_fixture f;
update role_sync_result set result=(select public.sync_pretix_attendees(event_a,jsonb_build_array(
jsonb_build_object('email',ticket_email,'full_name','Ticket Speaker','ticket_type','attendee','qr_token','role-ticket-qr','external_id','pretix-role')
)) from role_fixture);
select pg_temp.assert_speaker_role(jsonb_array_length(result->'errors')=0,'repeated Pretix sync succeeds') from role_sync_result;
select pg_temp.assert_speaker_role((select type='speaker' and qr_token='role-ticket-qr' and external_id='pretix-role' and checked_in and points=23
from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'Pretix cannot downgrade speaker; ticket and activity preserved') from role_fixture f;
update role_sync_result set result=(select public.sync_sessionize_excel(event_a,jsonb_build_object(
'speakers',jsonb_build_array(jsonb_build_object('email',ticket_email,'full_name','Ticket Speaker','external_id','sessionize-role')),
'sessions',jsonb_build_array(jsonb_build_object('external_id',talk::text,'title','Role talk','date','2026-11-01','start_time','09:00','end_time','10:00',
'speakers',jsonb_build_array(ticket_email,staff_email,sponsor_email)))
)) from role_fixture);
select pg_temp.assert_speaker_role(jsonb_array_length(result->'errors')=0,'Excel replay succeeds') from role_sync_result;
select pg_temp.assert_speaker_role((select type='speaker' and qr_token='role-ticket-qr' and external_id='pretix-role' and checked_in and points=23 and import_source='sessionize'
from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'Excel preserves purchased speaker ticket') from role_fixture f;
select pg_temp.assert_speaker_role(exists(select 1 from public.session_speakers where session_id=f.talk and contact_email=f.ticket_email),'Excel keeps correct session assignment') from role_fixture f;
update role_sync_result set result=(select public.sync_pretix_attendees(event_a,jsonb_build_array(
jsonb_build_object('email',ticket_email,'full_name','Ticket Speaker','ticket_type','attendee','qr_token','role-ticket-qr','external_id','pretix-role')
)) from role_fixture);
select pg_temp.assert_speaker_role(jsonb_array_length(result->'errors')=0,'Pretix after Excel succeeds') from role_sync_result;
select pg_temp.assert_speaker_role((select type='speaker' and qr_token='role-ticket-qr' and checked_in and points=23
from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'Excel then Pretix retains speaker role and ticket') from role_fixture f;
update public.session_speakers set contact_email=(select normal_email from role_fixture)
where session_id=(select reverse_talk from role_fixture) and contact_email=(select first_email from role_fixture);
select pg_temp.assert_speaker_role((select type='speaker' from public.registrations where event_id=f.event_a and contact_email=f.normal_email),'assignment update promotes new speaker') from role_fixture f;
update public.registrations set type='attendee' where event_id=(select event_a from role_fixture) and contact_email=(select ticket_email from role_fixture);
select pg_temp.assert_speaker_role((select type='speaker' from public.registrations where event_id=f.event_a and contact_email=f.ticket_email),'direct downgrade blocked while assigned') from role_fixture f;
select pg_temp.assert_speaker_role(not has_function_privilege('anon','public._preserve_assigned_speaker_role()','execute')
and not has_function_privilege('authenticated','public._preserve_assigned_speaker_role()','execute'),'internal role trigger not exposed') from role_fixture;
rollback;
@@ -0,0 +1,131 @@
\set ON_ERROR_STOP on
create function pg_temp.assert_merge(p_condition boolean, p_name text) returns void
language plpgsql as $$ begin
if p_condition is distinct from true then raise exception 'FAIL: %', p_name; end if;
raise notice 'PASS: %', p_name;
end; $$;
create function pg_temp.reject_merge(p_source uuid, p_target uuid, p_name text) returns void
language plpgsql as $$ begin
begin
perform public.merge_tickets(p_source, p_target);
exception when others then
raise notice 'PASS: % rejected', p_name;
return;
end;
raise exception 'FAIL: % was allowed', p_name;
end; $$;
create temporary table merge_fixture as select
gen_random_uuid() event_a, gen_random_uuid() event_b,
gen_random_uuid() source_id, gen_random_uuid() target_id, gen_random_uuid() other_id,
gen_random_uuid() manual_id, gen_random_uuid() staff_id, gen_random_uuid() staff_target_id,
gen_random_uuid() session_a, gen_random_uuid() session_b, gen_random_uuid() session_shared,
'merge-source-' || gen_random_uuid() || '@example.invalid' source_email,
'merge-target-' || gen_random_uuid() || '@example.invalid' target_email,
'merge-manual-' || gen_random_uuid() || '@example.invalid' manual_email,
'merge-staff-' || gen_random_uuid() || '@example.invalid' staff_email,
'merge-staff-ticket-' || gen_random_uuid() || '@example.invalid' staff_target_email,
'merge-admin-' || gen_random_uuid() || '@example.invalid' admin_email,
-1000000 - floor(random() * 1000000)::integer slot_a,
-3000000 - floor(random() * 1000000)::integer slot_b;
grant select on merge_fixture to authenticated, anon;
insert into public.contacts(email,full_name,is_admin,external_id)
select source_email,'Alex Smith',false,'sessionize-test-source' from merge_fixture
union all select target_email,'Alex Smith',false,null from merge_fixture
union all select manual_email,'Manual Person',false,null from merge_fixture
union all select staff_email,'Staff Person',false,'sessionize-test-staff' from merge_fixture
union all select staff_target_email,'Staff Ticket',false,null from merge_fixture
union all select admin_email,'Merge Admin',true,null from merge_fixture;
insert into public.events(id,name,start_date,end_date)
select event_a,'Merge A',date '2026-11-01',date '2026-11-01' from merge_fixture
union all select event_b,'Merge B',date '2026-12-01',date '2026-12-01' from merge_fixture;
insert into public.slots(id,event_id,type,name,slot_date,start_time,end_time)
select slot_a,event_a,'session'::public.slot_type,'Merge A',date '2026-11-01',time '09:00',time '10:00' from merge_fixture
union all select slot_b,event_b,'session','Merge B',date '2026-12-01',time '09:00',time '10:00' from merge_fixture;
insert into public.sessions(id,event_id,slot_id,title,external_id)
select session_a,event_a,slot_a,'Merge talk',session_a::text from merge_fixture
union all select session_shared,event_a,slot_a,'Shared talk',session_shared::text from merge_fixture
union all select session_b,event_b,slot_b,'Other event talk',session_b::text from merge_fixture;
insert into public.registrations(id,event_id,contact_email,type,qr_token,external_id,import_source,checked_in)
select source_id,event_a,source_email,'speaker'::public.registration_type,null,null,'sessionize',false from merge_fixture
union all select target_id,event_a,target_email,'staff',target_id::text,'pretix-target',null,true from merge_fixture
union all select other_id,event_b,target_email,'attendee',other_id::text,'pretix-other',null,false from merge_fixture
union all select manual_id,event_a,manual_email,'attendee',' ',null,null,true from merge_fixture
union all select staff_id,event_a,staff_email,'staff',null,null,'sessionize',false from merge_fixture
union all select staff_target_id,event_a,staff_target_email,'attendee',staff_target_id::text,'pretix-staff-target',null,false from merge_fixture;
insert into public.session_speakers(session_id,contact_email)
select session_a,source_email from merge_fixture
union all select session_shared,source_email from merge_fixture
union all select session_shared,target_email from merge_fixture
union all select session_b,source_email from merge_fixture;
update public.registrations set points = 17 where id = (select target_id from merge_fixture);
select pg_temp.assert_merge((select num_registrations=2 and num_checked_in_registrations=1
from public.events where id=(select event_a from merge_fixture)), 'QR-less and blank-QR rows excluded from totals');
select pg_temp.assert_merge(not has_function_privilege('anon','public.merge_tickets(uuid,uuid)','execute'), 'anon execution revoked');
select pg_temp.assert_merge(has_function_privilege('authenticated','public.merge_tickets(uuid,uuid)','execute'), 'authenticated execution granted');
select pg_temp.reject_merge(source_id,target_id,'unauthenticated merge') from merge_fixture;
select set_config('request.jwt.claims',jsonb_build_object('sub',gen_random_uuid(),'email',manual_email,'role','authenticated')::text,true) from merge_fixture;
set local role authenticated;
select pg_temp.reject_merge(source_id,target_id,'non-admin merge') from merge_fixture;
reset role;
select set_config('request.jwt.claims',jsonb_build_object('sub',gen_random_uuid(),'email',admin_email,'role','authenticated')::text,true) from merge_fixture;
set local role authenticated;
select pg_temp.reject_merge(source_id,other_id,'cross-event merge') from merge_fixture;
select pg_temp.reject_merge(source_id,source_id,'self merge') from merge_fixture;
select pg_temp.reject_merge(manual_id,target_id,'manual source') from merge_fixture;
select pg_temp.reject_merge(source_id,staff_id,'QR-less destination') from merge_fixture;
reset role;
update public.registrations set checked_in = true where id = (select source_id from merge_fixture);
set local role authenticated;
select pg_temp.reject_merge(source_id,target_id,'source attendance must be reconciled') from merge_fixture;
reset role;
update public.registrations set checked_in = false where id = (select source_id from merge_fixture);
set local role authenticated;
create temporary table merge_result as select public.merge_tickets(source_id,target_id) result from merge_fixture;
reset role;
select pg_temp.assert_merge((select (result->>'sessions_transferred')::integer=2 from merge_result), 'two source assignments transferred');
select pg_temp.assert_merge(not exists(select 1 from public.registrations where id=(select source_id from merge_fixture)), 'source registration deleted');
select pg_temp.assert_merge((select type='staff' and checked_in and points=17 and qr_token=id::text and external_id='pretix-target'
from public.registrations where id=(select target_id from merge_fixture)), 'target staff status QR and attendance preserved');
select pg_temp.assert_merge((select count(*)=2 from public.session_speakers where contact_email=(select target_email from merge_fixture)
and session_id in(select session_a from merge_fixture union all select session_shared from merge_fixture)), 'replacement links inserted without duplicates');
select pg_temp.assert_merge(not exists(select 1 from public.session_speakers where contact_email=(select source_email from merge_fixture)
and session_id in(select session_a from merge_fixture union all select session_shared from merge_fixture)), 'old event links removed');
select pg_temp.assert_merge(exists(select 1 from public.session_speakers where contact_email=(select source_email from merge_fixture)
and session_id=(select session_b from merge_fixture)), 'other event speaker link unchanged');
select pg_temp.assert_merge(exists(select 1 from public.contacts where email=(select source_email from merge_fixture)), 'source contact preserved');
select pg_temp.assert_merge((select type='attendee' from public.registrations where id=(select other_id from merge_fixture)), 'other event registration unchanged');
set local role authenticated;
select pg_temp.reject_merge(source_id,target_id,'repeated merge') from merge_fixture;
select public.merge_tickets(staff_id,staff_target_id) from merge_fixture;
reset role;
select pg_temp.assert_merge((select type='staff' from public.registrations where id=(select staff_target_id from merge_fixture)), 'staff role transferred to attendee ticket');
update public.registrations set type='attendee' where id=(select target_id from merge_fixture);
select pg_temp.assert_merge((select type='staff' from public.registrations where id=(select target_id from merge_fixture)), 'later Pretix-style role update cannot downgrade merged role');
select set_config('request.jwt.claims','{"role":"service_role"}',true);
select public.sync_sessionize_excel(event_a,jsonb_build_object(
'speakers',jsonb_build_array(jsonb_build_object('email',source_email,'full_name','Alex Smith','external_id','sessionize-test-source')),
'sessions',jsonb_build_array(jsonb_build_object('external_id',session_a::text,'title','Merge talk',
'date','2026-11-01','start_time','09:00','end_time','10:00','speakers',jsonb_build_array(source_email)))
)) from merge_fixture;
select pg_temp.assert_merge(not exists(select 1 from public.registrations where contact_email=(select source_email from merge_fixture)
and event_id=(select event_a from merge_fixture)), 'Excel reimport does not recreate source');
select pg_temp.assert_merge(exists(select 1 from public.session_speakers where contact_email=(select target_email from merge_fixture)
and session_id=(select session_a from merge_fixture)), 'Excel reimport retains canonical speaker link');
select pg_temp.assert_merge(not exists(select 1 from public.session_speakers where contact_email=(select source_email from merge_fixture)
and session_id=(select session_a from merge_fixture)), 'Excel reimport does not restore old link');
select pg_temp.assert_merge((select type='staff' from public.registrations where id=(select target_id from merge_fixture)), 'Excel reimport retains merged role');
select public.sync_sessionize_excel(event_a,jsonb_build_object('speakers',jsonb_build_array(
jsonb_build_object('email',manual_email,'full_name','Manual Person','external_id','sessionize-manual')
), 'sessions','[]'::jsonb)) from merge_fixture;
select pg_temp.assert_merge((select import_source='sessionize' and type='speaker' from public.registrations
where id=(select manual_id from merge_fixture)), 'Excel marks preexisting registrations as imported');
select public.sync_sessionize_event(event_a,jsonb_build_object('sessions',jsonb_build_array(
jsonb_build_object('external_id',session_a::text,'title','Merge talk','date','2026-11-01',
'start_time','09:00','end_time','10:00','speakers',jsonb_build_array(source_email))
), 'speakers','[]'::jsonb)) from merge_fixture;
select pg_temp.assert_merge(exists(select 1 from public.session_speakers where contact_email=(select target_email from merge_fixture)
and session_id=(select session_a from merge_fixture)), 'API reimport retains canonical speaker link');
rollback;