--
-- The results of mixing and decrypting per node
--

CREATE SEQUENCE  "MIXDEC_BALLOT_BOX_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE;

CREATE TABLE "MIXDEC_BALLOT_BOX" (
  "ID" NUMBER(11,0) PRIMARY KEY NOT NULL,
  "TENANT_ID" VARCHAR2(100 CHAR) NOT NULL,
  "ELECTION_EVENT_ID" VARCHAR2(100 CHAR) NOT NULL,
  "BALLOT_BOX_ID" VARCHAR2(100 CHAR) NOT NULL,
  "VOTE" CLOB
);

CREATE INDEX "MIX_DEC_BALLOT_BOX_SAME_BB_IDX" ON "MIXDEC_BALLOT_BOX" ("TENANT_ID", "ELECTION_EVENT_ID", "BALLOT_BOX_ID");

CREATE SEQUENCE  "MIXDEC_BALLOT_BOX_STATUS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE ;
CREATE TABLE "MIXDEC_BALLOT_BOX_STATUS" (
  "ID" NUMBER(11,0),
  "TENANT_ID" VARCHAR2(100 CHAR) NOT NULL,
  "ELECTION_EVENT_ID" VARCHAR2(100 CHAR) NOT NULL,
  "BALLOT_BOX_ID" VARCHAR2(100 CHAR) NOT NULL,
  "STATUS" VARCHAR2(10 CHAR) NOT NULL,
  "ERROR_MESSAGE" VARCHAR2(150 CHAR),

  PRIMARY KEY ("ID"),
  CONSTRAINT "UNIQUE_BALLOT_BOX_STATUS" UNIQUE ("TENANT_ID", "ELECTION_EVENT_ID", "BALLOT_BOX_ID")
);
