Initial commit: 风影 OA 全栈源码(API/Web/Flutter/IM)
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
\set ON_ERROR_STOP on
|
||||
|
||||
BEGIN;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
orphan_count integer;
|
||||
mirrored_count integer;
|
||||
BEGIN
|
||||
SELECT count(*) INTO orphan_count
|
||||
FROM "FileAsset" file
|
||||
WHERE file."bizType" LIKE 'CONTRACT%'
|
||||
AND NOT EXISTS (SELECT 1 FROM "Contract" contract WHERE contract.id = file."bizId");
|
||||
|
||||
SELECT count(*) INTO mirrored_count
|
||||
FROM "FileAsset" orphan
|
||||
WHERE orphan."bizType" LIKE 'CONTRACT%'
|
||||
AND NOT EXISTS (SELECT 1 FROM "Contract" contract WHERE contract.id = orphan."bizId")
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM "FileAsset" current_file
|
||||
JOIN "Contract" current_contract ON current_contract.id = current_file."bizId"
|
||||
WHERE current_file."bizType" = orphan."bizType"
|
||||
AND current_file."fileName" = orphan."fileName"
|
||||
AND current_file.size = orphan.size
|
||||
);
|
||||
|
||||
IF orphan_count <> 29 OR mirrored_count <> orphan_count THEN
|
||||
RAISE EXCEPTION 'Unexpected orphan contract files: orphan %, mirrored %',
|
||||
orphan_count, mirrored_count;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DELETE FROM "FileAsset" file
|
||||
WHERE file."bizType" LIKE 'CONTRACT%'
|
||||
AND NOT EXISTS (SELECT 1 FROM "Contract" contract WHERE contract.id = file."bizId");
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user