-- Baseline migration representing the schema already present in the database
-- before migration history was introduced (created via `prisma db push`).
CREATE TABLE "gruppo_scout" (
    "org_id" TEXT NOT NULL,
    "nome" TEXT NOT NULL,
    "regione" TEXT,
    "data_creazione" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "gruppo_scout_pkey" PRIMARY KEY ("org_id")
);

CREATE TABLE "invito" (
    "id" TEXT NOT NULL,
    "token" TEXT NOT NULL,
    "email" TEXT NOT NULL,
    "org_id" TEXT NOT NULL,
    "ruolo" TEXT NOT NULL,
    "scadenza" TIMESTAMP(3) NOT NULL,
    "stato" TEXT NOT NULL,

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

CREATE UNIQUE INDEX "invito_token_key" ON "invito"("token");

ALTER TABLE "invito" ADD CONSTRAINT "invito_org_id_fkey" FOREIGN KEY ("org_id") REFERENCES "gruppo_scout"("org_id") ON DELETE RESTRICT ON UPDATE CASCADE;
