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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- -----------------------------------
-- 新增是否主页字段
-- -----------------------------------
ALTER TABLE "BLADE_TOP_MENU" ADD "IS_MAIN" NUMBER(11,0) DEFAULT 0;

COMMENT ON COLUMN "BLADE_TOP_MENU"."IS_MAIN" IS '是否主页';
