-- ----------------------------
-- Table structure for sys_group
-- ----------------------------
DROP TABLE IF EXISTS "public"."sys_user";
DROP TABLE IF EXISTS "public"."sys_group";

DROP SEQUENCE IF EXISTS "public"."sys_group_id_seq";
CREATE SEQUENCE IF NOT EXISTS "public"."sys_group_id_seq" AS integer;

CREATE TABLE "public"."sys_group" (
                                      "id" int4 NOT NULL DEFAULT nextval('sys_group_id_seq'::regclass),
                                      "create_time" timestamp(6),
                                      "creator_id" int4,
                                      "site_num" varchar(255) COLLATE "pg_catalog"."default",
                                      "update_time" timestamp(6),
                                      "updater_id" int4,
                                      "app_module_id" int4,
                                      "description" varchar(255) COLLATE "pg_catalog"."default",
                                      "group_name" varchar(255) COLLATE "pg_catalog"."default"
)
;

-- ----------------------------
-- Uniques structure for table sys_group
-- ----------------------------
ALTER TABLE "public"."sys_group" ADD CONSTRAINT "用户组名称不能重复" UNIQUE ("group_name");

-- ----------------------------
-- Primary Key structure for table sys_group
-- ----------------------------
ALTER TABLE "public"."sys_group" ADD CONSTRAINT "sys_group_pkey" PRIMARY KEY ("id");






-- auth table

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS "public"."sys_user";

DROP SEQUENCE IF EXISTS "public"."sys_user_id_seq";
CREATE SEQUENCE IF NOT EXISTS "public"."sys_user_id_seq" AS integer;

CREATE TABLE "public"."sys_user" (
                                     "id" int4 NOT NULL DEFAULT nextval('sys_user_id_seq'::regclass),
                                     "create_time" timestamp(6),
                                     "creator_id" int4,
                                     "site_num" varchar(255) COLLATE "pg_catalog"."default",
                                     "update_time" timestamp(6),
                                     "updater_id" int4,
                                     "app_module_id" int4,
                                     "birthday" "sys"."date",
                                     "cas_id" int8,
                                     "client_module_id" int4,
                                     "department_id" int4,
                                     "description" varchar(255) COLLATE "pg_catalog"."default",
                                     "email" varchar(255) COLLATE "pg_catalog"."default",
                                     "gender" int4,
                                     "head_icon" varchar(100) COLLATE "pg_catalog"."default",
                                     "mobile_phone" varchar(255) COLLATE "pg_catalog"."default",
                                     "module_id" int4,
                                     "position" varchar(255) COLLATE "pg_catalog"."default",
                                     "security_level" int4,
                                     "sort_code" int4,
                                     "user_account" varchar(200) COLLATE "pg_catalog"."default",
                                     "user_name" varchar(20) COLLATE "pg_catalog"."default",
                                     "wechat" varchar(255) COLLATE "pg_catalog"."default",
                                     "group_id" int4
)
;

-- ----------------------------
-- Checks structure for table sys_user
-- ----------------------------
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "sys_user_department_id_check" CHECK (department_id >= 0);
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "sys_user_gender_check" CHECK (gender >= 1 AND gender <= 2);

-- ----------------------------
-- Primary Key structure for table sys_user
-- ----------------------------
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "sys_user_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Keys structure for table sys_user
-- ----------------------------
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "FKl7i4833vinxhaeho5oynrsjtk" FOREIGN KEY ("group_id") REFERENCES "public"."sys_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;



-- auth
INSERT INTO public.sys_user (id, create_time, creator_id, site_num, update_time, updater_id, app_module_id, birthday, cas_id, client_module_id, department_id, description, email, gender, head_icon, mobile_phone, module_id, position, security_level, sort_code, user_account, user_name, wechat, group_id) VALUES (1, CLOCK_TIMESTAMP()::timestamp, 1, null, CLOCK_TIMESTAMP()::timestamp, 1, null, current_date, 1, null, 0, '', 'jfliang@h-visions.com', 1, '', '', null, '', 1, 1, 'admin', 'admin', '', null);
select setval('public.sys_user_id_seq'::regclass, 100);