-- ----------------------------
-- 表名：config_info
-- ----------------------------
CREATE TABLE config_info(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384),
	"CONTENT" CLOB NOT NULL,
	"MD5" VARCHAR(96),
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"SRC_USER" CLOB,
	"SRC_IP" VARCHAR(60),
	"APP_NAME" VARCHAR(384),
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"C_DESC" VARCHAR(768),
	"C_USE" VARCHAR(192),
	"EFFECT" VARCHAR(192),
	"TYPE" VARCHAR(192),
	"C_SCHEMA" CLOB,
	"ENCRYPTED_DATA_KEY" CLOB NOT NULL
);
COMMENT ON TABLE config_info IS 'config_info';
COMMENT ON COLUMN config_info."ID" IS 'id';
COMMENT ON COLUMN config_info."DATA_ID" IS 'data_id';
COMMENT ON COLUMN config_info."GROUP_ID" IS '';
COMMENT ON COLUMN config_info."CONTENT" IS 'content';
COMMENT ON COLUMN config_info."MD5" IS 'md5';
COMMENT ON COLUMN config_info."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN config_info."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN config_info."SRC_USER" IS 'source user';
COMMENT ON COLUMN config_info."SRC_IP" IS 'source ip';
COMMENT ON COLUMN config_info."APP_NAME" IS '';
COMMENT ON COLUMN config_info."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN config_info."C_DESC" IS '';
COMMENT ON COLUMN config_info."C_USE" IS '';
COMMENT ON COLUMN config_info."EFFECT" IS '';
COMMENT ON COLUMN config_info."TYPE" IS '';
COMMENT ON COLUMN config_info."C_SCHEMA" IS '';
COMMENT ON COLUMN config_info."ENCRYPTED_DATA_KEY" IS '秘钥';

SET IDENTITY_INSERT config_info ON;

