Files
digital-psychology/apps/api/migrations/000034_ops_banners.up.sql
T
jackyu66gitandCursor b7b0b18802 fix(db): 重编号合并后撞号 migration,并修 admin e2e base
将 015–023 双文件冲突线性化为 015–050;提供已有库 schema_migrations 修复脚本;admin Playwright 对齐 /psy/admin/ 预览路径。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 02:14:52 +08:00

38 lines
1.0 KiB
SQL

-- ECR-024 OpsCMS Banner (read catalog)
CREATE TABLE IF NOT EXISTS ops_banners (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code varchar(64) NOT NULL UNIQUE,
title varchar(128) NOT NULL,
placement varchar(32) NOT NULL
CHECK (placement IN ('home','explore','ask')),
image_url text NULL,
link_path varchar(256) NULL,
sort_order int NOT NULL DEFAULT 0,
active boolean NOT NULL DEFAULT true,
system boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_ops_banners_active ON ops_banners(active);
INSERT INTO ops_banners(code, title, placement, image_url, link_path, sort_order, active, system)
VALUES (
'home_promo',
'首页运营横幅占位',
'home',
NULL,
'/membership',
10,
true,
true
)
ON CONFLICT (code) DO NOTHING;
INSERT INTO admin_role_permissions(role_id, code)
SELECT r.id, 'admin.cms.read'
FROM admin_roles r
WHERE r.name = 'super_admin'
ON CONFLICT DO NOTHING;