-- ============================================= -- Education 模块 — Ticket #8 迁移回滚 (PostgreSQL) -- 004-education-submit-report-rollback.sql -- ============================================= -- -- WARNING: This file contains NO executable SQL. -- Destructive rollback requires manual operator verification. -- -- Manual rollback procedure (operator must execute): -- 1. Verify no other tables depend on these tables: -- SELECT -- tc.table_name, -- kcu.column_name, -- ccu.table_name AS referenced_table_name -- FROM information_schema.table_constraints AS tc -- JOIN information_schema.key_column_usage AS kcu -- ON tc.constraint_name = kcu.constraint_name -- JOIN information_schema.constraint_column_usage AS ccu -- ON ccu.constraint_name = tc.constraint_name -- WHERE tc.constraint_type = 'FOREIGN KEY' -- AND ccu.table_name IN ('education_submit_idempotency', -- 'education_practice_report', 'education_practice_report_detail') -- AND ccu.table_catalog = current_database(); -- Result MUST be empty before proceeding. -- -- 2. Verify columns are not referenced by application code: -- Search codebase for 'correct_answer' / 'explanation' references in -- education_practice_question to confirm no other consumers. -- -- 3. Verify the tables contain only data from this migration: -- SELECT COUNT(*) AS idempotency_count FROM education_submit_idempotency; -- SELECT COUNT(*) AS report_count FROM education_practice_report; -- SELECT COUNT(*) AS detail_count FROM education_practice_report_detail; -- Operator must confirm these counts are acceptable to destroy. -- -- 4. After verification, execute: -- DROP TABLE IF EXISTS education_practice_report_detail; -- DROP TABLE IF EXISTS education_practice_report; -- DROP TABLE IF EXISTS education_submit_idempotency; -- ALTER TABLE education_practice_question -- DROP COLUMN correct_answer, -- DROP COLUMN explanation; -- -- DO NOT uncomment or execute the lines below without operator verification. -- -- DROP TABLE IF EXISTS education_practice_report_detail; -- -- DROP TABLE IF EXISTS education_practice_report; -- -- DROP TABLE IF EXISTS education_submit_idempotency; -- -- ALTER TABLE education_practice_question -- -- DROP COLUMN correct_answer, -- -- DROP COLUMN explanation;