Files

38 lines
1.5 KiB
PL/PgSQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 用户与组织管理表(系统管理模块补足)
-- 对应方案:系统管理模块 — 用户管理、组织管理
BEGIN;
-- 组织/机构表
CREATE TABLE IF NOT EXISTS organization (
id VARCHAR(64) PRIMARY KEY,
name VARCHAR(256) NOT NULL,
org_node VARCHAR(32), -- MA 码机构节点(如 6101
province VARCHAR(64), -- 所属省份
type VARCHAR(32) NOT NULL, -- regulator/reviewer/cp/operator
status VARCHAR(16) NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_org_type ON organization(type);
CREATE INDEX IF NOT EXISTS idx_org_node ON organization(org_node);
-- 用户表
CREATE TABLE IF NOT EXISTS system_user (
id VARCHAR(64) PRIMARY KEY,
username VARCHAR(128) NOT NULL UNIQUE,
full_name VARCHAR(128),
org_id VARCHAR(64) REFERENCES organization(id),
role VARCHAR(32) NOT NULL, -- regulator/reviewer/cp/operator
api_key VARCHAR(128) NOT NULL UNIQUE,
api_secret VARCHAR(256) NOT NULL,
status VARCHAR(16) NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_user_org ON system_user(org_id);
CREATE INDEX IF NOT EXISTS idx_user_role ON system_user(role);
CREATE INDEX IF NOT EXISTS idx_user_status ON system_user(status);
COMMIT;