Files
MBTI_wang/api/database/migrations/run_delivery_dedup.php
Ghost cf835ea585 feat: 管理端推送 Webhook 配置与出站推送链路接入
1、修复了管理端设置在推送开关/配置项上的联动与保存问题。

2、新增 OutboundPushHookService、PushHook/InternalPushHook 接口、前端 PushHookConfigPanel 与小程序 pushHook 工具。

3、优化 Analyze/Auth/Test/支付回调触发路径,补充去重迁移脚本与实施文档。

Made-with: Cursor
2026-04-15 15:07:36 +08:00

39 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 创建 delivery_dedup 去重表OutboundPushHook / FeishuLeadWebhook 等共用,按 scene 区分业务)
*
* 在 api 目录下执行:
* php database/migrations/run_delivery_dedup.php
*/
declare(strict_types=1);
chdir(__DIR__ . '/../..');
require __DIR__ . '/../../vendor/autoload.php';
$app = new think\App();
$app->initialize();
$prefix = (string) config('database.connections.mysql.prefix', '');
$table = $prefix . 'delivery_dedup';
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS `{$table}` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`scene` varchar(32) NOT NULL COMMENT '场景feishu_lead=飞书获客outbound_hook=通用出站 Webhook扩展时新增枚举值',
`dedupKey` varchar(255) NOT NULL COMMENT '该场景下幂等键(与 scene 联合唯一);出站为 _dedupKey 原值',
`createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_scene_dedup` (`scene`, `dedupKey`),
KEY `idx_scene` (`scene`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='多业务推送幂等去重(飞书获客、出站 Webhook 等共用)'
SQL;
try {
\think\facade\Db::execute($sql);
fwrite(STDOUT, "OK: 表 `{$table}` 已就绪\n");
} catch (\Throwable $e) {
fwrite(STDERR, 'FAIL: ' . $e->getMessage() . "\n");
exit(1);
}