-- DROP TABLE IF EXISTS T_KAKFA_USER;

-- kafka ACL启用SASL_SCRAM中的用户
CREATE TABLE IF NOT EXISTS T_KAFKA_USER
(
    ID              IDENTITY    NOT NULL COMMENT '主键ID',
    USERNAME        VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户名',
    PASSWORD        VARCHAR(50) NOT NULL DEFAULT '' COMMENT '密码',
    UPDATE_TIME     TIMESTAMP   NOT NULL DEFAULT NOW() COMMENT '更新时间',
    CLUSTER_INFO_ID BIGINT      NOT NULL COMMENT '集群信息里的集群ID',
    PRIMARY KEY (ID),
    UNIQUE (USERNAME)
);
-- 消息同步解决方案中使用的位点对齐信息
CREATE TABLE IF NOT EXISTS T_MIN_OFFSET_ALIGNMENT
(
    ID          IDENTITY     NOT NULL COMMENT '主键ID',
    GROUP_ID    VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'groupId',
    TOPIC       VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'topic',
    THAT_OFFSET VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'min offset for that kafka cluster',
    THIS_OFFSET VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'min offset for this kafka cluster',
    UPDATE_TIME TIMESTAMP    NOT NULL DEFAULT NOW() COMMENT '更新时间',
    PRIMARY KEY (ID),
    UNIQUE (GROUP_ID, TOPIC)
);

-- 多集群管理，每个集群的配置信息
CREATE TABLE IF NOT EXISTS T_CLUSTER_INFO
(
    ID           IDENTITY     NOT NULL COMMENT '主键ID',
    CLUSTER_NAME VARCHAR(128) NOT NULL DEFAULT '' COMMENT '集群名',
    ADDRESS      VARCHAR(256) NOT NULL DEFAULT '' COMMENT '集群地址',
    PROPERTIES   VARCHAR(512) NOT NULL DEFAULT '' COMMENT '集群的其它属性配置',
    UPDATE_TIME  TIMESTAMP    NOT NULL DEFAULT NOW() COMMENT '更新时间',
    PRIMARY KEY (ID),
    UNIQUE (CLUSTER_NAME)
);