create table clazz_leave_request
(
    id varchar not null,
    org_id varchar not null,
    clazz_id varchar not null
        constraint clazz_leave_request_clazz_id_fk
            references clazz (id),
    student_id varchar not null,
    teacher_id varchar,
    leave_type varchar not null,
    reason varchar,
    request_status varchar not null default 'PENDING',
    created_at timestamp not null default now(),
    created_by varchar,
    reviewed_at timestamp,
    reviewed_by varchar,
    is_delete boolean not null default false
);

create unique index clazz_leave_request_id_uindex
    on clazz_leave_request (id);

alter table clazz_leave_request
    add constraint clazz_leave_request_pk
        primary key (id);

create index idx_clazz_leave_request_org_id
    on clazz_leave_request (org_id);

create index idx_clazz_leave_request_clazz_id
    on clazz_leave_request (clazz_id);

create index idx_clazz_leave_request_student_id
    on clazz_leave_request (student_id);
