Files
digital-psychology/apps/api/migrations/000019_account_lifecycle.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

21 lines
689 B
SQL

-- ECR-013B AccountLifecycle / UserStatus
CREATE TABLE IF NOT EXISTS account_state_transitions (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid NOT NULL REFERENCES users(id),
from_status varchar(32) NOT NULL,
to_status varchar(32) NOT NULL,
admin_id uuid NOT NULL REFERENCES admin_accounts(id),
reason text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_account_state_transitions_user
ON account_state_transitions(user_id, created_at DESC);
INSERT INTO admin_role_permissions(role_id, code)
SELECT r.id, 'admin.users.status.write'
FROM admin_roles r
WHERE r.name = 'super_admin'
ON CONFLICT DO NOTHING;