Activiti刪除外來鍵

vickcan發表於2024-07-24

Activiti相關資料庫表定義了很多外來鍵,在自定義駁回、收回操作時,很容易出現外來鍵引起的操作失敗,親測有兩種方法解決:

1、臨時關閉外來鍵約束

1.1 操作開始前執行SET FOREIGN_KEY_CHECKS=0;關閉外來鍵約束
1.2 操作完成後執行SET FOREIGN_KEY_CHECKS=1;開啟外來鍵約束

2、刪除Activiti相關表外來鍵
ALTER TABLE ACT_GE_BYTEARRAY DROP FOREIGN KEY `ACT_FK_BYTEARR_DEPL`;
ALTER TABLE ACT_PROCDEF_INFO DROP FOREIGN KEY `ACT_FK_INFO_JSON_BA`;
ALTER TABLE ACT_PROCDEF_INFO DROP FOREIGN KEY `ACT_FK_INFO_PROCDEF`;
ALTER TABLE ACT_RE_MODEL DROP FOREIGN KEY `ACT_FK_MODEL_DEPLOYMENT`;
ALTER TABLE ACT_RE_MODEL DROP FOREIGN KEY `ACT_FK_MODEL_SOURCE`;
ALTER TABLE ACT_RE_MODEL DROP FOREIGN KEY `ACT_FK_MODEL_SOURCE_EXTRA`;
ALTER TABLE ACT_RU_DEADLETTER_JOB DROP FOREIGN KEY `ACT_FK_DEADLETTER_JOB_EXCEPTION`;
ALTER TABLE ACT_RU_DEADLETTER_JOB DROP FOREIGN KEY `ACT_FK_DEADLETTER_JOB_EXECUTION`;
ALTER TABLE ACT_RU_DEADLETTER_JOB DROP FOREIGN KEY `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE`;
ALTER TABLE ACT_RU_DEADLETTER_JOB DROP FOREIGN KEY `ACT_FK_DEADLETTER_JOB_PROC_DEF`;
ALTER TABLE ACT_RU_EVENT_SUBSCR DROP FOREIGN KEY `ACT_FK_EVENT_EXEC`;
ALTER TABLE ACT_RU_EXECUTION DROP FOREIGN KEY `ACT_FK_EXE_PARENT`;
ALTER TABLE ACT_RU_EXECUTION DROP FOREIGN KEY `ACT_FK_EXE_PROCDEF`;
ALTER TABLE ACT_RU_EXECUTION DROP FOREIGN KEY `ACT_FK_EXE_PROCINST`;
ALTER TABLE ACT_RU_EXECUTION DROP FOREIGN KEY `ACT_FK_EXE_SUPER`;
ALTER TABLE ACT_RU_IDENTITYLINK DROP FOREIGN KEY `ACT_FK_ATHRZ_PROCEDEF`;
ALTER TABLE ACT_RU_IDENTITYLINK DROP FOREIGN KEY `ACT_FK_IDL_PROCINST`;
ALTER TABLE ACT_RU_IDENTITYLINK DROP FOREIGN KEY `ACT_FK_TSKASS_TASK`;
ALTER TABLE ACT_RU_JOB DROP FOREIGN KEY `ACT_FK_JOB_EXCEPTION`;
ALTER TABLE ACT_RU_JOB DROP FOREIGN KEY `ACT_FK_JOB_EXECUTION`;
ALTER TABLE ACT_RU_JOB DROP FOREIGN KEY `ACT_FK_JOB_PROCESS_INSTANCE`;
ALTER TABLE ACT_RU_JOB DROP FOREIGN KEY `ACT_FK_JOB_PROC_DEF`;
ALTER TABLE ACT_RU_SUSPENDED_JOB DROP FOREIGN KEY `ACT_FK_SUSPENDED_JOB_EXCEPTION`;
ALTER TABLE ACT_RU_SUSPENDED_JOB DROP FOREIGN KEY `ACT_FK_SUSPENDED_JOB_EXECUTION`;
ALTER TABLE ACT_RU_SUSPENDED_JOB DROP FOREIGN KEY `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE`;
ALTER TABLE ACT_RU_SUSPENDED_JOB DROP FOREIGN KEY `ACT_FK_SUSPENDED_JOB_PROC_DEF`;
ALTER TABLE ACT_RU_TASK DROP FOREIGN KEY `ACT_FK_TASK_EXE`;
ALTER TABLE ACT_RU_TASK DROP FOREIGN KEY `ACT_FK_TASK_PROCDEF`;
ALTER TABLE ACT_RU_TASK DROP FOREIGN KEY `ACT_FK_TASK_PROCINST`;
ALTER TABLE ACT_RU_TIMER_JOB DROP FOREIGN KEY `ACT_FK_TIMER_JOB_EXCEPTION`;
ALTER TABLE ACT_RU_TIMER_JOB DROP FOREIGN KEY `ACT_FK_TIMER_JOB_EXECUTION`;
ALTER TABLE ACT_RU_TIMER_JOB DROP FOREIGN KEY `ACT_FK_TIMER_JOB_PROCESS_INSTANCE`;
ALTER TABLE ACT_RU_TIMER_JOB DROP FOREIGN KEY `ACT_FK_TIMER_JOB_PROC_DEF`;
ALTER TABLE ACT_RU_VARIABLE DROP FOREIGN KEY `ACT_FK_VAR_BYTEARRAY`;
ALTER TABLE ACT_RU_VARIABLE DROP FOREIGN KEY `ACT_FK_VAR_EXE`;
ALTER TABLE ACT_RU_VARIABLE DROP FOREIGN KEY `ACT_FK_VAR_PROCINST`;

相關文章