-- ----------------------------
-- 表名：config_info
-- ----------------------------
-- ----------------------------
-- 表名：branch_table
-- ----------------------------
-- ----------------------------
-- 表名：config_info
-- ----------------------------
-- ----------------------------
-- 表名：config_info_aggr
-- ----------------------------
CREATE TABLE config_info_aggr(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384) NOT NULL,
	"DATUM_ID" VARCHAR(765) NOT NULL,
	"CONTENT" CLOB NOT NULL,
	"GMT_MODIFIED" DATETIME NOT NULL,
	"APP_NAME" VARCHAR(384),
	"TENANT_ID" VARCHAR(384) DEFAULT ''
);
COMMENT ON TABLE config_info_aggr IS '增加租户字段';
COMMENT ON COLUMN config_info_aggr."ID" IS 'id';
COMMENT ON COLUMN config_info_aggr."DATA_ID" IS 'data_id';
COMMENT ON COLUMN config_info_aggr."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN config_info_aggr."DATUM_ID" IS 'datum_id';
COMMENT ON COLUMN config_info_aggr."CONTENT" IS '内容';
COMMENT ON COLUMN config_info_aggr."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN config_info_aggr."APP_NAME" IS '';
COMMENT ON COLUMN config_info_aggr."TENANT_ID" IS '租户字段';
SET IDENTITY_INSERT config_info_aggr ON;
-- ----------------------------
-- 表名：config_info_beta
-- ----------------------------
CREATE TABLE config_info_beta(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384) NOT NULL,
	"APP_NAME" VARCHAR(384),
	"CONTENT" CLOB NOT NULL,
	"BETA_IPS" VARCHAR(3072),
	"MD5" VARCHAR(96),
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"SRC_USER" CLOB,
	"SRC_IP" VARCHAR(60),
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"ENCRYPTED_DATA_KEY" CLOB NOT NULL
);
COMMENT ON TABLE config_info_beta IS 'config_info_beta';
COMMENT ON COLUMN config_info_beta."ID" IS 'id';
COMMENT ON COLUMN config_info_beta."DATA_ID" IS 'data_id';
COMMENT ON COLUMN config_info_beta."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN config_info_beta."APP_NAME" IS 'app_name';
COMMENT ON COLUMN config_info_beta."CONTENT" IS 'content';
COMMENT ON COLUMN config_info_beta."BETA_IPS" IS 'betaIps';
COMMENT ON COLUMN config_info_beta."MD5" IS 'md5';
COMMENT ON COLUMN config_info_beta."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN config_info_beta."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN config_info_beta."SRC_USER" IS 'source user';
COMMENT ON COLUMN config_info_beta."SRC_IP" IS 'source ip';
COMMENT ON COLUMN config_info_beta."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN config_info_beta."ENCRYPTED_DATA_KEY" IS '秘钥';
SET IDENTITY_INSERT config_info_beta ON;
-- ----------------------------
-- 表名：config_info_tag
-- ----------------------------
CREATE TABLE config_info_tag(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384) NOT NULL,
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"TAG_ID" VARCHAR(384) NOT NULL,
	"APP_NAME" VARCHAR(384),
	"CONTENT" CLOB NOT NULL,
	"MD5" VARCHAR(96),
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"SRC_USER" CLOB,
	"SRC_IP" VARCHAR(60)
);
COMMENT ON TABLE config_info_tag IS 'config_info_tag';
COMMENT ON COLUMN config_info_tag."ID" IS 'id';
COMMENT ON COLUMN config_info_tag."DATA_ID" IS 'data_id';
COMMENT ON COLUMN config_info_tag."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN config_info_tag."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN config_info_tag."TAG_ID" IS 'tag_id';
COMMENT ON COLUMN config_info_tag."APP_NAME" IS 'app_name';
COMMENT ON COLUMN config_info_tag."CONTENT" IS 'content';
COMMENT ON COLUMN config_info_tag."MD5" IS 'md5';
COMMENT ON COLUMN config_info_tag."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN config_info_tag."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN config_info_tag."SRC_USER" IS 'source user';
COMMENT ON COLUMN config_info_tag."SRC_IP" IS 'source ip';
SET IDENTITY_INSERT config_info_tag ON;
-- ----------------------------
-- 表名：config_tags_relation
-- ----------------------------
CREATE TABLE config_tags_relation(
	"ID" BIGINT NOT NULL,
	"TAG_NAME" VARCHAR(384) NOT NULL,
	"TAG_TYPE" VARCHAR(192),
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384) NOT NULL,
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"NID" BIGINT IDENTITY(1, 1) PRIMARY KEY
);
COMMENT ON TABLE config_tags_relation IS 'config_tag_relation';
COMMENT ON COLUMN config_tags_relation."ID" IS 'id';
COMMENT ON COLUMN config_tags_relation."TAG_NAME" IS 'tag_name';
COMMENT ON COLUMN config_tags_relation."TAG_TYPE" IS 'tag_type';
COMMENT ON COLUMN config_tags_relation."DATA_ID" IS 'data_id';
COMMENT ON COLUMN config_tags_relation."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN config_tags_relation."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN config_tags_relation."NID" IS '';
SET IDENTITY_INSERT config_tags_relation ON;
-- ----------------------------
-- 表名：group_capacity
-- ----------------------------
CREATE TABLE group_capacity(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"GROUP_ID" VARCHAR(384) NOT NULL DEFAULT '',
	"QUOTA" INT NOT NULL DEFAULT '0',
	"USAGE" INT NOT NULL DEFAULT '0',
	"MAX_SIZE" INT NOT NULL DEFAULT '0',
	"MAX_AGGR_COUNT" INT NOT NULL DEFAULT '0',
	"MAX_AGGR_SIZE" INT NOT NULL DEFAULT '0',
	"MAX_HISTORY_COUNT" INT NOT NULL DEFAULT '0',
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00'
);
COMMENT ON TABLE group_capacity IS '集群、各Group容量信息表';
COMMENT ON COLUMN group_capacity."ID" IS '主键ID';
COMMENT ON COLUMN group_capacity."GROUP_ID" IS 'Group ID，空字符表示整个集群';
COMMENT ON COLUMN group_capacity."QUOTA" IS '配额，0表示使用默认值';
COMMENT ON COLUMN group_capacity."USAGE" IS '使用量';
COMMENT ON COLUMN group_capacity."MAX_SIZE" IS '单个配置大小上限，单位为字节，0表示使用默认值';
COMMENT ON COLUMN group_capacity."MAX_AGGR_COUNT" IS '聚合子配置最大个数，，0表示使用默认值';
COMMENT ON COLUMN group_capacity."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值';
COMMENT ON COLUMN group_capacity."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN group_capacity."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN group_capacity."GMT_MODIFIED" IS '修改时间';
SET IDENTITY_INSERT group_capacity ON;
-- ----------------------------
-- 表名：his_config_info
-- ----------------------------
CREATE TABLE his_config_info(
	"ID" BIGINT NOT NULL,
	"NID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"DATA_ID" VARCHAR(765) NOT NULL,
	"GROUP_ID" VARCHAR(384) NOT NULL,
	"APP_NAME" VARCHAR(384),
	"CONTENT" CLOB NOT NULL,
	"MD5" VARCHAR(96),
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"SRC_USER" CLOB,
	"SRC_IP" VARCHAR(60),
	"OP_TYPE" CHAR(10),
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"ENCRYPTED_DATA_KEY" CLOB NOT NULL
);
COMMENT ON TABLE his_config_info IS '多租户改造';
COMMENT ON COLUMN his_config_info."ID" IS '';
COMMENT ON COLUMN his_config_info."NID" IS '';
COMMENT ON COLUMN his_config_info."DATA_ID" IS '';
COMMENT ON COLUMN his_config_info."GROUP_ID" IS '';
COMMENT ON COLUMN his_config_info."APP_NAME" IS 'app_name';
COMMENT ON COLUMN his_config_info."CONTENT" IS '';
COMMENT ON COLUMN his_config_info."MD5" IS '';
COMMENT ON COLUMN his_config_info."GMT_CREATE" IS '';
COMMENT ON COLUMN his_config_info."GMT_MODIFIED" IS '';
COMMENT ON COLUMN his_config_info."SRC_USER" IS '';
COMMENT ON COLUMN his_config_info."SRC_IP" IS '';
COMMENT ON COLUMN his_config_info."OP_TYPE" IS '';
COMMENT ON COLUMN his_config_info."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN his_config_info."ENCRYPTED_DATA_KEY" IS '秘钥';
SET IDENTITY_INSERT his_config_info ON;
-- ----------------------------
-- 表名：permissions
-- ----------------------------
CREATE TABLE permissions(
	"ROLE" VARCHAR(150) NOT NULL,
	"RESOURCE" VARCHAR(1536) NOT NULL,
	"ACTION" VARCHAR(24) NOT NULL
);
COMMENT ON TABLE permissions IS '';
COMMENT ON COLUMN permissions."ROLE" IS '';
COMMENT ON COLUMN permissions."RESOURCE" IS '';
COMMENT ON COLUMN permissions."ACTION" IS '';
-- ----------------------------
-- 表名：roles
-- ----------------------------
CREATE TABLE roles(
	"USERNAME" VARCHAR(150) NOT NULL,
	"ROLE" VARCHAR(150) NOT NULL
);
COMMENT ON TABLE roles IS '';
COMMENT ON COLUMN roles."USERNAME" IS '';
COMMENT ON COLUMN roles."ROLE" IS '';
DELETE FROM roles;
INSERT INTO roles ("ROLE","USERNAME") VALUES ('ROLE_ADMIN','nacos');
-- ----------------------------
-- 表名：tenant_capacity
-- ----------------------------
CREATE TABLE tenant_capacity(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"TENANT_ID" VARCHAR(384) NOT NULL DEFAULT '',
	"QUOTA" INT NOT NULL DEFAULT '0',
	"USAGE" INT NOT NULL DEFAULT '0',
	"MAX_SIZE" INT NOT NULL DEFAULT '0',
	"MAX_AGGR_COUNT" INT NOT NULL DEFAULT '0',
	"MAX_AGGR_SIZE" INT NOT NULL DEFAULT '0',
	"MAX_HISTORY_COUNT" INT NOT NULL DEFAULT '0',
	"GMT_CREATE" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00',
	"GMT_MODIFIED" DATETIME NOT NULL DEFAULT '2010-05-05 00:00:00'
);
COMMENT ON TABLE tenant_capacity IS '租户容量信息表';
COMMENT ON COLUMN tenant_capacity."ID" IS '主键ID';
COMMENT ON COLUMN tenant_capacity."TENANT_ID" IS 'Tenant ID';
COMMENT ON COLUMN tenant_capacity."QUOTA" IS '配额，0表示使用默认值';
COMMENT ON COLUMN tenant_capacity."USAGE" IS '使用量';
COMMENT ON COLUMN tenant_capacity."MAX_SIZE" IS '单个配置大小上限，单位为字节，0表示使用默认值';
COMMENT ON COLUMN tenant_capacity."MAX_AGGR_COUNT" IS '聚合子配置最大个数';
COMMENT ON COLUMN tenant_capacity."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值';
COMMENT ON COLUMN tenant_capacity."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN tenant_capacity."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN tenant_capacity."GMT_MODIFIED" IS '修改时间';
SET IDENTITY_INSERT tenant_capacity ON;
-- ----------------------------
-- 表名：tenant_info
-- ----------------------------
CREATE TABLE tenant_info(
	"ID" BIGINT IDENTITY(1, 1) PRIMARY KEY,
	"KP" VARCHAR(384) NOT NULL,
	"TENANT_ID" VARCHAR(384) DEFAULT '',
	"TENANT_NAME" VARCHAR(384) DEFAULT '',
	"TENANT_DESC" VARCHAR(768),
	"CREATE_SOURCE" VARCHAR(96),
	"GMT_CREATE" BIGINT NOT NULL,
	"GMT_MODIFIED" BIGINT NOT NULL
);
COMMENT ON TABLE tenant_info IS 'tenant_info';
COMMENT ON COLUMN tenant_info."ID" IS 'id';
COMMENT ON COLUMN tenant_info."KP" IS 'kp';
COMMENT ON COLUMN tenant_info."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN tenant_info."TENANT_NAME" IS 'tenant_name';
COMMENT ON COLUMN tenant_info."TENANT_DESC" IS 'tenant_desc';
COMMENT ON COLUMN tenant_info."CREATE_SOURCE" IS 'create_source';
COMMENT ON COLUMN tenant_info."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN tenant_info."GMT_MODIFIED" IS '修改时间';
SET IDENTITY_INSERT tenant_info ON;
INSERT INTO tenant_info ("TENANT_DESC","GMT_CREATE","KP","TENANT_NAME","GMT_MODIFIED","TENANT_ID","CREATE_SOURCE","ID") VALUES ('开发环境',1683377008569,'1','develop',1683377008569,'69c4eecb-05bd-4041-81fe-1473f95f578c','nacos',1);
INSERT INTO tenant_info ("TENANT_DESC","GMT_CREATE","KP","TENANT_NAME","GMT_MODIFIED","TENANT_ID","CREATE_SOURCE","ID") VALUES ('测试环境',1683377016283,'1','staging',1683377016283,'1e017954-eb52-4d21-a843-0286d9013cf3','nacos',2);
INSERT INTO tenant_info ("TENANT_DESC","GMT_CREATE","KP","TENANT_NAME","GMT_MODIFIED","TENANT_ID","CREATE_SOURCE","ID") VALUES ('预发环境',1683377025641,'1','pre',1683377025641,'f50f4948-3ca2-48af-8bb1-1a47950b503d','nacos',3);
INSERT INTO tenant_info ("TENANT_DESC","GMT_CREATE","KP","TENANT_NAME","GMT_MODIFIED","TENANT_ID","CREATE_SOURCE","ID") VALUES ('生产环境',1683377034418,'1','production',1683377034418,'3baec428-9669-486c-b359-a76f7a1f1ac7','nacos',4);

