fix(migrations): MariaDB 兼容幂等化 privacy_mode 列与 distributions 种子插入
CI / gate (push) Has been cancelled

This commit is contained in:
QihuAI Design committed 2026-07-20 19:37:57 +08:00
1 parent 71a6403e5b
commit 11b80b90f4
2 files changed
+9 -4

No files matched your search

+8 -3
View File
@@ -84,6 +84,11 @@ CREATE TABLE IF NOT EXISTS usage_reports (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 5. Add privacy_mode to distributions table
ALTER TABLE distributions
ADD COLUMN IF NOT EXISTS privacy_mode ENUM('local', 'cloud', 'hybrid') NOT NULL DEFAULT 'cloud'
COMMENT 'Deployment mode for distribution' AFTER status;
-- MariaDB 11.8 不支持 ADD COLUMN IF NOT EXISTS 语法,改用 information_schema 预检 + 动态 PREPARE 实现幂等
SET @exist_pm := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'aiflow' AND TABLE_NAME = 'distributions' AND COLUMN_NAME = 'privacy_mode');
SET @sql_pm := IF(@exist_pm = 0,
"ALTER TABLE distributions ADD COLUMN privacy_mode ENUM('local', 'cloud', 'hybrid') NOT NULL DEFAULT 'cloud' COMMENT 'Deployment mode for distribution' AFTER status",
'SELECT 1');
PREPARE stmt_pm FROM @sql_pm;
EXECUTE stmt_pm;
DEALLOCATE PREPARE stmt_pm;