Files
martial-master/database/martial-db/cleanup_test_data.sql
宅房 7aa6545cbb
All checks were successful
continuous-integration/drone/push Build is passing
fix bugs
2025-12-12 05:13:10 +08:00

86 lines
2.9 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ================================================================
-- 清理所有测试数据脚本
-- 用途:清空所有业务数据,保留表结构
-- 日期2025-12-06
-- 警告:此脚本会删除所有业务数据,请谨慎使用!
-- ================================================================
-- 设置外键检查为0允许删除有外键关联的数据
SET FOREIGN_KEY_CHECKS = 0;
-- 1. 清空赛事相关表
-- ================================================================
TRUNCATE TABLE `martial_competition`;
TRUNCATE TABLE `martial_banner`;
-- 2. 清空项目相关表
-- ================================================================
TRUNCATE TABLE `martial_project`;
-- 3. 清空场地相关表
-- ================================================================
TRUNCATE TABLE `martial_venue`;
-- 4. 清空参赛者/运动员相关表
-- ================================================================
TRUNCATE TABLE `martial_athlete`;
TRUNCATE TABLE `martial_participant`;
-- 5. 清空报名订单相关表
-- ================================================================
TRUNCATE TABLE `martial_registration_order`;
-- 6. 清空裁判相关表
-- ================================================================
TRUNCATE TABLE `martial_referee`;
-- 7. 清空成绩相关表
-- ================================================================
TRUNCATE TABLE `martial_score`;
-- 8. 清空赛程编排相关表(如果存在)
-- ================================================================
-- TRUNCATE TABLE `martial_schedule`;
-- TRUNCATE TABLE `martial_schedule_detail`;
-- 9. 清空信息发布相关表
-- ================================================================
TRUNCATE TABLE `martial_info_publish`;
-- 重新启用外键检查
SET FOREIGN_KEY_CHECKS = 1;
-- ================================================================
-- 验证清理结果
-- ================================================================
SELECT
'赛事数据' AS ,
COUNT(*) AS
FROM martial_competition
UNION ALL
SELECT '项目数据', COUNT(*) FROM martial_project
UNION ALL
SELECT '场地数据', COUNT(*) FROM martial_venue
UNION ALL
SELECT '参赛者数据', COUNT(*) FROM martial_athlete
UNION ALL
SELECT '报名订单数据', COUNT(*) FROM martial_registration_order
UNION ALL
SELECT '裁判数据', COUNT(*) FROM martial_referee
UNION ALL
SELECT '成绩数据', COUNT(*) FROM martial_score
UNION ALL
SELECT '信息发布数据', COUNT(*) FROM martial_info_publish;
-- ================================================================
-- 清理完成
-- ================================================================
-- 所有业务数据已清空,表结构保留
-- 您现在可以重新测试完整的业务流程:
-- 1. 创建赛事
-- 2. 配置场地
-- 3. 创建项目
-- 4. 添加参赛者
-- 5. 进行编排
-- ================================================================