hi-server/initialize/migrate/database/02118_traffic_log_idx.up.sql
shanshanzhong 1d81df6664
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
add:添加短链接服务
2026-01-24 00:32:08 -08:00

16 lines
406 B
SQL

SET @index_exists = (
SELECT COUNT(1)
FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'traffic_log'
AND INDEX_NAME = 'idx_timestamp'
);
SET @sql = IF(@index_exists = 0,
'CREATE INDEX idx_timestamp ON traffic_log (timestamp)',
'SELECT ''Index already exists'' AS message');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;