CREATE TABLE public.users (
    id bigint PRIMARY KEY ,
    create_time timestamp NOT NULL ,
    last_update_time timestamp NOT NULL,
    name text NOT NULL ,
    account text NOT NULL ,
    passwd text NOT NULL
);

COMMENT ON TABLE public.users IS '基础用户表，记录用户在系统内的昵称';
COMMENT ON COLUMN public.users.id IS '用户ID';
COMMENT ON COLUMN public.users.name IS '用户在系统内的名称';
COMMENT ON COLUMN public.users.account IS '用户登录凭证';
COMMENT ON COLUMN public.users.passwd IS '用户登录密钥';

INSERT INTO public.users VALUES (0, transaction_timestamp(), transaction_timestamp(), '绯红先知', 'admin', 'fh123456');

CREATE TABLE public.system (
    id bigint PRIMARY KEY ,
    create_time timestamp NOT NULL ,
    last_update_time timestamp NOT NULL,
    name text NOT NULL ,
    domain text NOT NULL
);

COMMENT ON TABLE public.system IS '系统表，记录当前认证服务所对接的系统';
COMMENT ON COLUMN public.system.id IS '系统 ID';
COMMENT ON COLUMN public.system.name IS '系统名称';

INSERT INTO public.system VALUES (0, transaction_timestamp(), transaction_timestamp(), '绯红守卫', 'www.ciallo.pub');

CREATE TABLE public.system_expand_info (
    user_id bigint NOT NULL ,
    system_id bigint NOT NULL ,
    info jsonb NOT NULL ,
    PRIMARY KEY (user_id, system_id)
);

COMMENT ON TABLE public.system_expand_info IS '系统拓展表，记录用户在某个系统下的额外信息';
COMMENT ON COLUMN public.user.id IS '拓展表ID';
COMMENT ON COLUMN public.user.name IS '用户在系统内的名称';
COMMENT ON COLUMN public.user.account IS '用户登录凭证';
COMMENT ON COLUMN public.user.passwd IS '用户登录密钥';