Init DB and Tests with Components

- add Artikel, Kauf, Kategorie Model
- generate Components
- playing with custom components
- add Tailwindcss
This commit is contained in:
Simon Zeyer
2023-11-05 21:35:01 +00:00
parent 7d40cbd7d5
commit 9a26d97209
76 changed files with 3308 additions and 32 deletions
@@ -0,0 +1,24 @@
-- 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
);
-- 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
);
-- CreateIndex
CREATE UNIQUE INDEX "artikel_name_key" ON "artikel"("name");
@@ -0,0 +1,49 @@
/*
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");
@@ -0,0 +1,47 @@
/*
Warnings:
- 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 "Kauf_Artikel";
PRAGMA foreign_keys=on;
-- CreateTable
CREATE TABLE "KaufArtikel" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"kauf_id" INTEGER NOT NULL,
"artikel_id" INTEGER NOT NULL,
"anzahl" INTEGER NOT NULL,
CONSTRAINT "KaufArtikel_kauf_id_fkey" FOREIGN KEY ("kauf_id") REFERENCES "Kauf" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "KaufArtikel_artikel_id_fkey" FOREIGN KEY ("artikel_id") REFERENCES "Artikel" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Kategorie" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"timestamp" INTEGER NOT NULL,
"preis_ges" REAL
);
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Artikel" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"preis" REAL,
"kategorie_id" INTEGER,
CONSTRAINT "Artikel_kategorie_id_fkey" FOREIGN KEY ("kategorie_id") REFERENCES "Kategorie" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Artikel" ("id", "name", "preis") SELECT "id", "name", "preis" FROM "Artikel";
DROP TABLE "Artikel";
ALTER TABLE "new_Artikel" RENAME TO "Artikel";
CREATE UNIQUE INDEX "Artikel_name_key" ON "Artikel"("name");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
-- CreateIndex
CREATE UNIQUE INDEX "Kategorie_name_key" ON "Kategorie"("name");
+3
View File
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
+30 -6
View File
@@ -9,10 +9,34 @@ generator client {
}
// Define your own datamodels here and run `yarn redwood prisma migrate dev`
// to create migrations for them and apply to your dev DB.
// TODO: Please remove the following example:
model UserExample {
id Int @id @default(autoincrement())
email String @unique
name String?
model KaufArtikel {
id Int @id @default(autoincrement())
kauf Kauf @relation(fields: [kauf_id], references: [id])
kauf_id Int
artikel Artikel @relation(fields: [artikel_id], references: [id])
artikel_id Int
anzahl Int
}
model Artikel {
id Int @id @default(autoincrement())
name String @unique
preis Float?
kategorie Kategorie? @relation(fields: [kategorie_id], references: [id])
kategorie_id Int?
kaeufe KaufArtikel[]
}
model Kategorie {
id Int @id @default(autoincrement())
name String @unique
artikel Artikel[]
}
model Kauf {
id Int @id @default(autoincrement())
timestamp DateTime @default(now())
preis_ges Float?
artikel KaufArtikel[]
}