/*
 Navicat Premium Data Transfer

 Source Server         : sw-system
 Source Server Type    : PostgreSQL
 Source Server Version : 90204 (90204)
 Source Host           : 192.168.10.130:5432
 Source Catalog        : sw_system
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 90204 (90204)
 File Encoding         : 65001

 Date: 06/08/2025 16:30:40
*/


-- ----------------------------
-- Table structure for system_oauth2_access_token
-- ----------------------------
DROP TABLE IF EXISTS "public"."system_oauth2_access_token";
CREATE TABLE "public"."system_oauth2_access_token" (
  "id" int8 NOT NULL,
  "user_id" int8 NOT NULL,
  "user_type" int2 NOT NULL,
  "user_info" varchar(512) COLLATE "pg_catalog"."default" NOT NULL,
  "access_token" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "refresh_token" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
  "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "scopes" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "expires_time" timestamp(6) NOT NULL,
  "creator" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "create_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "updater" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "update_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "deleted" int2 NOT NULL DEFAULT 0,
  "tenant_id" int8 NOT NULL DEFAULT 0
)
;
ALTER TABLE "public"."system_oauth2_access_token" OWNER TO "sw_system";
COMMENT ON COLUMN "public"."system_oauth2_access_token"."id" IS '编号';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."user_id" IS '用户编号';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."user_type" IS '用户类型';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."user_info" IS '用户信息';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."access_token" IS '访问令牌';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."refresh_token" IS '刷新令牌';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."client_id" IS '客户端编号';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."scopes" IS '授权范围';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."expires_time" IS '过期时间';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."creator" IS '创建者';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."updater" IS '更新者';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."deleted" IS '是否删除';
COMMENT ON COLUMN "public"."system_oauth2_access_token"."tenant_id" IS '租户编号';
COMMENT ON TABLE "public"."system_oauth2_access_token" IS 'OAuth2 访问令牌';

-- ----------------------------
-- Table structure for system_oauth2_approve
-- ----------------------------
DROP TABLE IF EXISTS "public"."system_oauth2_approve";
CREATE TABLE "public"."system_oauth2_approve" (
  "id" int8 NOT NULL,
  "user_id" int8 NOT NULL,
  "user_type" int2 NOT NULL,
  "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "scope" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "approved" bool NOT NULL DEFAULT false,
  "expires_time" timestamp(6) NOT NULL,
  "creator" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "create_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "updater" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "update_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "deleted" int2 NOT NULL DEFAULT 0,
  "tenant_id" int8 NOT NULL DEFAULT 0
)
;
ALTER TABLE "public"."system_oauth2_approve" OWNER TO "sw_system";
COMMENT ON COLUMN "public"."system_oauth2_approve"."id" IS '编号';
COMMENT ON COLUMN "public"."system_oauth2_approve"."user_id" IS '用户编号';
COMMENT ON COLUMN "public"."system_oauth2_approve"."user_type" IS '用户类型';
COMMENT ON COLUMN "public"."system_oauth2_approve"."client_id" IS '客户端编号';
COMMENT ON COLUMN "public"."system_oauth2_approve"."scope" IS '授权范围';
COMMENT ON COLUMN "public"."system_oauth2_approve"."approved" IS '是否接受';
COMMENT ON COLUMN "public"."system_oauth2_approve"."expires_time" IS '过期时间';
COMMENT ON COLUMN "public"."system_oauth2_approve"."creator" IS '创建者';
COMMENT ON COLUMN "public"."system_oauth2_approve"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."system_oauth2_approve"."updater" IS '更新者';
COMMENT ON COLUMN "public"."system_oauth2_approve"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."system_oauth2_approve"."deleted" IS '是否删除';
COMMENT ON COLUMN "public"."system_oauth2_approve"."tenant_id" IS '租户编号';
COMMENT ON TABLE "public"."system_oauth2_approve" IS 'OAuth2 批准表';

-- ----------------------------
-- Table structure for system_oauth2_client
-- ----------------------------
DROP TABLE IF EXISTS "public"."system_oauth2_client";
CREATE TABLE "public"."system_oauth2_client" (
  "id" int8 NOT NULL,
  "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "secret" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "logo" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "description" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "status" int2 NOT NULL,
  "access_token_validity_seconds" int4 NOT NULL,
  "refresh_token_validity_seconds" int4 NOT NULL,
  "redirect_uris" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "authorized_grant_types" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "scopes" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "auto_approve_scopes" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "authorities" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "resource_ids" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "additional_information" varchar(4096) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "creator" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "create_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "updater" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "update_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "deleted" int2 NOT NULL DEFAULT 0
)
;
ALTER TABLE "public"."system_oauth2_client" OWNER TO "sw_system";
COMMENT ON COLUMN "public"."system_oauth2_client"."id" IS '编号';
COMMENT ON COLUMN "public"."system_oauth2_client"."client_id" IS '客户端编号';
COMMENT ON COLUMN "public"."system_oauth2_client"."secret" IS '客户端密钥';
COMMENT ON COLUMN "public"."system_oauth2_client"."name" IS '应用名';
COMMENT ON COLUMN "public"."system_oauth2_client"."logo" IS '应用图标';
COMMENT ON COLUMN "public"."system_oauth2_client"."description" IS '应用描述';
COMMENT ON COLUMN "public"."system_oauth2_client"."status" IS '状态';
COMMENT ON COLUMN "public"."system_oauth2_client"."access_token_validity_seconds" IS '访问令牌的有效期';
COMMENT ON COLUMN "public"."system_oauth2_client"."refresh_token_validity_seconds" IS '刷新令牌的有效期';
COMMENT ON COLUMN "public"."system_oauth2_client"."redirect_uris" IS '可重定向的 URI 地址';
COMMENT ON COLUMN "public"."system_oauth2_client"."authorized_grant_types" IS '授权类型';
COMMENT ON COLUMN "public"."system_oauth2_client"."scopes" IS '授权范围';
COMMENT ON COLUMN "public"."system_oauth2_client"."auto_approve_scopes" IS '自动通过的授权范围';
COMMENT ON COLUMN "public"."system_oauth2_client"."authorities" IS '权限';
COMMENT ON COLUMN "public"."system_oauth2_client"."resource_ids" IS '资源';
COMMENT ON COLUMN "public"."system_oauth2_client"."additional_information" IS '附加信息';
COMMENT ON COLUMN "public"."system_oauth2_client"."creator" IS '创建者';
COMMENT ON COLUMN "public"."system_oauth2_client"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."system_oauth2_client"."updater" IS '更新者';
COMMENT ON COLUMN "public"."system_oauth2_client"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."system_oauth2_client"."deleted" IS '是否删除';
COMMENT ON TABLE "public"."system_oauth2_client" IS 'OAuth2 客户端表';

