CREATE TABLE IF NOT EXISTS LEADER_STATUS_TABLE (
  GROUP_ID VARCHAR (512) NOT NULL,
  NODE_ID VARCHAR (512) NOT NULL,
  LAST_HEARTBEAT BIGINT NOT NULL,
  PRIMARY KEY (GROUP_ID)
)ENGINE INNODB;

CREATE TABLE IF NOT EXISTS CLUSTER_NODE_STATUS_TABLE (
  GROUP_ID VARCHAR (512) NOT NULL,
  NODE_ID VARCHAR (512) NOT NULL,
  IS_NEW_NODE INT NOT NULL,
  LAST_HEARTBEAT BIGINT NOT NULL,
  PRIMARY KEY (GROUP_ID, NODE_ID)
)ENGINE INNODB;

CREATE TABLE IF NOT EXISTS 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
)ENGINE INNODB;

CREATE TABLE IF NOT EXISTS REMOVED_MEMBERS_TABLE (
  GROUP_ID VARCHAR (512) NOT NULL,
  NODE_ID VARCHAR (512) NOT NULL,
  REMOVED_MEMBER_ID VARCHAR (512) NOT NULL
)ENGINE INNODB;

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