/*
  Warnings:

  - You are about to drop the `Anmeldung` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropIndex
DROP INDEX "Anmeldung_email_key";

-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "Anmeldung";
PRAGMA foreign_keys=on;

-- CreateTable
CREATE TABLE "anmeldungen" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "anrede" TEXT NOT NULL,
    "vorname" TEXT NOT NULL,
    "nachname" TEXT NOT NULL,
    "email" TEXT NOT NULL,
    "noteDeutsch" TEXT,
    "noteMathe" TEXT,
    "sozialverhalten" TEXT,
    "status" TEXT NOT NULL DEFAULT 'OFFEN',
    "zugewiesenId" INTEGER,
    "wunsch1Id" INTEGER,
    "wunsch2Id" INTEGER,
    "wunsch3Id" INTEGER,
    "timestamp" BIGINT NOT NULL,
    CONSTRAINT "anmeldungen_zugewiesenId_fkey" FOREIGN KEY ("zugewiesenId") REFERENCES "Dienststelle" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
    CONSTRAINT "anmeldungen_wunsch1Id_fkey" FOREIGN KEY ("wunsch1Id") REFERENCES "Dienststelle" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
    CONSTRAINT "anmeldungen_wunsch2Id_fkey" FOREIGN KEY ("wunsch2Id") REFERENCES "Dienststelle" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
    CONSTRAINT "anmeldungen_wunsch3Id_fkey" FOREIGN KEY ("wunsch3Id") REFERENCES "Dienststelle" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);

-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_PdfDatei" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "pfad" TEXT NOT NULL,
    "anmeldungId" INTEGER NOT NULL,
    CONSTRAINT "PdfDatei_anmeldungId_fkey" FOREIGN KEY ("anmeldungId") REFERENCES "anmeldungen" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_PdfDatei" ("anmeldungId", "id", "pfad") SELECT "anmeldungId", "id", "pfad" FROM "PdfDatei";
DROP TABLE "PdfDatei";
ALTER TABLE "new_PdfDatei" RENAME TO "PdfDatei";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
