stacker.news/prisma/migrations/20220511171526_upload/migration.sql

30 lines
861 B
SQL

-- CreateTable
CREATE TABLE "Upload" (
"id" SERIAL NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"type" TEXT NOT NULL,
"size" INTEGER NOT NULL,
"width" INTEGER,
"height" INTEGER,
"itemId" INTEGER,
"userId" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Upload.created_at_index" ON "Upload"("created_at");
-- CreateIndex
CREATE INDEX "Upload.itemId_index" ON "Upload"("itemId");
-- CreateIndex
CREATE INDEX "Upload.userId_index" ON "Upload"("userId");
-- AddForeignKey
ALTER TABLE "Upload" ADD FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Upload" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;