-- FREE content is accessible without a subscription; PREMIUM requires one.
-- Effective tier cascades at read time: any PREMIUM ancestor makes descendants PREMIUM.

ALTER TABLE programs
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_programs_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE courses
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_courses_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE modules
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_modules_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE lessons
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_lessons_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE exam_prep.catalog_courses
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_exam_prep_catalog_courses_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE exam_prep.units
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_exam_prep_units_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE exam_prep.unit_modules
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_exam_prep_unit_modules_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));

ALTER TABLE exam_prep.unit_module_lessons
    ADD COLUMN access_tier VARCHAR(16) NOT NULL DEFAULT 'PREMIUM'
        CONSTRAINT chk_exam_prep_unit_module_lessons_access_tier CHECK (access_tier IN ('FREE', 'PREMIUM'));