-- ----------------------------
-- 表名：users
-- ----------------------------
CREATE TABLE users(
	"USERNAME" VARCHAR(150) NOT NULL PRIMARY KEY,
	"PASSWORD" VARCHAR(1500) NOT NULL,
	"ENABLED" VARCHAR(45) NOT NULL
);
COMMENT ON TABLE users IS '';
COMMENT ON COLUMN users."USERNAME" IS '';
COMMENT ON COLUMN users."PASSWORD" IS '';
COMMENT ON COLUMN users."ENABLED" IS '';
DELETE FROM users;
INSERT INTO users ("PASSWORD","ENABLED","USERNAME") VALUES ('$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu','true','nacos');

-- 唯一索引
CREATE UNIQUE INDEX uk_configinfo_datagrouptenant ON config_info(data_id,group_id,tenant_id);
CREATE UNIQUE INDEX uk_configinfoaggr_datagrouptenantdatum ON config_info_aggr(data_id,group_id,tenant_id,datum_id);
CREATE UNIQUE INDEX uk_configinfobeta_datagrouptenant ON config_info_beta(data_id,group_id,tenant_id);
CREATE UNIQUE INDEX uk_configinfotag_datagrouptenanttag ON config_info_tag(data_id,group_id,tenant_id,tag_id);
CREATE UNIQUE INDEX uk_configtagrelation_configidtag ON config_tags_relation(id,tag_name,tag_type);
CREATE UNIQUE INDEX uk_group_id ON group_capacity(group_id);
CREATE UNIQUE INDEX uk_role_permission ON permissions(role,resource,action);
CREATE UNIQUE INDEX uk_username_role ON roles(username,role);
CREATE UNIQUE INDEX uk_tenant_id ON tenant_capacity(tenant_id);
CREATE UNIQUE INDEX uk_tenant_info_kptenantid ON tenant_info(kp,tenant_id);


