Files
MBTI_wang/api/database/add_test_scope.sql
2026-03-17 12:39:38 +08:00

13 lines
703 B
SQL
Raw 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.

-- 为 test_results 新增 testScope 字段,明确区分企业版与个人版
-- personal用户从个人链接/个人页发起的测试(定价走 admin_personal
-- enterprise用户从企业分享链接发起的测试定价走 admin_enterprise
-- 执行前请确认表前缀,默认为 mbti_
ALTER TABLE `mbti_test_results`
ADD COLUMN `testScope` varchar(20) NOT NULL DEFAULT 'personal'
COMMENT '测试来源版本: personal=个人版 enterprise=企业版'
AFTER `enterpriseId`;
-- 将已有记录中 enterpriseId 非空的补标为 enterprise兼容历史数据
UPDATE `mbti_test_results` SET `testScope` = 'enterprise' WHERE `enterpriseId` IS NOT NULL;