-- CreateTable
CREATE TABLE "Intervento" (
    "id" SERIAL NOT NULL,
    "id_registratore" INTEGER NOT NULL,
    "data" DATE NOT NULL,
    "lavoro" TEXT NOT NULL,
    "fattura" BOOLEAN NOT NULL,

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

-- CreateTable
CREATE TABLE "Registratore" (
    "id" SERIAL NOT NULL,
    "id_cliente" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "Cliente" (
    "id" SERIAL NOT NULL,
    "ragione_sociale" VARCHAR(255) NOT NULL,
    "email" VARCHAR(255) NOT NULL,
    "partita_iva" VARCHAR(255) NOT NULL,
    "telefono" VARCHAR(255) NOT NULL,
    "sede" VARCHAR(255) NOT NULL,
    "sede_url" VARCHAR(255) NOT NULL,
    "contratto" VARCHAR(255) NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Cliente_ragione_sociale_key" ON "Cliente"("ragione_sociale");

-- AddForeignKey
ALTER TABLE "Intervento" ADD CONSTRAINT "Intervento_id_registratore_fkey" FOREIGN KEY ("id_registratore") REFERENCES "Registratore"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Registratore" ADD CONSTRAINT "Registratore_id_cliente_fkey" FOREIGN KEY ("id_cliente") REFERENCES "Cliente"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
