-- ----------------------------
-- Table structure for blade_auth_lock
-- ----------------------------
CREATE TABLE "BLADEX"."BLADE_AUTH_LOCK"
(
    "ID" BIGINT NOT NULL,
    "USER_ID" BIGINT NULL,
    "TENANT_ID" VARCHAR(12) DEFAULT '000000',
    "LOCK_TYPE" VARCHAR(20) NOT NULL,
    "LOCK_STATUS" VARCHAR(20) NOT NULL,
    "LOCK_TARGET" VARCHAR(100) NOT NULL,
    "REMOTE_IP" VARCHAR(50) NULL,
    "USER_AGENT" VARCHAR(500) NULL,
    "FAIL_COUNT" INT DEFAULT 0,
    "LOCK_BEGIN_TIME" DATETIME NOT NULL,
    "LOCK_END_TIME" DATETIME NULL,
    "LOCK_REASON" VARCHAR(500) NULL,
    "UNLOCK_REASON" VARCHAR(500) NULL,
    "STATUS" INT DEFAULT 1,
    "IS_DELETED" INT DEFAULT 0,
    PRIMARY KEY ("ID")
);

COMMENT ON TABLE "BLADEX"."BLADE_AUTH_LOCK" IS '认证锁定记录表';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."ID" IS '主键';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."USER_ID" IS '关联用户ID';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."TENANT_ID" IS '租户ID';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_TYPE" IS '锁定类型（SYSTEM-系统自动/MANUAL-人工手动）';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_STATUS" IS '锁定状态（PRE_LOCKED-待锁定/LOCKED-锁定中/UN_LOCKED-已解锁）';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_TARGET" IS '锁定目标（账号名或IP地址）';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."REMOTE_IP" IS '请求IP';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."USER_AGENT" IS '用户代理';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."FAIL_COUNT" IS '认证失败次数';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_BEGIN_TIME" IS '锁定开始时间';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_END_TIME" IS '锁定结束时间（MANUAL类型为空表示永久锁定，SYSTEM-LOCKED状态为锁定到期时间）';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."LOCK_REASON" IS '锁定原因';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."UNLOCK_REASON" IS '解锁原因';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."STATUS" IS '状态';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOCK"."IS_DELETED" IS '是否已删除';

-- ----------------------------
-- Table structure for blade_auth_log
-- ----------------------------
CREATE TABLE "BLADEX"."BLADE_AUTH_LOG"
(
    "ID" BIGINT NOT NULL,
    "USER_ID" BIGINT NULL,
    "TENANT_ID" VARCHAR(12) DEFAULT '000000',
    "SERVICE_ID" VARCHAR(32) NULL,
    "SERVER_IP" VARCHAR(255) NULL,
    "SERVER_HOST" VARCHAR(255) NULL,
    "ENV" VARCHAR(255) NULL,
    "ACCOUNT" VARCHAR(45) NULL,
    "REAL_NAME" VARCHAR(20) NULL,
    "GRANT_TYPE" VARCHAR(30) NULL,
    "REMOTE_IP" VARCHAR(255) NULL,
    "USER_AGENT" VARCHAR(1000) NULL,
    "LOGIN_TIME" DATETIME NULL,
    "STATUS" INT DEFAULT 1,
    "IS_DELETED" INT DEFAULT 0,
    PRIMARY KEY ("ID")
);

COMMENT ON TABLE "BLADEX"."BLADE_AUTH_LOG" IS '认证日志表';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."ID" IS '主键';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."USER_ID" IS '用户ID';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."TENANT_ID" IS '租户ID';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."SERVICE_ID" IS '服务ID';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."SERVER_IP" IS '服务器IP地址';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."SERVER_HOST" IS '服务器名';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."ENV" IS '服务器环境';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."ACCOUNT" IS '授权账号';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."REAL_NAME" IS '用户姓名';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."GRANT_TYPE" IS '授权类型';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."REMOTE_IP" IS '请求IP';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."USER_AGENT" IS '用户代理';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."LOGIN_TIME" IS '登录时间';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."STATUS" IS '状态';

COMMENT ON COLUMN "BLADEX"."BLADE_AUTH_LOG"."IS_DELETED" IS '是否已删除';

-- ----------------------------
-- Table structure for blade_api_key_log
-- ----------------------------
CREATE TABLE "BLADEX"."BLADE_API_KEY_LOG"
(
    "ID" BIGINT NOT NULL,
    "TENANT_ID" VARCHAR(12) DEFAULT '000000',
    "SERVICE_ID" VARCHAR(32) NULL,
    "SERVER_HOST" VARCHAR(255) NULL,
    "SERVER_IP" VARCHAR(255) NULL,
    "ENV" VARCHAR(255) NULL,
    "API_KEY_ID" BIGINT NULL,
    "METHOD" VARCHAR(10) NULL,
    "REQUEST_URI" VARCHAR(255) NULL,
    "USER_AGENT" VARCHAR(1000) NULL,
    "REMOTE_IP" VARCHAR(255) NULL,
    "PARAMS" CLOB NULL,
    "TIME" VARCHAR(64) NULL,
    "CREATE_BY" VARCHAR(64) NULL,
    "CREATE_TIME" DATETIME NULL,
    PRIMARY KEY ("ID")
);

COMMENT ON TABLE "BLADEX"."BLADE_API_KEY_LOG" IS '令牌调用日志表';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."ID" IS '编号';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."TENANT_ID" IS '租户ID';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."SERVICE_ID" IS '服务ID';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."SERVER_HOST" IS '服务器名';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."SERVER_IP" IS '服务器IP地址';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."ENV" IS '服务器环境';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."API_KEY_ID" IS 'API Key主键ID';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."METHOD" IS '操作方式';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."REQUEST_URI" IS '请求URI';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."USER_AGENT" IS '用户代理';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."REMOTE_IP" IS '操作IP地址';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."PARAMS" IS '操作提交的数据';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."TIME" IS '执行时间';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."CREATE_BY" IS '创建者';

COMMENT ON COLUMN "BLADEX"."BLADE_API_KEY_LOG"."CREATE_TIME" IS '创建时间';

-- -----------------------------------
-- 新增是否主页字段
-- -----------------------------------
ALTER TABLE "BLADE_TOP_MENU" ADD "IS_MAIN" INT DEFAULT 0;
COMMENT ON COLUMN "BLADE_TOP_MENU"."IS_MAIN" IS '是否主页';
