-- Schema: spider__voter_1
CREATE SCHEMA IF NOT EXISTS "spider__voter_1";

-- Table: AREA_CODE_STATE
CREATE TABLE "spider__voter_1"."AREA_CODE_STATE" (
    "area_code" BIGINT NOT NULL,
    "state" TEXT NOT NULL,
    CONSTRAINT "AREA_CODE_STATE_pkey" PRIMARY KEY ("area_code")
);

-- Table: CONTESTANTS
CREATE TABLE "spider__voter_1"."CONTESTANTS" (
    "contestant_number" BIGINT NOT NULL,
    "contestant_name" TEXT NOT NULL,
    CONSTRAINT "CONTESTANTS_pkey" PRIMARY KEY ("contestant_number")
);

-- Table: VOTES
CREATE TABLE "spider__voter_1"."VOTES" (
    "vote_id" BIGINT NOT NULL,
    "phone_number" BIGINT NOT NULL,
    "state" TEXT NOT NULL,
    "contestant_number" BIGINT NOT NULL,
    "created" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT "VOTES_pkey" PRIMARY KEY ("vote_id")
);

-- Foreign Keys
ALTER TABLE "spider__voter_1"."VOTES" ADD CONSTRAINT "fk_VOTES_0" FOREIGN KEY ("contestant_number") REFERENCES "spider__voter_1"."CONTESTANTS" ("contestant_number") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Indexes
CREATE INDEX "idx_VOTES_idx_votes_phone_number" ON "spider__voter_1"."VOTES" ("phone_number");
