-- ----------------------------
-- 表名：base_tenant
-- ----------------------------
CREATE TABLE base_tenant(
	"F_ID" VARCHAR(150) NOT NULL,
	"F_EN_CODE" VARCHAR(150),
	"F_FULL_NAME" VARCHAR(150),
	"F_DB_NAME" VARCHAR(150),
	"F_DESCRIPTION" VARCHAR(1500),
	"F_SORT_CODE" BIGINT,
	"F_ENABLED_MARK" INT,
	"F_CREATOR_TIME" TIMESTAMP,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150),
	"F_TENANT_ID" VARCHAR(150),
	"F_START_TIME" TIMESTAMP,
	"F_END_TIME" TIMESTAMP,
	"F_ACCOUNT_NUM" BIGINT,
	"F_TYPE" INT,
	"F_DB_TYPE" VARCHAR(150),
	"F_UNIT_INFO_JSON" CLOB,
	"F_USER_INFO_JSON" CLOB

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant IS '租户表';
COMMENT ON COLUMN base_tenant."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant."F_EN_CODE" IS '编号';
COMMENT ON COLUMN base_tenant."F_FULL_NAME" IS '名称';
COMMENT ON COLUMN base_tenant."F_DB_NAME" IS '服务名称';
COMMENT ON COLUMN base_tenant."F_DESCRIPTION" IS '描述';
COMMENT ON COLUMN base_tenant."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant."F_ENABLED_MARK" IS '有效标志';
COMMENT ON COLUMN base_tenant."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant."F_DELETE_MARK" IS '删除标志';
COMMENT ON COLUMN base_tenant."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant."F_DELETE_USER_ID" IS '删除用户';
COMMENT ON COLUMN base_tenant."F_TENANT_ID" IS '租户主键';
COMMENT ON COLUMN base_tenant."F_START_TIME" IS '起始时间';
COMMENT ON COLUMN base_tenant."F_END_TIME" IS '过期时间';
COMMENT ON COLUMN base_tenant."F_ACCOUNT_NUM" IS '账号额度';
COMMENT ON COLUMN base_tenant."F_TYPE" IS '类型(0-库隔离 1-id隔离 2-连接隔离)';
COMMENT ON COLUMN base_tenant."F_DB_TYPE" IS '数据库类型';
COMMENT ON COLUMN base_tenant."F_UNIT_INFO_JSON" IS '单位信息';
COMMENT ON COLUMN base_tenant."F_USER_INFO_JSON" IS '联系人信息';
-- ----------------------------
-- 表名：base_tenant_account
-- ----------------------------
CREATE TABLE base_tenant_account(
	"F_ID" VARCHAR(150) NOT NULL,
	"F_ACCOUNT" VARCHAR(150),
	"F_PASSWORD" VARCHAR(150),
	"F_REAL_NAME" VARCHAR(150),
	"F_GENDER" INT,
	"F_IS_ADMINISTRATOR" INT,
	"F_DESCRIPTION" VARCHAR(1500),
	"F_SORT_CODE" BIGINT,
	"F_ENABLED_MARK" INT,
	"F_CREATOR_TIME" TIMESTAMP,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_TENANT_ID" VARCHAR(150),
	"F_MOBILE_PHONE" VARCHAR(150)

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant_account IS '用户信息';
COMMENT ON COLUMN base_tenant_account."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant_account."F_ACCOUNT" IS '账户';
COMMENT ON COLUMN base_tenant_account."F_PASSWORD" IS '密码';
COMMENT ON COLUMN base_tenant_account."F_REAL_NAME" IS '姓名';
COMMENT ON COLUMN base_tenant_account."F_GENDER" IS '性别';
COMMENT ON COLUMN base_tenant_account."F_IS_ADMINISTRATOR" IS '是否管理员';
COMMENT ON COLUMN base_tenant_account."F_DESCRIPTION" IS '描述';
COMMENT ON COLUMN base_tenant_account."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant_account."F_ENABLED_MARK" IS '有效标志';
COMMENT ON COLUMN base_tenant_account."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant_account."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant_account."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant_account."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant_account."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant_account."F_DELETE_USER_ID" IS '删除用户';
COMMENT ON COLUMN base_tenant_account."F_DELETE_MARK" IS '删除标志';
COMMENT ON COLUMN base_tenant_account."F_TENANT_ID" IS '租户主键';
COMMENT ON COLUMN base_tenant_account."F_MOBILE_PHONE" IS '手机号码';
DELETE FROM base_tenant_account;
INSERT INTO base_tenant_account ("F_ENABLED_MARK","F_PASSWORD","F_TENANT_ID","F_CREATOR_USER_ID","F_LAST_MODIFY_USER_ID","F_DELETE_MARK","F_DELETE_USER_ID","F_IS_ADMINISTRATOR","F_DELETE_TIME","F_MOBILE_PHONE","F_ACCOUNT","F_REAL_NAME","F_DESCRIPTION","F_GENDER","F_SORT_CODE","F_ID","F_LAST_MODIFY_TIME","F_CREATOR_TIME") VALUES (1,'14e1b600b1fd579f47433b88e8d85291',Null,'1',Null,Null,Null,1,Null,Null,'admin','管理员','admin',1,1,'47ff0279-aa26a4fbeb59f630c8776f759',Null,'2021-09-18 18:01:08');
-- ----------------------------
-- 表名：base_tenant_authorize
-- ----------------------------
CREATE TABLE base_tenant_authorize(
	"F_ID" VARCHAR(150) NOT NULL,
	"F_MODULE_ID" VARCHAR(150),
	"F_URL_ADDRESS" VARCHAR(1500),
	"F_TENANT_ID" VARCHAR(150),
	"F_SORT_CODE" BIGINT,
	"F_CREATOR_TIME" TIMESTAMP,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150)

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant_authorize IS '租户权限';
COMMENT ON COLUMN base_tenant_authorize."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant_authorize."F_MODULE_ID" IS '未授权菜单id';
COMMENT ON COLUMN base_tenant_authorize."F_URL_ADDRESS" IS '功能地址';
COMMENT ON COLUMN base_tenant_authorize."F_TENANT_ID" IS '租户主键';
COMMENT ON COLUMN base_tenant_authorize."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant_authorize."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant_authorize."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant_authorize."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant_authorize."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant_authorize."F_DELETE_MARK" IS '删除标志';
COMMENT ON COLUMN base_tenant_authorize."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant_authorize."F_DELETE_USER_ID" IS '删除用户';
-- ----------------------------
-- 表名：base_tenant_link
-- ----------------------------
CREATE TABLE base_tenant_link(
	"F_ID" VARCHAR(150) NOT NULL,
	"F_FULL_NAME" VARCHAR(150),
	"F_CONFIG_TYPE" INT,
	"F_HOST" VARCHAR(150),
	"F_PORT" INT,
	"F_USER_NAME" VARCHAR(150),
	"F_PASSWORD" VARCHAR(150),
	"F_SERVICE_NAME" VARCHAR(150),
	"F_DESCRIPTION" CLOB,
	"F_SORT_CODE" BIGINT,
	"F_ENABLED_MARK" INT,
	"F_CREATOR_TIME" TIMESTAMP,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150),
	"F_DB_SCHEMA" VARCHAR(150),
	"F_TABLE_SPACE" VARCHAR(150),
	"F_ORACLE_PARAM" CLOB,
	"F_CONNECTION_STR" CLOB,
	"F_TENANT_ID" VARCHAR(150),
	"F_DB_TYPE" VARCHAR(150)

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant_link IS '租户数据连接';
COMMENT ON COLUMN base_tenant_link."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant_link."F_FULL_NAME" IS '连接名称';
COMMENT ON COLUMN base_tenant_link."F_CONFIG_TYPE" IS '配置类型（0：主，1：从）';
COMMENT ON COLUMN base_tenant_link."F_HOST" IS '主机地址';
COMMENT ON COLUMN base_tenant_link."F_PORT" IS '端口';
COMMENT ON COLUMN base_tenant_link."F_USER_NAME" IS '用户';
COMMENT ON COLUMN base_tenant_link."F_PASSWORD" IS '密码';
COMMENT ON COLUMN base_tenant_link."F_SERVICE_NAME" IS '服务名称';
COMMENT ON COLUMN base_tenant_link."F_DESCRIPTION" IS '描述';
COMMENT ON COLUMN base_tenant_link."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant_link."F_ENABLED_MARK" IS '有效标志';
COMMENT ON COLUMN base_tenant_link."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant_link."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant_link."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant_link."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant_link."F_DELETE_MARK" IS '删除标志';
COMMENT ON COLUMN base_tenant_link."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant_link."F_DELETE_USER_ID" IS '删除用户';
COMMENT ON COLUMN base_tenant_link."F_DB_SCHEMA" IS '表模式';
COMMENT ON COLUMN base_tenant_link."F_TABLE_SPACE" IS '表空间';
COMMENT ON COLUMN base_tenant_link."F_ORACLE_PARAM" IS 'oracle参数';
COMMENT ON COLUMN base_tenant_link."F_CONNECTION_STR" IS '自定义连接语句';
COMMENT ON COLUMN base_tenant_link."F_TENANT_ID" IS '租户id';
COMMENT ON COLUMN base_tenant_link."F_DB_TYPE" IS '数据库类型';
-- ----------------------------
-- 表名：base_tenant_log
-- ----------------------------
CREATE TABLE base_tenant_log(
	"F_ID" VARCHAR(765) NOT NULL,
	"F_TENANT_ID" VARCHAR(150),
	"F_LOGIN_ACCOUNT" VARCHAR(150),
	"F_LOGIN_IP_ADDRESS" VARCHAR(150),
	"F_LOGIN_IP_ADDRESS_NAME" VARCHAR(150),
	"F_LOGIN_SOURCE_WEBSITE" VARCHAR(765),
	"F_LOGIN_TIME" TIMESTAMP,
	"F_DESCRIPTION" VARCHAR(1500),
	"F_SORT_CODE" BIGINT,
	"F_CREATOR_TIME" TIMESTAMP,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150)

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant_log IS '租户日志表';
COMMENT ON COLUMN base_tenant_log."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant_log."F_TENANT_ID" IS '租户主键';
COMMENT ON COLUMN base_tenant_log."F_LOGIN_ACCOUNT" IS '登录账户';
COMMENT ON COLUMN base_tenant_log."F_LOGIN_IP_ADDRESS" IS 'IP地址';
COMMENT ON COLUMN base_tenant_log."F_LOGIN_IP_ADDRESS_NAME" IS 'IP所在城市';
COMMENT ON COLUMN base_tenant_log."F_LOGIN_SOURCE_WEBSITE" IS '来源网站';
COMMENT ON COLUMN base_tenant_log."F_LOGIN_TIME" IS '登录时间';
COMMENT ON COLUMN base_tenant_log."F_DESCRIPTION" IS '描述';
COMMENT ON COLUMN base_tenant_log."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant_log."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant_log."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant_log."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant_log."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant_log."F_DELETE_MARK" IS '删除标志';
COMMENT ON COLUMN base_tenant_log."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant_log."F_DELETE_USER_ID" IS '删除用户';
-- ----------------------------
-- 表名：base_tenant_socials
-- ----------------------------
CREATE TABLE base_tenant_socials(
	"F_ID" VARCHAR(150) NOT NULL,
	"F_USER_ID" VARCHAR(150),
	"F_ACCOUNT" VARCHAR(150),
	"F_ACCOUNT_NAME" VARCHAR(765),
	"F_SOCIAL_TYPE" VARCHAR(150),
	"F_SOCIAL_ID" VARCHAR(300),
	"F_SOCIAL_NAME" VARCHAR(300),
	"F_TENANT_ID" VARCHAR(300),
	"F_DESCRIPTION" VARCHAR(300),
	"F_SORT_CODE" BIGINT,
	"F_CREATOR_USER_ID" VARCHAR(150),
	"F_CREATOR_TIME" TIMESTAMP,
	"F_LAST_MODIFY_TIME" TIMESTAMP,
	"F_LAST_MODIFY_USER_ID" VARCHAR(150),
	"F_DELETE_MARK" INT,
	"F_DELETE_TIME" TIMESTAMP,
	"F_DELETE_USER_ID" VARCHAR(150)

, PRIMARY KEY (f_id)
);
COMMENT ON TABLE base_tenant_socials IS '多租户第三方绑定表';
COMMENT ON COLUMN base_tenant_socials."F_ID" IS '自然主键';
COMMENT ON COLUMN base_tenant_socials."F_USER_ID" IS '用户id';
COMMENT ON COLUMN base_tenant_socials."F_ACCOUNT" IS '用户账号';
COMMENT ON COLUMN base_tenant_socials."F_ACCOUNT_NAME" IS '用户账号名称';
COMMENT ON COLUMN base_tenant_socials."F_SOCIAL_TYPE" IS '第三方类型';
COMMENT ON COLUMN base_tenant_socials."F_SOCIAL_ID" IS '第三方账号id';
COMMENT ON COLUMN base_tenant_socials."F_SOCIAL_NAME" IS '第三方账号';
COMMENT ON COLUMN base_tenant_socials."F_TENANT_ID" IS '租户id';
COMMENT ON COLUMN base_tenant_socials."F_DESCRIPTION" IS '备注';
COMMENT ON COLUMN base_tenant_socials."F_SORT_CODE" IS '排序';
COMMENT ON COLUMN base_tenant_socials."F_CREATOR_USER_ID" IS '创建用户';
COMMENT ON COLUMN base_tenant_socials."F_CREATOR_TIME" IS '创建时间';
COMMENT ON COLUMN base_tenant_socials."F_LAST_MODIFY_TIME" IS '修改时间';
COMMENT ON COLUMN base_tenant_socials."F_LAST_MODIFY_USER_ID" IS '修改用户';
COMMENT ON COLUMN base_tenant_socials."F_DELETE_MARK" IS '删除标记';
COMMENT ON COLUMN base_tenant_socials."F_DELETE_TIME" IS '删除时间';
COMMENT ON COLUMN base_tenant_socials."F_DELETE_USER_ID" IS '删除用户';
