| -- Make student_profiles.exam_date nullable. | |
| -- | |
| -- A student who does not yet know their exam date must be able to finish | |
| -- onboarding ("I don't know my exam date yet"); the adaptive planner then uses | |
| -- a steady default horizon instead of a fabricated date. The column was | |
| -- originally NOT NULL; relax it without touching existing rows. | |
| -- | |
| -- Idempotent: DROP NOT NULL is a no-op if the constraint is already gone. | |
| -- Non-destructive: no data is read, written, or dropped. Existing exam dates | |
| -- are preserved exactly. | |
| alter table public.student_profiles | |
| alter column exam_date drop not null; | |
| -- Downgrade (manual, only safe when no NULL rows exist): | |
| -- update public.student_profiles set exam_date = current_date + 90 | |
| -- where exam_date is null; -- choose a policy before running | |
| -- alter table public.student_profiles | |
| -- alter column exam_date set not null; | |