-- CreateTable
CREATE TABLE `User` (
    `User_ID` INTEGER NOT NULL AUTO_INCREMENT,
    `Benutzername` VARCHAR(191) NOT NULL,
    `Passwort` VARCHAR(191) NOT NULL,

    UNIQUE INDEX `User_Benutzername_key`(`Benutzername`),
    PRIMARY KEY (`User_ID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Session` (
    `Session_ID` INTEGER NOT NULL AUTO_INCREMENT,
    `Einstellungs_JSON` JSON NOT NULL,
    `Date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `Admin_ID` INTEGER NOT NULL,

    PRIMARY KEY (`Session_ID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Idee` (
    `Idee_ID` INTEGER NOT NULL AUTO_INCREMENT,

    PRIMARY KEY (`Idee_ID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Zeichnungen` (
    `Zeichnung_ID` INTEGER NOT NULL AUTO_INCREMENT,
    `Runde` INTEGER NOT NULL,
    `Idee_ID` INTEGER NULL,

    PRIMARY KEY (`Zeichnung_ID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `Session` ADD CONSTRAINT `Session_Admin_ID_fkey` FOREIGN KEY (`Admin_ID`) REFERENCES `User`(`User_ID`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Zeichnungen` ADD CONSTRAINT `Zeichnungen_Idee_ID_fkey` FOREIGN KEY (`Idee_ID`) REFERENCES `Idee`(`Idee_ID`) ON DELETE SET NULL ON UPDATE CASCADE;
