暂存一下,防止丢失
This commit is contained in:
19
migrations/000168_create_notification.down.sql
Normal file
19
migrations/000168_create_notification.down.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
BEGIN;
|
||||
|
||||
-- 在同一事务取得排他锁后检查并删除,避免检查与删表之间写入新通知事实。
|
||||
DO $$
|
||||
BEGIN
|
||||
IF to_regclass('tb_notification') IS NULL THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
LOCK TABLE tb_notification IN ACCESS EXCLUSIVE MODE;
|
||||
IF EXISTS (SELECT 1 FROM tb_notification LIMIT 1) THEN
|
||||
RAISE EXCEPTION 'tb_notification 已存在通知事实,禁止删表回滚,请停止生产者后向前修复';
|
||||
END IF;
|
||||
|
||||
DROP TABLE tb_notification;
|
||||
END
|
||||
$$;
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user