统一仪表盘、AI 回复、卡密、扫码和通知等前后端行为,补齐并发与失败恢复测试。新增 MySQL 8.4、PostgreSQL 17 持久化 Docker 功能测试和 SQLite 脱敏播种工具。
31 lines
1.1 KiB
SQL
31 lines
1.1 KiB
SQL
-- +goose Up
|
|
-- MySQL may use the composite scope index to satisfy the cookie_id foreign key.
|
|
-- Keep a dedicated leading-column index so the scope index remains removable
|
|
-- during a Goose rollback.
|
|
DROP PROCEDURE IF EXISTS add_ai_conversations_cookie_index;
|
|
-- +goose StatementBegin
|
|
CREATE PROCEDURE add_ai_conversations_cookie_index()
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM information_schema.STATISTICS
|
|
WHERE TABLE_SCHEMA = DATABASE()
|
|
AND TABLE_NAME = 'ai_conversations'
|
|
AND INDEX_NAME = 'idx_ai_conversations_cookie_id'
|
|
) THEN
|
|
CREATE INDEX idx_ai_conversations_cookie_id
|
|
ON ai_conversations(cookie_id);
|
|
END IF;
|
|
END;
|
|
-- +goose StatementEnd
|
|
CALL add_ai_conversations_cookie_index();
|
|
DROP PROCEDURE add_ai_conversations_cookie_index;
|
|
|
|
CREATE INDEX idx_ai_conversations_scope
|
|
ON ai_conversations(cookie_id, chat_id, item_id, id);
|
|
|
|
-- +goose Down
|
|
DROP INDEX idx_ai_conversations_scope ON ai_conversations;
|
|
-- Intentionally retain idx_ai_conversations_cookie_id: the cookie_id foreign key
|
|
-- requires an index even after this feature migration is rolled back.
|