Files
zhuiguang-ai/prisma/migrations/20260525000000_expand_user_levels/migration.sql
T

17 lines
859 B
SQL

-- AlterEnum: Map old enum values to new 20-level system
-- Step 1: Change the column to VARCHAR temporarily
ALTER TABLE `users` MODIFY COLUMN `level` VARCHAR(20) NOT NULL DEFAULT 'LV01';
-- Step 2: Map old enum values to new ones
UPDATE `users` SET `level` = 'LV01' WHERE `level` = 'BRONZE';
UPDATE `users` SET `level` = 'LV03' WHERE `level` = 'SILVER';
UPDATE `users` SET `level` = 'LV06' WHERE `level` = 'GOLD';
UPDATE `users` SET `level` = 'LV10' WHERE `level` = 'PLATINUM';
-- AlterTable: Add bio field
ALTER TABLE `users` ADD COLUMN `bio` TEXT NULL;
-- AlterTable: Add parentId for ForumCategory hierarchy
ALTER TABLE `forum_categories` ADD COLUMN `parent_id` INT NULL;
ALTER TABLE `forum_categories` ADD CONSTRAINT `forum_categories_parent_id_fkey` FOREIGN KEY (`parent_id`) REFERENCES `forum_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;