mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-14 19:04:00 +08:00
Add support for snowflake ID primary key (#670)
* fix: 修复PostgreSQL SQL语法错误,将反引号替换为双引号 * feat: 新增雪花算法ID实现 * 优化雪花算法和主键类型 * 修复错误引用 * 添加雪花详情链接 * feat: add snowflake ID parser method * 修复独立执行异常 * 更新系统时间错误类
This commit is contained in:
@ -1,12 +1,59 @@
|
||||
create table sys_data_rule
|
||||
(
|
||||
id bigserial,
|
||||
name varchar(500) not null,
|
||||
model varchar(50) not null,
|
||||
"column" varchar(20) not null,
|
||||
operator integer not null,
|
||||
expression integer not null,
|
||||
value varchar(255) not null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_data_rule is '数据规则表';
|
||||
|
||||
comment on column sys_data_rule.id is '主键 ID';
|
||||
|
||||
comment on column sys_data_rule.name is '名称';
|
||||
|
||||
comment on column sys_data_rule.model is 'SQLA 模型名,对应 DATA_PERMISSION_MODELS 键名';
|
||||
|
||||
comment on column sys_data_rule."column" is '模型字段名';
|
||||
|
||||
comment on column sys_data_rule.operator is '运算符(0:and、1:or)';
|
||||
|
||||
comment on column sys_data_rule.expression is '表达式(0:==、1:!=、2:>、3:>=、4:<、5:<=、6:in、7:not_in)';
|
||||
|
||||
comment on column sys_data_rule.value is '规则值';
|
||||
|
||||
comment on column sys_data_rule.created_time is '创建时间';
|
||||
|
||||
comment on column sys_data_rule.updated_time is '更新时间';
|
||||
|
||||
alter table sys_data_rule
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_data_rule_pkey
|
||||
on sys_data_rule (id);
|
||||
|
||||
create unique index sys_data_rule_name_key
|
||||
on sys_data_rule (name);
|
||||
|
||||
create unique index ix_sys_data_rule_id
|
||||
on sys_data_rule (id);
|
||||
|
||||
create table sys_data_scope
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
name varchar(50) not null
|
||||
unique,
|
||||
id bigserial,
|
||||
name varchar(50) not null,
|
||||
status integer not null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_data_scope is '数据范围表';
|
||||
@ -21,13 +68,21 @@ comment on column sys_data_scope.created_time is '创建时间';
|
||||
|
||||
comment on column sys_data_scope.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_data_scope_id
|
||||
alter table sys_data_scope
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_data_scope_pkey
|
||||
on sys_data_scope (id);
|
||||
|
||||
create unique index sys_data_scope_name_key
|
||||
on sys_data_scope (name);
|
||||
|
||||
create unique index ix_sys_data_scope_id
|
||||
on sys_data_scope (id);
|
||||
|
||||
create table sys_dept
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
name varchar(50) not null,
|
||||
sort integer not null,
|
||||
leader varchar(20),
|
||||
@ -35,11 +90,12 @@ create table sys_dept
|
||||
email varchar(50),
|
||||
status integer not null,
|
||||
del_flag integer not null,
|
||||
parent_id integer
|
||||
references sys_dept
|
||||
on delete set null,
|
||||
parent_id bigint
|
||||
references ??? ()
|
||||
on delete set null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_dept is '部门表';
|
||||
@ -66,7 +122,13 @@ comment on column sys_dept.created_time is '创建时间';
|
||||
|
||||
comment on column sys_dept.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_dept_id
|
||||
alter table sys_dept
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_dept_pkey
|
||||
on sys_dept (id);
|
||||
|
||||
create unique index ix_sys_dept_id
|
||||
on sys_dept (id);
|
||||
|
||||
create index ix_sys_dept_parent_id
|
||||
@ -74,8 +136,7 @@ create index ix_sys_dept_parent_id
|
||||
|
||||
create table sys_login_log
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigint not null,
|
||||
user_uuid varchar(50) not null,
|
||||
username varchar(20) not null,
|
||||
status integer not null,
|
||||
@ -89,12 +150,13 @@ create table sys_login_log
|
||||
device varchar(50),
|
||||
msg text not null,
|
||||
login_time timestamp with time zone not null,
|
||||
created_time timestamp with time zone not null
|
||||
created_time timestamp with time zone not null,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_login_log is '登录日志表';
|
||||
|
||||
comment on column sys_login_log.id is '主键 ID';
|
||||
comment on column sys_login_log.id is '雪花算法主键 ID';
|
||||
|
||||
comment on column sys_login_log.user_uuid is '用户UUID';
|
||||
|
||||
@ -124,16 +186,21 @@ comment on column sys_login_log.login_time is '登录时间';
|
||||
|
||||
comment on column sys_login_log.created_time is '创建时间';
|
||||
|
||||
create index ix_sys_login_log_id
|
||||
alter table sys_login_log
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_login_log_pkey
|
||||
on sys_login_log (id);
|
||||
|
||||
create unique index ix_sys_login_log_id
|
||||
on sys_login_log (id);
|
||||
|
||||
create table sys_menu
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
title varchar(50) not null,
|
||||
name varchar(50) not null,
|
||||
path varchar(200) not null,
|
||||
path varchar(200),
|
||||
sort integer not null,
|
||||
icon varchar(100),
|
||||
type integer not null,
|
||||
@ -144,11 +211,12 @@ create table sys_menu
|
||||
cache integer not null,
|
||||
link text,
|
||||
remark text,
|
||||
parent_id integer
|
||||
references sys_menu
|
||||
on delete set null,
|
||||
parent_id bigint
|
||||
references ??? ()
|
||||
on delete set null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_menu is '菜单表';
|
||||
@ -165,7 +233,7 @@ comment on column sys_menu.sort is '排序';
|
||||
|
||||
comment on column sys_menu.icon is '菜单图标';
|
||||
|
||||
comment on column sys_menu.type is '菜单类型(0目录 1菜单 2按钮)';
|
||||
comment on column sys_menu.type is '菜单类型(0目录 1菜单 2按钮 3内嵌 4外链)';
|
||||
|
||||
comment on column sys_menu.component is '组件路径';
|
||||
|
||||
@ -187,16 +255,21 @@ comment on column sys_menu.created_time is '创建时间';
|
||||
|
||||
comment on column sys_menu.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_menu_id
|
||||
alter table sys_menu
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_menu_pkey
|
||||
on sys_menu (id);
|
||||
|
||||
create index ix_sys_menu_parent_id
|
||||
on sys_menu (parent_id);
|
||||
|
||||
create unique index ix_sys_menu_id
|
||||
on sys_menu (id);
|
||||
|
||||
create table sys_opera_log
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
trace_id varchar(32) not null,
|
||||
username varchar(20),
|
||||
method varchar(20) not null,
|
||||
@ -216,7 +289,8 @@ create table sys_opera_log
|
||||
msg text,
|
||||
cost_time double precision not null,
|
||||
opera_time timestamp with time zone not null,
|
||||
created_time timestamp with time zone not null
|
||||
created_time timestamp with time zone not null,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_opera_log is '操作日志表';
|
||||
@ -263,20 +337,26 @@ comment on column sys_opera_log.opera_time is '操作时间';
|
||||
|
||||
comment on column sys_opera_log.created_time is '创建时间';
|
||||
|
||||
create index ix_sys_opera_log_id
|
||||
alter table sys_opera_log
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_opera_log_pkey
|
||||
on sys_opera_log (id);
|
||||
|
||||
create unique index ix_sys_opera_log_id
|
||||
on sys_opera_log (id);
|
||||
|
||||
create table sys_role
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
name varchar(20) not null
|
||||
unique,
|
||||
id bigserial,
|
||||
name varchar(20) not null,
|
||||
status integer not null,
|
||||
is_filter_scopes integer not null,
|
||||
remark text,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_role is '角色表';
|
||||
@ -295,22 +375,31 @@ comment on column sys_role.created_time is '创建时间';
|
||||
|
||||
comment on column sys_role.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_role_id
|
||||
alter table sys_role
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_role_pkey
|
||||
on sys_role (id);
|
||||
|
||||
create unique index sys_role_name_key
|
||||
on sys_role (name);
|
||||
|
||||
create unique index ix_sys_role_id
|
||||
on sys_role (id);
|
||||
|
||||
create table sys_config
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
name varchar(20) not null,
|
||||
type varchar(20),
|
||||
key varchar(50) not null
|
||||
unique,
|
||||
key varchar(50) not null,
|
||||
value text not null,
|
||||
is_frontend integer not null,
|
||||
remark text,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_config is '参数配置表';
|
||||
@ -333,20 +422,29 @@ comment on column sys_config.created_time is '创建时间';
|
||||
|
||||
comment on column sys_config.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_config_id
|
||||
alter table sys_config
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_config_pkey
|
||||
on sys_config (id);
|
||||
|
||||
create unique index sys_config_key_key
|
||||
on sys_config (key);
|
||||
|
||||
create unique index ix_sys_config_id
|
||||
on sys_config (id);
|
||||
|
||||
create table sys_dict_type
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
name varchar(32) not null,
|
||||
code varchar(32) not null
|
||||
unique,
|
||||
code varchar(32) not null,
|
||||
status integer not null,
|
||||
remark text,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_dict_type is '字典类型表';
|
||||
@ -365,13 +463,21 @@ comment on column sys_dict_type.created_time is '创建时间';
|
||||
|
||||
comment on column sys_dict_type.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_dict_type_id
|
||||
alter table sys_dict_type
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_dict_type_pkey
|
||||
on sys_dict_type (id);
|
||||
|
||||
create unique index sys_dict_type_code_key
|
||||
on sys_dict_type (code);
|
||||
|
||||
create unique index ix_sys_dict_type_id
|
||||
on sys_dict_type (id);
|
||||
|
||||
create table sys_notice
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
title varchar(50) not null,
|
||||
type integer not null,
|
||||
author varchar(16) not null,
|
||||
@ -379,7 +485,8 @@ create table sys_notice
|
||||
status integer not null,
|
||||
content text not null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_notice is '系统通知公告表';
|
||||
@ -402,16 +509,20 @@ comment on column sys_notice.created_time is '创建时间';
|
||||
|
||||
comment on column sys_notice.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_notice_id
|
||||
alter table sys_notice
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_notice_pkey
|
||||
on sys_notice (id);
|
||||
|
||||
create unique index ix_sys_notice_id
|
||||
on sys_notice (id);
|
||||
|
||||
create table gen_business
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
app_name varchar(50) not null,
|
||||
table_name varchar(255) not null
|
||||
unique,
|
||||
table_name varchar(255) not null,
|
||||
doc_comment varchar(255) not null,
|
||||
table_comment varchar(255),
|
||||
class_name varchar(50),
|
||||
@ -422,7 +533,9 @@ create table gen_business
|
||||
gen_path varchar(255),
|
||||
remark text,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table gen_business is '代码生成业务表';
|
||||
@ -455,62 +568,28 @@ comment on column gen_business.created_time is '创建时间';
|
||||
|
||||
comment on column gen_business.updated_time is '更新时间';
|
||||
|
||||
create index ix_gen_business_id
|
||||
alter table gen_business
|
||||
owner to postgres;
|
||||
|
||||
create unique index gen_business_pkey
|
||||
on gen_business (id);
|
||||
|
||||
create table sys_data_rule
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
name varchar(500) not null
|
||||
unique,
|
||||
model varchar(50) not null,
|
||||
"column" varchar(20) not null,
|
||||
operator integer not null,
|
||||
expression integer not null,
|
||||
value varchar(255) not null,
|
||||
scope_id integer
|
||||
references sys_data_scope
|
||||
on delete set null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
);
|
||||
create unique index gen_business_table_name_key
|
||||
on gen_business (table_name);
|
||||
|
||||
comment on table sys_data_rule is '数据规则表';
|
||||
|
||||
comment on column sys_data_rule.id is '主键 ID';
|
||||
|
||||
comment on column sys_data_rule.name is '名称';
|
||||
|
||||
comment on column sys_data_rule.model is 'SQLA 模型名,对应 DATA_PERMISSION_MODELS 键名';
|
||||
|
||||
comment on column sys_data_rule."column" is '模型字段名';
|
||||
|
||||
comment on column sys_data_rule.operator is '运算符(0:and、1:or)';
|
||||
|
||||
comment on column sys_data_rule.expression is '表达式(0:==、1:!=、2:>、3:>=、4:<、5:<=、6:in、7:not_in)';
|
||||
|
||||
comment on column sys_data_rule.value is '规则值';
|
||||
|
||||
comment on column sys_data_rule.scope_id is '数据范围关联 ID';
|
||||
|
||||
comment on column sys_data_rule.created_time is '创建时间';
|
||||
|
||||
comment on column sys_data_rule.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_data_rule_id
|
||||
on sys_data_rule (id);
|
||||
create unique index ix_gen_business_id
|
||||
on gen_business (id);
|
||||
|
||||
create table sys_role_menu
|
||||
(
|
||||
id serial,
|
||||
role_id integer not null
|
||||
references sys_role
|
||||
on delete cascade,
|
||||
menu_id integer not null
|
||||
references sys_menu
|
||||
on delete cascade,
|
||||
primary key (id, role_id, menu_id)
|
||||
id bigserial,
|
||||
role_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
menu_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on column sys_role_menu.id is '主键ID';
|
||||
@ -519,19 +598,25 @@ comment on column sys_role_menu.role_id is '角色ID';
|
||||
|
||||
comment on column sys_role_menu.menu_id is '菜单ID';
|
||||
|
||||
alter table sys_role_menu
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_role_menu_pkey
|
||||
on sys_role_menu (id, role_id, menu_id);
|
||||
|
||||
create unique index ix_sys_role_menu_id
|
||||
on sys_role_menu (id);
|
||||
|
||||
create table sys_role_data_scope
|
||||
(
|
||||
id serial,
|
||||
role_id integer not null
|
||||
references sys_role
|
||||
on delete cascade,
|
||||
data_scope_id integer not null
|
||||
references sys_data_scope
|
||||
on delete cascade,
|
||||
primary key (id, role_id, data_scope_id)
|
||||
id bigserial,
|
||||
role_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
data_scope_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on column sys_role_data_scope.id is '主键 ID';
|
||||
@ -540,34 +625,66 @@ comment on column sys_role_data_scope.role_id is '角色 ID';
|
||||
|
||||
comment on column sys_role_data_scope.data_scope_id is '数据范围 ID';
|
||||
|
||||
alter table sys_role_data_scope
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_role_data_scope_pkey
|
||||
on sys_role_data_scope (id, role_id, data_scope_id);
|
||||
|
||||
create unique index ix_sys_role_data_scope_id
|
||||
on sys_role_data_scope (id);
|
||||
|
||||
create table sys_data_scope_rule
|
||||
(
|
||||
id bigserial,
|
||||
data_scope_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
data_rule_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on column sys_data_scope_rule.id is '主键ID';
|
||||
|
||||
comment on column sys_data_scope_rule.data_scope_id is '数据范围 ID';
|
||||
|
||||
comment on column sys_data_scope_rule.data_rule_id is '数据规则 ID';
|
||||
|
||||
alter table sys_data_scope_rule
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_data_scope_rule_pkey
|
||||
on sys_data_scope_rule (id, data_scope_id, data_rule_id);
|
||||
|
||||
create unique index ix_sys_data_scope_rule_id
|
||||
on sys_data_scope_rule (id);
|
||||
|
||||
create table sys_user
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
uuid varchar(50) not null
|
||||
unique,
|
||||
id bigserial,
|
||||
uuid varchar(50) not null,
|
||||
username varchar(20) not null,
|
||||
nickname varchar(20) not null
|
||||
unique,
|
||||
password varchar(255),
|
||||
salt bytea,
|
||||
email varchar(50) not null,
|
||||
nickname varchar(20) not null,
|
||||
password varchar(255) not null,
|
||||
salt bytea not null,
|
||||
email varchar(50),
|
||||
phone varchar(11),
|
||||
avatar varchar(255),
|
||||
status integer not null,
|
||||
is_superuser integer not null,
|
||||
is_staff integer not null,
|
||||
status integer not null,
|
||||
is_multi_login integer not null,
|
||||
avatar varchar(255),
|
||||
phone varchar(11),
|
||||
join_time timestamp with time zone not null,
|
||||
last_login_time timestamp with time zone,
|
||||
dept_id integer
|
||||
references sys_dept
|
||||
on delete set null,
|
||||
dept_id bigint
|
||||
references ??? ()
|
||||
on delete set null,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_user is '用户表';
|
||||
@ -584,18 +701,18 @@ comment on column sys_user.salt is '加密盐';
|
||||
|
||||
comment on column sys_user.email is '邮箱';
|
||||
|
||||
comment on column sys_user.phone is '手机号';
|
||||
|
||||
comment on column sys_user.avatar is '头像';
|
||||
|
||||
comment on column sys_user.status is '用户账号状态(0停用 1正常)';
|
||||
|
||||
comment on column sys_user.is_superuser is '超级权限(0否 1是)';
|
||||
|
||||
comment on column sys_user.is_staff is '后台管理登陆(0否 1是)';
|
||||
|
||||
comment on column sys_user.status is '用户账号状态(0停用 1正常)';
|
||||
|
||||
comment on column sys_user.is_multi_login is '是否重复登陆(0否 1是)';
|
||||
|
||||
comment on column sys_user.avatar is '头像';
|
||||
|
||||
comment on column sys_user.phone is '手机号';
|
||||
|
||||
comment on column sys_user.join_time is '注册时间';
|
||||
|
||||
comment on column sys_user.last_login_time is '上次登录';
|
||||
@ -606,33 +723,42 @@ comment on column sys_user.created_time is '创建时间';
|
||||
|
||||
comment on column sys_user.updated_time is '更新时间';
|
||||
|
||||
alter table sys_user
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_user_pkey
|
||||
on sys_user (id);
|
||||
|
||||
create unique index sys_user_uuid_key
|
||||
on sys_user (uuid);
|
||||
|
||||
create unique index ix_sys_user_email
|
||||
on sys_user (email);
|
||||
|
||||
create index ix_sys_user_id
|
||||
on sys_user (id);
|
||||
|
||||
create unique index ix_sys_user_username
|
||||
on sys_user (username);
|
||||
|
||||
create unique index ix_sys_user_id
|
||||
on sys_user (id);
|
||||
|
||||
create index ix_sys_user_status
|
||||
on sys_user (status);
|
||||
|
||||
create table sys_dict_data
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
label varchar(32) not null
|
||||
unique,
|
||||
id bigserial,
|
||||
label varchar(32) not null,
|
||||
value varchar(32) not null,
|
||||
sort integer not null,
|
||||
status integer not null,
|
||||
remark text,
|
||||
type_id integer not null
|
||||
references sys_dict_type
|
||||
on delete cascade,
|
||||
type_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key (),
|
||||
unique ()
|
||||
);
|
||||
|
||||
comment on table sys_dict_data is '字典数据表';
|
||||
@ -655,13 +781,21 @@ comment on column sys_dict_data.created_time is '创建时间';
|
||||
|
||||
comment on column sys_dict_data.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_dict_data_id
|
||||
alter table sys_dict_data
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_dict_data_pkey
|
||||
on sys_dict_data (id);
|
||||
|
||||
create unique index sys_dict_data_label_key
|
||||
on sys_dict_data (label);
|
||||
|
||||
create unique index ix_sys_dict_data_id
|
||||
on sys_dict_data (id);
|
||||
|
||||
create table gen_column
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
name varchar(50) not null,
|
||||
comment varchar(255),
|
||||
type varchar(20) not null,
|
||||
@ -671,9 +805,10 @@ create table gen_column
|
||||
length integer not null,
|
||||
is_pk boolean not null,
|
||||
is_nullable boolean not null,
|
||||
gen_business_id integer not null
|
||||
references gen_business
|
||||
on delete cascade
|
||||
gen_business_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table gen_column is '代码生成模型列表';
|
||||
@ -700,19 +835,25 @@ comment on column gen_column.is_nullable is '是否可为空';
|
||||
|
||||
comment on column gen_column.gen_business_id is '代码生成业务ID';
|
||||
|
||||
create index ix_gen_column_id
|
||||
alter table gen_column
|
||||
owner to postgres;
|
||||
|
||||
create unique index gen_column_pkey
|
||||
on gen_column (id);
|
||||
|
||||
create unique index ix_gen_column_id
|
||||
on gen_column (id);
|
||||
|
||||
create table sys_user_role
|
||||
(
|
||||
id serial,
|
||||
user_id integer not null
|
||||
references sys_user
|
||||
on delete cascade,
|
||||
role_id integer not null
|
||||
references sys_role
|
||||
on delete cascade,
|
||||
primary key (id, user_id, role_id)
|
||||
id bigserial,
|
||||
user_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
role_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on column sys_user_role.id is '主键ID';
|
||||
@ -721,47 +862,47 @@ comment on column sys_user_role.user_id is '用户ID';
|
||||
|
||||
comment on column sys_user_role.role_id is '角色ID';
|
||||
|
||||
alter table sys_user_role
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_user_role_pkey
|
||||
on sys_user_role (id, user_id, role_id);
|
||||
|
||||
create unique index ix_sys_user_role_id
|
||||
on sys_user_role (id);
|
||||
|
||||
create table sys_user_social
|
||||
(
|
||||
id serial
|
||||
primary key,
|
||||
id bigserial,
|
||||
sid varchar(20) not null,
|
||||
source varchar(20) not null,
|
||||
open_id varchar(20),
|
||||
sid varchar(20),
|
||||
union_id varchar(20),
|
||||
scope varchar(120),
|
||||
code varchar(50),
|
||||
user_id integer
|
||||
references sys_user
|
||||
on delete set null,
|
||||
user_id bigint not null
|
||||
references ??? ()
|
||||
on delete cascade,
|
||||
created_time timestamp with time zone not null,
|
||||
updated_time timestamp with time zone
|
||||
updated_time timestamp with time zone,
|
||||
primary key ()
|
||||
);
|
||||
|
||||
comment on table sys_user_social is '用户社交表(OAuth2)';
|
||||
|
||||
comment on column sys_user_social.id is '主键 ID';
|
||||
|
||||
comment on column sys_user_social.sid is '第三方用户 ID';
|
||||
|
||||
comment on column sys_user_social.source is '第三方用户来源';
|
||||
|
||||
comment on column sys_user_social.open_id is '第三方用户 open id';
|
||||
|
||||
comment on column sys_user_social.uid is '第三方用户 ID';
|
||||
|
||||
comment on column sys_user_social.union_id is '第三方用户 union id';
|
||||
|
||||
comment on column sys_user_social.scope is '第三方用户授予的权限';
|
||||
|
||||
comment on column sys_user_social.code is '用户的授权 code';
|
||||
|
||||
comment on column sys_user_social.user_id is '用户关联ID';
|
||||
|
||||
comment on column sys_user_social.created_time is '创建时间';
|
||||
|
||||
comment on column sys_user_social.updated_time is '更新时间';
|
||||
|
||||
create index ix_sys_user_social_id
|
||||
alter table sys_user_social
|
||||
owner to postgres;
|
||||
|
||||
create unique index sys_user_social_pkey
|
||||
on sys_user_social (id);
|
||||
|
||||
create unique index ix_sys_user_social_id
|
||||
on sys_user_social (id);
|
||||
|
Reference in New Issue
Block a user