// Learning Hub is retired. My Resources generates better slides from a typed // deck, and the articles and quizzes live in the quiz app. // // The content was exported before this ran — every article as markdown plus a // full SQL dump of all five tables — to ops-backups/learning-hub-export-*. // That export is the restore path; this migration is not reversible in any // useful sense, because down() can recreate the shape but never the rows. // // generated_image_links goes with it: it existed only to say which Learning Hub // content an image was published in, and it was the sole reason a generated // image could ever be read by someone who did not make it. Images are now // owner-only, which is both simpler and stricter. exports.up = async function (pgm) { // Order matters only for readability — CASCADE handles the dependencies. pgm.sql('DROP TABLE IF EXISTS generated_image_links CASCADE'); pgm.sql('DROP TABLE IF EXISTS learning_progress CASCADE'); pgm.sql('DROP TABLE IF EXISTS learning_options CASCADE'); pgm.sql('DROP TABLE IF EXISTS learning_questions CASCADE'); pgm.sql('DROP TABLE IF EXISTS learning_content CASCADE'); pgm.sql('DROP TABLE IF EXISTS learning_categories CASCADE'); // The workflow enum on image jobs. Any rows for the retired workflow go with // it: those images belonged to Learning Hub content that no longer exists. pgm.sql("DELETE FROM generated_image_jobs WHERE workflow = 'learning_hub'"); pgm.sql('ALTER TABLE generated_image_jobs DROP CONSTRAINT IF EXISTS generated_image_jobs_workflow_check'); pgm.sql("ALTER TABLE generated_image_jobs ADD CONSTRAINT generated_image_jobs_workflow_check " + "CHECK (workflow = ANY (ARRAY['clinical_assistant'::text, 'my_resources'::text]))"); // Settings that only ever addressed Learning Hub. pgm.sql("DELETE FROM app_settings WHERE key LIKE 'learning_hub.%'"); }; exports.down = async function (pgm) { // The shape, not the content. Restoring the rows means loading the export. pgm.sql('ALTER TABLE generated_image_jobs DROP CONSTRAINT IF EXISTS generated_image_jobs_workflow_check'); pgm.sql("ALTER TABLE generated_image_jobs ADD CONSTRAINT generated_image_jobs_workflow_check " + "CHECK (workflow = ANY (ARRAY['clinical_assistant'::text, 'learning_hub'::text, 'my_resources'::text]))"); };