Archived
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kAzS35kMnZNt4YGgJXtfw
28 lines
1.2 KiB
SQL
28 lines
1.2 KiB
SQL
-- 身份归统一鉴权中心(ADR-012):会话表与岗位授权表退役;员工 id 从此就是 Keycloak 的 sub。
|
|
--
|
|
-- 从前(ADR-010)是自建账号口令 + 服务端会话表 + 岗位授权(客体三类 × 动作三种)。
|
|
-- 现在:后端只验 Bearer JWT;权限只到「端」(design / ops / workbench),
|
|
-- 角色 → 端是运营中心可改的一张表;名册从 Keycloak 同步、岗位本地指派。
|
|
drop table if exists sys.session;
|
|
drop table if exists sys.position_grant;
|
|
|
|
alter table sys.staff
|
|
drop column if exists password_hash,
|
|
add column if not exists email text,
|
|
add column if not exists roles jsonb not null default '[]'::jsonb,
|
|
add column if not exists last_seen_at timestamptz,
|
|
add column if not exists synced_at timestamptz;
|
|
|
|
create table if not exists sys.role_access (
|
|
role text primary key,
|
|
design boolean not null default false,
|
|
ops boolean not null default false,
|
|
workbench boolean not null default false,
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
|
|
-- 种子人不是 Keycloak 的人:id 不是 sub,账号还会与 Keycloak 用户名撞唯一索引 —— 清掉。
|
|
-- 他们名下的运行数据由 `reset-runs` 清(迁移不碰运行表)。
|
|
delete from sys.work_group;
|
|
delete from sys.staff;
|