RezinaLMS-BackEnd/db/migrations/000115_education_subscription_category.up.sql

20 lines
837 B
SQL

-- Generalize the active LMS subscription product. Keep inactive legacy plan rows
-- available for historical billing and reporting records.
ALTER TABLE subscription_plans DROP CONSTRAINT IF EXISTS chk_subscription_plans_category;
ALTER TABLE subscription_plans
ADD CONSTRAINT chk_subscription_plans_category
CHECK (category IN ('EDUCATION', 'LEARN_ENGLISH', 'IELTS', 'DUOLINGO'));
UPDATE subscription_plans
SET category = 'EDUCATION', updated_at = NOW()
WHERE category = 'LEARN_ENGLISH';
UPDATE subscription_plans
SET is_active = FALSE, updated_at = NOW()
WHERE category IN ('IELTS', 'DUOLINGO');
ALTER TABLE programs DROP CONSTRAINT IF EXISTS chk_programs_category;
UPDATE programs SET category = 'EDUCATION', updated_at = NOW();
ALTER TABLE programs
ADD CONSTRAINT chk_programs_category CHECK (category = 'EDUCATION');