-- ----------------------------
-- Table structure for system_oauth2_code
-- ----------------------------
DROP TABLE IF EXISTS "public"."system_oauth2_code";
CREATE TABLE "public"."system_oauth2_code" (
  "id" int8 NOT NULL,
  "user_id" int8 NOT NULL,
  "user_type" int2 NOT NULL,
  "code" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
  "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "scopes" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "expires_time" timestamp(6) NOT NULL,
  "redirect_uri" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "state" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "creator" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "create_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "updater" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "update_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "deleted" int2 NOT NULL DEFAULT 0,
  "tenant_id" int8 NOT NULL DEFAULT 0
)
;
ALTER TABLE "public"."system_oauth2_code" OWNER TO "sw_system";
COMMENT ON COLUMN "public"."system_oauth2_code"."id" IS '编号';
COMMENT ON COLUMN "public"."system_oauth2_code"."user_id" IS '用户编号';
COMMENT ON COLUMN "public"."system_oauth2_code"."user_type" IS '用户类型';
COMMENT ON COLUMN "public"."system_oauth2_code"."code" IS '授权码';
COMMENT ON COLUMN "public"."system_oauth2_code"."client_id" IS '客户端编号';
COMMENT ON COLUMN "public"."system_oauth2_code"."scopes" IS '授权范围';
COMMENT ON COLUMN "public"."system_oauth2_code"."expires_time" IS '过期时间';
COMMENT ON COLUMN "public"."system_oauth2_code"."redirect_uri" IS '可重定向的 URI 地址';
COMMENT ON COLUMN "public"."system_oauth2_code"."state" IS '状态';
COMMENT ON COLUMN "public"."system_oauth2_code"."creator" IS '创建者';
COMMENT ON COLUMN "public"."system_oauth2_code"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."system_oauth2_code"."updater" IS '更新者';
COMMENT ON COLUMN "public"."system_oauth2_code"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."system_oauth2_code"."deleted" IS '是否删除';
COMMENT ON COLUMN "public"."system_oauth2_code"."tenant_id" IS '租户编号';
COMMENT ON TABLE "public"."system_oauth2_code" IS 'OAuth2 授权码表';

-- ----------------------------
-- Table structure for system_oauth2_refresh_token
-- ----------------------------
DROP TABLE IF EXISTS "public"."system_oauth2_refresh_token";
CREATE TABLE "public"."system_oauth2_refresh_token" (
  "id" int8 NOT NULL,
  "user_id" int8 NOT NULL,
  "refresh_token" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
  "user_type" int2 NOT NULL,
  "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "scopes" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "expires_time" timestamp(6) NOT NULL,
  "creator" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "create_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "updater" varchar(64) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "update_time" timestamp(6) NOT NULL DEFAULT pg_systimestamp(),
  "deleted" int2 NOT NULL DEFAULT 0,
  "tenant_id" int8 NOT NULL DEFAULT 0
)
;
ALTER TABLE "public"."system_oauth2_refresh_token" OWNER TO "sw_system";
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."id" IS '编号';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."user_id" IS '用户编号';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."refresh_token" IS '刷新令牌';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."user_type" IS '用户类型';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."client_id" IS '客户端编号';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."scopes" IS '授权范围';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."expires_time" IS '过期时间';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."creator" IS '创建者';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."updater" IS '更新者';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."deleted" IS '是否删除';
COMMENT ON COLUMN "public"."system_oauth2_refresh_token"."tenant_id" IS '租户编号';
COMMENT ON TABLE "public"."system_oauth2_refresh_token" IS 'OAuth2 刷新令牌';

-- ----------------------------
-- Indexes structure for table system_oauth2_access_token
-- ----------------------------
CREATE INDEX "idx_system_oauth2_access_token_01" ON "public"."system_oauth2_access_token" USING btree (
  "access_token" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_system_oauth2_access_token_02" ON "public"."system_oauth2_access_token" USING btree (
  "refresh_token" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

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

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

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

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

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