Merge branch 'refactor/backend-architecture' into development

This commit is contained in:
yangshilin
2026-03-18 17:18:23 +08:00
parent 2070a03d35
commit 48b70e1350
266 changed files with 12386 additions and 9690 deletions

View File

@@ -0,0 +1,26 @@
-- 为 users 表添加订阅相关列subscription_type, subscription_expires_at
-- 若列已存在则跳过,可重复执行。
-- 执行方式: psql -U <user> -d <database> -f api/migrations/add_users_subscription_columns.sql
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'users' AND column_name = 'subscription_type'
) THEN
ALTER TABLE users ADD COLUMN subscription_type VARCHAR DEFAULT 'free';
RAISE NOTICE '已添加 users.subscription_type 列';
ELSE
RAISE NOTICE 'users.subscription_type 列已存在,跳过';
END IF;
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'users' AND column_name = 'subscription_expires_at'
) THEN
ALTER TABLE users ADD COLUMN subscription_expires_at TIMESTAMP WITH TIME ZONE DEFAULT NULL;
RAISE NOTICE '已添加 users.subscription_expires_at 列';
ELSE
RAISE NOTICE 'users.subscription_expires_at 列已存在,跳过';
END IF;
END $$;