CREATE TABLE public.sessions
(
    session_id integer NOT NULL DEFAULT nextval('sessions_session_id_seq'::regclass),
    course_id integer NOT NULL,
    created_by bigint NOT NULL,
    title character varying(200) NOT NULL,
    scheduled_at timestamp with time zone NOT NULL,
    duration_min integer NOT NULL DEFAULT 90,
    zoom_meeting_id character varying(50),
    zoom_join_url text,
    status session_status NOT NULL DEFAULT 'SCHEDULED'::session_status,
    created_at timestamp with time zone NOT NULL DEFAULT now(),
    participant_roles text[] NOT NULL DEFAULT '{STUDENT,TUTOR}'::text[],
    attendance_synced_at timestamp with time zone,
    schedule_id integer,
    notify_at timestamp with time zone,
    notifications_sent_at timestamp with time zone,
    CONSTRAINT sessions_course_id_fkey FOREIGN KEY (course_id) REFERENCES courses(course_id),
    CONSTRAINT sessions_created_by_fkey FOREIGN KEY (created_by) REFERENCES partners(partner_id),
    CONSTRAINT sessions_schedule_id_fkey FOREIGN KEY (schedule_id) REFERENCES session_schedules(schedule_id),
    CONSTRAINT sessions_pkey PRIMARY KEY (session_id)
);
