152 lines
13 KiB
SQL
152 lines
13 KiB
SQL
-- 项目协作已停用存储清理;备份并审计运行时代码、外键和数据库对象后执行。
|
|
-- 本脚本只删除17张旧pm_*表、旧布局表和旧升级标记,不删除现行项目或研发业务。
|
|
SET NAMES utf8mb4;
|
|
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_attachment` DROP FOREIGN KEY `pm_attachment_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_attachment' AND constraint_name='pm_attachment_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_collab_graph_layout` DROP FOREIGN KEY `pm_collab_graph_layout_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_collab_graph_layout' AND constraint_name='pm_collab_graph_layout_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_collab_graph_layout` DROP FOREIGN KEY `pm_collab_graph_layout_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_collab_graph_layout' AND constraint_name='pm_collab_graph_layout_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_comment` DROP FOREIGN KEY `pm_comment_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_comment' AND constraint_name='pm_comment_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_dependency_condition` DROP FOREIGN KEY `pm_dependency_condition_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_dependency_condition' AND constraint_name='pm_dependency_condition_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_dependency_condition` DROP FOREIGN KEY `pm_dependency_condition_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_dependency_condition' AND constraint_name='pm_dependency_condition_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_dependency_condition` DROP FOREIGN KEY `pm_dependency_condition_ibfk_3`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_dependency_condition' AND constraint_name='pm_dependency_condition_ibfk_3');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_flow_node` DROP FOREIGN KEY `pm_flow_node_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_flow_node' AND constraint_name='pm_flow_node_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_flow` DROP FOREIGN KEY `pm_flow_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_flow' AND constraint_name='pm_flow_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_graph_layout` DROP FOREIGN KEY `pm_graph_layout_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_graph_layout' AND constraint_name='pm_graph_layout_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_graph_layout` DROP FOREIGN KEY `pm_graph_layout_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_graph_layout' AND constraint_name='pm_graph_layout_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_history` DROP FOREIGN KEY `pm_history_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_history' AND constraint_name='pm_history_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_node_instance` DROP FOREIGN KEY `pm_node_instance_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_node_instance' AND constraint_name='pm_node_instance_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_node_state` DROP FOREIGN KEY `pm_node_state_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_node_state' AND constraint_name='pm_node_state_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_node_task_prerequisite` DROP FOREIGN KEY `pm_node_task_prerequisite_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_node_task_prerequisite' AND constraint_name='pm_node_task_prerequisite_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_node_task_prerequisite` DROP FOREIGN KEY `pm_node_task_prerequisite_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_node_task_prerequisite' AND constraint_name='pm_node_task_prerequisite_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_notification` DROP FOREIGN KEY `pm_notification_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_notification' AND constraint_name='pm_notification_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_notification` DROP FOREIGN KEY `pm_notification_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_notification' AND constraint_name='pm_notification_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_outbox` DROP FOREIGN KEY `pm_outbox_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_outbox' AND constraint_name='pm_outbox_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_config` DROP FOREIGN KEY `fk_pm_project_creator`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_config' AND constraint_name='fk_pm_project_creator');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_config` DROP FOREIGN KEY `pm_project_config_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_config' AND constraint_name='pm_project_config_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_config` DROP FOREIGN KEY `pm_project_config_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_config' AND constraint_name='pm_project_config_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_lock` DROP FOREIGN KEY `pm_project_lock_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_lock' AND constraint_name='pm_project_lock_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_stage` DROP FOREIGN KEY `pm_project_stage_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_stage' AND constraint_name='pm_project_stage_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_stage` DROP FOREIGN KEY `pm_project_stage_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_stage' AND constraint_name='pm_project_stage_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_project_stage` DROP FOREIGN KEY `pm_project_stage_ibfk_3`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_project_stage' AND constraint_name='pm_project_stage_ibfk_3');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_space` DROP FOREIGN KEY `pm_space_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_space' AND constraint_name='pm_space_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_work_item` DROP FOREIGN KEY `fk_pm_item_stage`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_work_item' AND constraint_name='fk_pm_item_stage');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_work_item` DROP FOREIGN KEY `fk_pm_parent`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_work_item' AND constraint_name='fk_pm_parent');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_work_item` DROP FOREIGN KEY `pm_work_item_ibfk_1`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_work_item' AND constraint_name='pm_work_item_ibfk_1');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_work_item` DROP FOREIGN KEY `pm_work_item_ibfk_2`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_work_item' AND constraint_name='pm_work_item_ibfk_2');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
SET @pm_cleanup_sql=(SELECT IF(COUNT(*)>0,'ALTER TABLE `pm_work_item` DROP FOREIGN KEY `pm_work_item_ibfk_3`','SELECT 1') FROM information_schema.table_constraints WHERE constraint_schema=DATABASE() AND table_name='pm_work_item' AND constraint_name='pm_work_item_ibfk_3');
|
|
PREPARE pm_cleanup_stmt FROM @pm_cleanup_sql;
|
|
EXECUTE pm_cleanup_stmt;
|
|
DEALLOCATE PREPARE pm_cleanup_stmt;
|
|
DROP TABLE IF EXISTS `pm_attachment`;
|
|
DROP TABLE IF EXISTS `pm_comment`;
|
|
DROP TABLE IF EXISTS `pm_dependency_condition`;
|
|
DROP TABLE IF EXISTS `pm_flow`;
|
|
DROP TABLE IF EXISTS `pm_flow_node`;
|
|
DROP TABLE IF EXISTS `pm_graph_layout`;
|
|
DROP TABLE IF EXISTS `pm_history`;
|
|
DROP TABLE IF EXISTS `pm_node_instance`;
|
|
DROP TABLE IF EXISTS `pm_node_state`;
|
|
DROP TABLE IF EXISTS `pm_node_task_prerequisite`;
|
|
DROP TABLE IF EXISTS `pm_notification`;
|
|
DROP TABLE IF EXISTS `pm_outbox`;
|
|
DROP TABLE IF EXISTS `pm_project_config`;
|
|
DROP TABLE IF EXISTS `pm_project_lock`;
|
|
DROP TABLE IF EXISTS `pm_project_stage`;
|
|
DROP TABLE IF EXISTS `pm_space`;
|
|
DROP TABLE IF EXISTS `pm_work_item`;
|
|
DROP TABLE IF EXISTS `pm_collab_graph_layout`;
|
|
DROP TABLE IF EXISTS `pm_collab_schema_migration`;
|