drop_drainage_engineering_facility.sql 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. -- ============================================================
  2. -- 拆表收尾:删除旧表 app_user.drainage_engineering_facility
  3. --
  4. -- 前置条件(务必全部满足后再执行):
  5. -- 1. migration_infrastructure_restructure.sql 已执行,新表存在:
  6. -- app_user.drainage_gate_info
  7. -- app_user.drainage_storage_info
  8. -- app_user.pump_station_info
  9. -- 2. 后端新代码已上线:
  10. -- /api/drainage/gate/* → drainage_gate_info
  11. -- /api/drainage/storage/* → drainage_storage_info
  12. -- /api/drainage/pumpStation/* → pump_station_info(station_type=drainage)
  13. -- 3. 前端已切接口,驾驶舱已切 Mapper。
  14. --
  15. -- 注意:
  16. -- · 本脚本【不迁移历史数据】(按本次约束)。旧表 drop 后,
  17. -- 拆表前录入的闸门/调蓄/泵站台账将不再可见,新表从空表开始。
  18. -- · 删除不可逆,执行前请确认旧表无保留价值。
  19. -- ============================================================
  20. -- 前置:结束上一次失败执行遗留的 aborted 事务
  21. ROLLBACK;
  22. BEGIN;
  23. SET search_path TO app_user, public;
  24. -- 核对新表是否就绪(若任一行返回 0,请终止本脚本)
  25. SELECT count(*) AS new_table_count
  26. FROM information_schema.tables
  27. WHERE table_schema = 'app_user'
  28. AND table_name IN ('drainage_gate_info', 'drainage_storage_info', 'pump_station_info');
  29. -- 期望 new_table_count = 3
  30. -- 删除旧表
  31. DROP TABLE IF EXISTS app_user.drainage_engineering_facility;
  32. COMMIT;
  33. -- 核对:旧表应不存在
  34. -- SELECT count(*) FROM information_schema.tables
  35. -- WHERE table_schema='app_user' AND table_name='drainage_engineering_facility';
  36. -- 期望 0