fix notify fail
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
ALTER TABLE `notify`
|
||||
CHANGE COLUMN `biz_reminded_id` `biz_reminded_key` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '业务提醒查重键',
|
||||
ADD COLUMN `biz_reminded_active_key` TINYINT(1) GENERATED ALWAYS AS (IF(`deleted_at` IS NULL, 1, NULL)) STORED COMMENT '未删除查重键' INVISIBLE AFTER `deleted_at`,
|
||||
DROP INDEX `idx_biz_reminded_created`,
|
||||
ADD INDEX `idx_biz_reminded_key_created`(`biz_type` ASC, `biz_reminded_type` ASC, `biz_reminded_key` ASC, `created_at` ASC) USING BTREE;
|
||||
|
||||
UPDATE `notify` target
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY biz_type, biz_reminded_type, biz_reminded_key
|
||||
ORDER BY created_at DESC, id DESC
|
||||
) AS rn
|
||||
FROM `notify`
|
||||
WHERE deleted_at IS NULL
|
||||
AND biz_type IS NOT NULL
|
||||
AND biz_reminded_type IS NOT NULL
|
||||
AND biz_reminded_key IS NOT NULL
|
||||
) duplicate ON duplicate.id = target.id
|
||||
SET target.deleted_at = UNIX_TIMESTAMP() * 1000
|
||||
WHERE duplicate.rn > 1;
|
||||
|
||||
ALTER TABLE `notify`
|
||||
ADD UNIQUE INDEX `uk_biz_reminded_key_active`(`biz_type` ASC, `biz_reminded_type` ASC, `biz_reminded_key` ASC, `biz_reminded_active_key` ASC) USING BTREE;
|
||||
Reference in New Issue
Block a user