prisma schema update

This commit is contained in:
Bruno Sienkiewicz 2024-05-19 17:30:30 +02:00
parent 6be6253db2
commit a0316edce7
3 changed files with 117 additions and 24 deletions

View File

@ -0,0 +1,33 @@
/*
Warnings:
- A unique constraint covering the columns `[zamowienieId]` on the table `Zamowione_danie` will be added. If there are existing duplicate values, this will fail.
- Added the required column `zamowienieId` to the `Zamowione_danie` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Zamowione_danie" ADD COLUMN "zamowienieId" INTEGER NOT NULL;
-- CreateTable
CREATE TABLE "_DanieZamowione_danie" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "_DanieZamowione_danie_AB_unique" ON "_DanieZamowione_danie"("A", "B");
-- CreateIndex
CREATE INDEX "_DanieZamowione_danie_B_index" ON "_DanieZamowione_danie"("B");
-- CreateIndex
CREATE UNIQUE INDEX "Zamowione_danie_zamowienieId_key" ON "Zamowione_danie"("zamowienieId");
-- AddForeignKey
ALTER TABLE "Zamowione_danie" ADD CONSTRAINT "Zamowione_danie_zamowienieId_fkey" FOREIGN KEY ("zamowienieId") REFERENCES "Zamowienie"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DanieZamowione_danie" ADD CONSTRAINT "_DanieZamowione_danie_A_fkey" FOREIGN KEY ("A") REFERENCES "Danie"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DanieZamowione_danie" ADD CONSTRAINT "_DanieZamowione_danie_B_fkey" FOREIGN KEY ("B") REFERENCES "Zamowione_danie"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,43 @@
/*
Warnings:
- You are about to drop the `Recencja` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[Historia_zamowienId]` on the table `Uzytkownik` will be added. If there are existing duplicate values, this will fail.
- Added the required column `Historia_zamowienId` to the `Uzytkownik` table without a default value. This is not possible if the table is not empty.
- Added the required column `restauracjaId` to the `Znizka` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Uzytkownik" ADD COLUMN "Historia_zamowienId" INTEGER NOT NULL;
-- AlterTable
ALTER TABLE "Znizka" ADD COLUMN "restauracjaId" INTEGER NOT NULL;
-- DropTable
DROP TABLE "Recencja";
-- CreateTable
CREATE TABLE "Recenzja" (
"id" SERIAL NOT NULL,
"tekst" TEXT NOT NULL,
"wartosc" INTEGER NOT NULL,
"restauracjaId" INTEGER NOT NULL,
"uzytkownikId" INTEGER NOT NULL,
CONSTRAINT "Recenzja_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Uzytkownik_Historia_zamowienId_key" ON "Uzytkownik"("Historia_zamowienId");
-- AddForeignKey
ALTER TABLE "Recenzja" ADD CONSTRAINT "Recenzja_restauracjaId_fkey" FOREIGN KEY ("restauracjaId") REFERENCES "Restauracja"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Recenzja" ADD CONSTRAINT "Recenzja_uzytkownikId_fkey" FOREIGN KEY ("uzytkownikId") REFERENCES "Uzytkownik"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Uzytkownik" ADD CONSTRAINT "Uzytkownik_Historia_zamowienId_fkey" FOREIGN KEY ("Historia_zamowienId") REFERENCES "Historia_zamowien"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Znizka" ADD CONSTRAINT "Znizka_restauracjaId_fkey" FOREIGN KEY ("restauracjaId") REFERENCES "Restauracja"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -8,47 +8,64 @@ datasource db {
}
model Restauracja {
id Int @id @default(autoincrement())
adres String
id Int @id @default(autoincrement())
adres String
znizkas Znizka[] @relation("RestauracjaZnizka")
recenzjas Recenzja[] @relation("RestauracjaRecenzja")
}
model Recencja {
id Int @id @default(autoincrement())
tekst String
wartosc Int
model Recenzja {
id Int @id @default(autoincrement())
tekst String
wartosc Int
restauracjaId Int
uzytkownikId Int
restauracja Restauracja @relation("RestauracjaRecenzja", fields: [restauracjaId], references: [id])
uzytkownik Uzytkownik @relation("UzytkownikRecenzja", fields: [uzytkownikId], references: [id])
}
model Uzytkownik {
id Int @id @default(autoincrement())
imie String
nazwisko String
adres String
id Int @id @default(autoincrement())
imie String
nazwisko String
adres String
Historia_zamowienId Int @unique
recenzjas Recenzja[] @relation("UzytkownikRecenzja")
historia_zamowien Historia_zamowien @relation("HistoriaRelation", fields: [Historia_zamowienId], references: [id])
}
model Historia_zamowien {
id Int @id @default(autoincrement())
data_zamowienia DateTime
id Int @id @default(autoincrement())
data_zamowienia DateTime
HistoriaUzytkownik Uzytkownik? @relation("HistoriaRelation")
}
model Danie {
id Int @id @default(autoincrement())
cena Int
kategoria String
nazwa String
id Int @id @default(autoincrement())
cena Int
kategoria String
nazwa String
zamowioneDanias Zamowione_danie[] @relation("DanieZamowione_danie")
}
model Zamowione_danie {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
zamowienie Zamowienie @relation(fields: [zamowienieId], references: [id])
zamowienieId Int @unique
danias Danie[] @relation("DanieZamowione_danie")
}
model Zamowienie {
id Int @id @default(autoincrement())
status String
id Int @id @default(autoincrement())
status String
zamowioneDanie Zamowione_danie?
}
model Znizka {
id Int @id @default(autoincrement())
kod String
wartosc Int
czy_dostepna Boolean
}
id Int @id @default(autoincrement())
kod String
wartosc Int
czy_dostepna Boolean
restauracjaId Int
restauracja Restauracja @relation("RestauracjaZnizka", fields: [restauracjaId], references: [id])
}