-- Draft vs published visibility for the remaining LMS and exam-prep hierarchy levels
-- (mirrors lessons.publish_status from 000062 and practice publish_status from 000060).
-- Existing rows stay PUBLISHED; new inserts default to DRAFT unless the API sends PUBLISHED.

-- LMS hierarchy
ALTER TABLE programs
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_programs_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE programs
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

ALTER TABLE courses
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_courses_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE courses
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

ALTER TABLE modules
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_modules_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE modules
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

-- Exam-prep hierarchy
ALTER TABLE exam_prep.catalog_courses
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_exam_prep_catalog_courses_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE exam_prep.catalog_courses
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

ALTER TABLE exam_prep.units
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_exam_prep_units_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE exam_prep.units
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

ALTER TABLE exam_prep.unit_modules
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_exam_prep_unit_modules_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE exam_prep.unit_modules
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';

ALTER TABLE exam_prep.unit_module_lessons
    ADD COLUMN publish_status VARCHAR(16) NOT NULL DEFAULT 'PUBLISHED'
        CONSTRAINT chk_exam_prep_unit_module_lessons_publish_status CHECK (publish_status IN ('DRAFT', 'PUBLISHED'));

ALTER TABLE exam_prep.unit_module_lessons
    ALTER COLUMN publish_status SET DEFAULT 'DRAFT';
