Add Upload.paid boolean column

One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation).

Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for.

This makes fee calculation easier since no JOINs are required.
This commit is contained in:
ekzyis 2023-10-25 01:04:46 +02:00
parent 30aed4e805
commit 900592020f
3 changed files with 19 additions and 12 deletions

View File

@ -1,8 +0,0 @@
/*
Warnings:
- You are about to drop the column `uploadId` on the `Item` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "Upload.itemId_unique";

View File

@ -0,0 +1,18 @@
/*
Warnings:
- You are about to drop the column `itemId` on the `Upload` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "Upload" DROP CONSTRAINT "Upload_itemId_fkey";
-- DropIndex
DROP INDEX "Upload.itemId_index";
-- DropIndex
DROP INDEX "Upload.itemId_unique";
-- AlterTable
ALTER TABLE "Upload" DROP COLUMN "itemId",
ADD COLUMN "paid" BOOLEAN;

View File

@ -176,14 +176,12 @@ model Upload {
size Int
width Int?
height Int?
itemId Int?
userId Int
item Item? @relation(fields: [itemId], references: [id])
user User @relation("Uploads", fields: [userId], references: [id], onDelete: Cascade)
User User[]
paid Boolean?
@@index([createdAt], map: "Upload.created_at_index")
@@index([itemId], map: "Upload.itemId_index")
@@index([userId], map: "Upload.userId_index")
}
@ -299,7 +297,6 @@ model Item {
PollOption PollOption[]
PollVote PollVote[]
ThreadSubscription ThreadSubscription[]
uploads Upload[]
User User[]
itemForwards ItemForward[]