CREATE TABLE "GLOBAL_TABLE"
(
    "XID"                       VARCHAR2(128) NOT NULL,
    "TRANSACTION_ID"            BIGINT,
    "STATUS"                    TINYINT       NOT NULL,
    "APPLICATION_ID"            VARCHAR2(32),
    "TRANSACTION_SERVICE_GROUP" VARCHAR2(32),
    "TRANSACTION_NAME"          VARCHAR2(128),
    "TIMEOUT"                   INT,
    "BEGIN_TIME"                BIGINT,
    "APPLICATION_DATA"          VARCHAR2(2000),
    "GMT_CREATE"                TIMESTAMP(0),
    "GMT_MODIFIED"              TIMESTAMP(0),
    PRIMARY KEY ("XID")
);

CREATE  INDEX "IDX_GMT_MODIFIED_STATUS" ON "GLOBAL_TABLE"("GMT_MODIFIED" ASC,"STATUS" ASC);
CREATE  INDEX "IDX_TRANSACTION_ID" ON "GLOBAL_TABLE"("TRANSACTION_ID" ASC);


-- the table to store BranchSession data
CREATE TABLE "BRANCH_TABLE"
(
    "BRANCH_ID"         BIGINT        NOT NULL,
    "XID"               VARCHAR2(128) NOT NULL,
    "TRANSACTION_ID"    BIGINT,
    "RESOURCE_GROUP_ID" VARCHAR2(32),
    "RESOURCE_ID"       VARCHAR2(256),
    "BRANCH_TYPE"       VARCHAR2(8),
    "STATUS"            TINYINT,
    "CLIENT_ID"         VARCHAR2(64),
    "APPLICATION_DATA"  VARCHAR2(2000),
    "GMT_CREATE" TIMESTAMP(0),
    "GMT_MODIFIED" TIMESTAMP(0),
    PRIMARY KEY ("BRANCH_ID")
);

