-- Employment status + full-time check-in window on users; late flag on attendance.
-- Run once in Supabase SQL editor.

alter table public.users
  add column if not exists employment_status text;

alter table public.users
  add column if not exists check_in_window text;

update public.users
set employment_status = 'part_time'
where employment_status is null or employment_status = '';

alter table public.users
  alter column employment_status set default 'part_time';

alter table public.users
  alter column employment_status set not null;

alter table public.users
  drop constraint if exists users_employment_status_check;

alter table public.users
  add constraint users_employment_status_check
  check (employment_status in ('part_time', 'full_time'));

alter table public.users
  drop constraint if exists users_check_in_window_check;

alter table public.users
  add constraint users_check_in_window_check
  check (
    check_in_window is null
    or check_in_window in ('09:00-10:00', '09:30-10:30')
  );

alter table public.attendance_sessions
  add column if not exists is_late boolean not null default false;
