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:
parent
30aed4e805
commit
900592020f
@ -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";
|
|
18
prisma/migrations/20231025000727_upload_paid/migration.sql
Normal file
18
prisma/migrations/20231025000727_upload_paid/migration.sql
Normal 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;
|
@ -176,14 +176,12 @@ model Upload {
|
|||||||
size Int
|
size Int
|
||||||
width Int?
|
width Int?
|
||||||
height Int?
|
height Int?
|
||||||
itemId Int?
|
|
||||||
userId Int
|
userId Int
|
||||||
item Item? @relation(fields: [itemId], references: [id])
|
|
||||||
user User @relation("Uploads", fields: [userId], references: [id], onDelete: Cascade)
|
user User @relation("Uploads", fields: [userId], references: [id], onDelete: Cascade)
|
||||||
User User[]
|
User User[]
|
||||||
|
paid Boolean?
|
||||||
|
|
||||||
@@index([createdAt], map: "Upload.created_at_index")
|
@@index([createdAt], map: "Upload.created_at_index")
|
||||||
@@index([itemId], map: "Upload.itemId_index")
|
|
||||||
@@index([userId], map: "Upload.userId_index")
|
@@index([userId], map: "Upload.userId_index")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +297,6 @@ model Item {
|
|||||||
PollOption PollOption[]
|
PollOption PollOption[]
|
||||||
PollVote PollVote[]
|
PollVote PollVote[]
|
||||||
ThreadSubscription ThreadSubscription[]
|
ThreadSubscription ThreadSubscription[]
|
||||||
uploads Upload[]
|
|
||||||
User User[]
|
User User[]
|
||||||
itemForwards ItemForward[]
|
itemForwards ItemForward[]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user