CREATE INDEX "IDX_XID" ON "BRANCH_TABLE"("XID" ASC);


-- the table to store lock data
CREATE TABLE "LOCK_TABLE"
(
    "ROW_KEY"        VARCHAR2(128) NOT NULL,
    "XID"            VARCHAR2(128),
    "TRANSACTION_ID" BIGINT,
    "BRANCH_ID"      BIGINT        NOT NULL,
    "RESOURCE_ID"    VARCHAR2(256),
    "TABLE_NAME"     VARCHAR2(32),
    "PK"             VARCHAR2(128),
    "STATUS"         TINYINT       NOT NULL DEFAULT 0,
    "GMT_CREATE"     TIMESTAMP(0),
    "GMT_MODIFIED"   TIMESTAMP(0),
    PRIMARY KEY ("ROW_KEY")
);

COMMENT ON COLUMN "LOCK_TABLE"."STATUS" IS '0:locked ,1:rollbacking';

CREATE INDEX "IDX_BRANCH_ID" ON "LOCK_TABLE" ("BRANCH_ID" ASC);
CREATE INDEX "IDX_STATUS" ON "LOCK_TABLE" ("STATUS" ASC);

CREATE TABLE "DISTRIBUTED_LOCK"
(
    "LOCK_KEY"   VARCHAR2(20) NOT NULL,
    "LOCK_VALUE" VARCHAR2(20) NOT NULL,
    "EXPIRE"     BIGINT       NOT NULL,
    PRIMARY KEY ("LOCK_KEY")
);

INSERT INTO "DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO "DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryCommitting', ' ', 0);
INSERT INTO "DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO "DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('TxTimeoutCheck', ' ', 0);


CREATE TABLE "VGROUP_TABLE"
(
    "VGROUP"    VARCHAR2(255),
    "NAMESPACE" VARCHAR2(255),
    "CLUSTER"   VARCHAR2(255),
    PRIMARY KEY ("VGROUP")
);