-- CreateTable
CREATE TABLE "party_shares" (
    "id" VARCHAR(255) NOT NULL,
    "party_id" VARCHAR(255) NOT NULL,
    "session_id" VARCHAR(255) NOT NULL,
    "share_type" VARCHAR(20) NOT NULL,
    "share_data" TEXT NOT NULL,
    "public_key" TEXT NOT NULL,
    "threshold_n" INTEGER NOT NULL,
    "threshold_t" INTEGER NOT NULL,
    "status" VARCHAR(20) NOT NULL DEFAULT 'active',
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,
    "last_used_at" TIMESTAMP(3),

    CONSTRAINT "party_shares_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "signing_sessions" (
    "id" VARCHAR(255) NOT NULL,
    "party_id" VARCHAR(255) NOT NULL,
    "session_id" VARCHAR(255) NOT NULL,
    "message_hash" VARCHAR(255) NOT NULL,
    "signature" TEXT,
    "status" VARCHAR(20) NOT NULL DEFAULT 'pending',
    "error_message" TEXT,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,
    "completed_at" TIMESTAMP(3),

    CONSTRAINT "signing_sessions_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "party_shares_party_id_idx" ON "party_shares"("party_id");

-- CreateIndex
CREATE INDEX "party_shares_session_id_idx" ON "party_shares"("session_id");

-- CreateIndex
CREATE INDEX "party_shares_status_idx" ON "party_shares"("status");

-- CreateIndex
CREATE INDEX "signing_sessions_party_id_idx" ON "signing_sessions"("party_id");

-- CreateIndex
CREATE INDEX "signing_sessions_session_id_idx" ON "signing_sessions"("session_id");

-- CreateIndex
CREATE INDEX "signing_sessions_status_idx" ON "signing_sessions"("status");
