diff --git a/prisma/migrations/20240624161546_initialize/migration.sql b/prisma/migrations/20240624161546_initialize/migration.sql new file mode 100644 index 0000000..ed9c0ee --- /dev/null +++ b/prisma/migrations/20240624161546_initialize/migration.sql @@ -0,0 +1,47 @@ +-- CreateTable +CREATE TABLE "Category" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + + CONSTRAINT "Category_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "HeroImage" ( + "id" SERIAL NOT NULL, + "image1" TEXT NOT NULL, + "image2" TEXT NOT NULL, + + CONSTRAINT "HeroImage_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Product" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + "description" TEXT NOT NULL, + "slug" TEXT NOT NULL, + "price" DOUBLE PRECISION NOT NULL, + "price_id" TEXT NOT NULL, + "categoryId" INTEGER NOT NULL, + + CONSTRAINT "Product_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Image" ( + "id" SERIAL NOT NULL, + "url" TEXT NOT NULL, + "productId" INTEGER NOT NULL, + + CONSTRAINT "Image_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Product_slug_key" ON "Product"("slug"); + +-- AddForeignKey +ALTER TABLE "Product" ADD CONSTRAINT "Product_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Image" ADD CONSTRAINT "Image_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..fbffa92 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "postgresql" \ No newline at end of file