/*
  Warnings:

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

*/
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "artikel";
PRAGMA foreign_keys=on;

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

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

-- CreateTable
CREATE TABLE "Kauf_Artikel" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "kauf_id" INTEGER NOT NULL,
    "artikel_id" INTEGER NOT NULL,
    "anzahl" INTEGER NOT NULL,
    CONSTRAINT "Kauf_Artikel_kauf_id_fkey" FOREIGN KEY ("kauf_id") REFERENCES "Kauf" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
    CONSTRAINT "Kauf_Artikel_artikel_id_fkey" FOREIGN KEY ("artikel_id") REFERENCES "Artikel" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);

-- CreateTable
CREATE TABLE "Artikel" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "name" TEXT NOT NULL,
    "preis" REAL
);

-- CreateTable
CREATE TABLE "Kauf" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "timestamp" INTEGER NOT NULL,
    "preis_ges" REAL
);

-- CreateIndex
CREATE UNIQUE INDEX "Artikel_name_key" ON "Artikel"("name");
