First protorype

This commit is contained in:
Alexandru Eduard Farcas
2025-07-04 12:24:00 +03:00
parent 325b0bdc30
commit 024e5ca656
26 changed files with 1278 additions and 1 deletions
@@ -0,0 +1,59 @@
-- CreateEnum
CREATE TYPE "FuelType" AS ENUM ('GASOLINE', 'DIESEL', 'LPG');
-- CreateEnum
CREATE TYPE "Currency" AS ENUM ('EUR', 'USD', 'RON', 'GBP');
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"email" TEXT NOT NULL,
"hashedPassword" TEXT NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Car" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"fuelType" "FuelType" NOT NULL,
CONSTRAINT "Car_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "FillUp" (
"id" TEXT NOT NULL,
"carId" TEXT NOT NULL,
"mileage" INTEGER NOT NULL,
"liters" DOUBLE PRECISION NOT NULL,
"cost" DOUBLE PRECISION NOT NULL,
"currency" "Currency" NOT NULL,
"date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "FillUp_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "MileageEntry" (
"id" TEXT NOT NULL,
"carId" TEXT NOT NULL,
"mileage" INTEGER NOT NULL,
"date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MileageEntry_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- AddForeignKey
ALTER TABLE "Car" ADD CONSTRAINT "Car_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "FillUp" ADD CONSTRAINT "FillUp_carId_fkey" FOREIGN KEY ("carId") REFERENCES "Car"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "MileageEntry" ADD CONSTRAINT "MileageEntry_carId_fkey" FOREIGN KEY ("carId") REFERENCES "Car"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,12 @@
/*
Warnings:
- Added the required column `make` to the `Car` table without a default value. This is not possible if the table is not empty.
- Added the required column `model` to the `Car` table without a default value. This is not possible if the table is not empty.
- Added the required column `year` to the `Car` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Car" ADD COLUMN "make" TEXT NOT NULL,
ADD COLUMN "model" TEXT NOT NULL,
ADD COLUMN "year" INTEGER NOT NULL;
+3
View File
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"