chore: 首次提交 - 关联 GitHub fnvtk/MBTI_wang

Made-with: Cursor
This commit is contained in:
卡若
2026-03-17 12:39:38 +08:00
commit eb510304c0
259 changed files with 60464 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
-- 迁移system_config 新增 enterprise_id 列
-- enterprise_id = 0 表示全局/超管配置,> 0 表示对应企业的配置
-- 执行前请先备份数据库
-- 1. 新增 enterprise_id 列(默认 0 = 全局)
ALTER TABLE `mbti_system_config`
ADD COLUMN `enterprise_id` INT NOT NULL DEFAULT 0 COMMENT '企业ID0=全局/个人版' AFTER `key`;
-- 2. 删除旧的单字段唯一索引,改为 (key, enterprise_id) 联合唯一索引
ALTER TABLE `mbti_system_config` DROP INDEX `idx_key`;
ALTER TABLE `mbti_system_config` ADD UNIQUE INDEX `idx_key_eid` (`key`, `enterprise_id`);
-- 3. 迁移旧数据poster_config_eid_N → key='poster_config', enterprise_id=N
UPDATE `mbti_system_config`
SET `enterprise_id` = CAST(SUBSTRING_INDEX(`key`, '_eid_', -1) AS UNSIGNED),
`key` = 'poster_config'
WHERE `key` LIKE 'poster_config_eid_%';
-- 4. 迁移旧数据distribution_enterprise_N → key='distribution', enterprise_id=N
UPDATE `mbti_system_config`
SET `enterprise_id` = CAST(SUBSTRING_INDEX(`key`, 'distribution_enterprise_', -1) AS UNSIGNED),
`key` = 'distribution'
WHERE `key` LIKE 'distribution_enterprise_%';
-- 5. 迁移旧数据distribution_personal → key='distribution', enterprise_id=0
UPDATE `mbti_system_config`
SET `key` = 'distribution'
WHERE `key` = 'distribution_personal';
-- 6. 迁移旧数据miniprogram_config_eid_N → key='text_config', enterprise_id=N
UPDATE `mbti_system_config`
SET `enterprise_id` = CAST(SUBSTRING_INDEX(`key`, '_eid_', -1) AS UNSIGNED),
`key` = 'text_config'
WHERE `key` LIKE 'miniprogram_config_eid_%';