CREATE TABLE LEADER_STATUS_TABLE (
    GROUP_ID VARCHAR2(512) NOT NULL,
    NODE_ID VARCHAR2(512) NOT NULL,
    LAST_HEARTBEAT NUMBER NOT NULL,
    PRIMARY KEY (GROUP_ID)
);

CREATE TABLE CLUSTER_NODE_STATUS_TABLE (
    GROUP_ID VARCHAR2(512) NOT NULL,
    NODE_ID VARCHAR2(512) NOT NULL,
    IS_NEW_NODE INT NOT NULL,
    LAST_HEARTBEAT NUMBER NOT NULL,
    PRIMARY KEY (GROUP_ID,NODE_ID)
);

CREATE TABLE  MEMBERSHIP_EVENT_TABLE (
  GROUP_ID VARCHAR (512) NOT NULL,
  NODE_ID VARCHAR (512) NOT NULL,
  CHANGE_TYPE INT NOT NULL,
  CHANGED_MEMBER_ID VARCHAR (512) NOT NULL
);

CREATE TABLE  REMOVED_MEMBERS_TABLE (
  GROUP_ID VARCHAR (512) NOT NULL,
  NODE_ID VARCHAR (512) NOT NULL,
  REMOVED_MEMBER_ID VARCHAR (512) NOT NULL
);

CREATE TABLE  COORDINATED_TASK_TABLE (
  TASK_NAME VARCHAR (512) NOT NULL,
  DESTINED_NODE_ID VARCHAR (512),
  TASK_STATE VARCHAR (32),
  PRIMARY KEY (TASK_NAME)
);

CREATE TABLE TASK_DELETE_GUARD (
    TASK_NAME VARCHAR2(512) NOT NULL,
    GUARD_UUID VARCHAR2(36) NOT NULL,
    UPDATED_AT NUMBER(19) NOT NULL,
    PRIMARY KEY (TASK_NAME)
);

CREATE TABLE TASK_DELETE_BARRIER (
    TASK_NAME VARCHAR2(512) NOT NULL,
    GUARD_UUID VARCHAR2(36) NOT NULL,
    OWNER_NODE_ID VARCHAR2(512) NOT NULL,
    STATUS VARCHAR2(16) NOT NULL,
    DEADLINE_AT NUMBER(19) NOT NULL,
    UPDATED_AT NUMBER(19) NOT NULL,
    PRIMARY KEY (TASK_NAME, GUARD_UUID)
);

CREATE TABLE TASK_DELETE_BARRIER_EXPECTED (
    TASK_NAME VARCHAR2(512) NOT NULL,
    GUARD_UUID VARCHAR2(36) NOT NULL,
    NODE_ID VARCHAR2(220) NOT NULL,
    PRIMARY KEY (TASK_NAME, GUARD_UUID, NODE_ID)
);

CREATE TABLE TASK_DELETE_BARRIER_ACK (
    TASK_NAME VARCHAR2(512) NOT NULL,
    GUARD_UUID VARCHAR2(36) NOT NULL,
    NODE_ID VARCHAR2(220) NOT NULL,
    ACKED_AT NUMBER(19) NOT NULL,
    PRIMARY KEY (TASK_NAME, GUARD_UUID, NODE_ID)
);
