- 新增api/payment/支付服务(微信、支付宝) - 新增api/routers/payment.py支付路由 - 更新database/models.py支付相关模型 - 新增数据库迁移文件(订单表、用户订阅字段) - 更新main.py、requirements.txt、.env.production Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
1.1 KiB
SQL
27 lines
1.1 KiB
SQL
-- 为 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 $$;
|