feat: add reusable private and shared account icons
This commit is contained in:
1 parent
d2b2681698
commit
a4e9d56b8a
44 files changed
+1443
-20
No files matched your search
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE `Icon` (
|
||||
`id` CHAR(36) NOT NULL,
|
||||
`ownerId` CHAR(36) NULL,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`shared` BOOLEAN NOT NULL DEFAULT false,
|
||||
`hash` CHAR(64) NOT NULL,
|
||||
`data` MEDIUMBLOB NOT NULL,
|
||||
`source` VARCHAR(500) NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `Icon_ownerId_hash_shared_key` (`ownerId`, `hash`, `shared`),
|
||||
INDEX `Icon_shared_name_idx` (`shared`, `name`),
|
||||
CONSTRAINT `Icon_ownerId_fkey` FOREIGN KEY (`ownerId`) REFERENCES `User` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
ALTER TABLE `Position` ADD COLUMN `iconId` CHAR(36) NULL;
|
||||
ALTER TABLE `Position` ADD CONSTRAINT `Position_iconId_fkey` FOREIGN KEY (`iconId`) REFERENCES `Icon` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -17,6 +17,7 @@ model User {
|
||||
positions Position[]
|
||||
rates ExchangeRate[]
|
||||
sessions Session[]
|
||||
icons Icon[]
|
||||
}
|
||||
model Session {
|
||||
id String @id @db.Char(64)
|
||||
@@ -44,6 +45,8 @@ model Position {
|
||||
hidden Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
iconId String? @db.Char(36)
|
||||
icon Icon? @relation(fields:[iconId],references:[id],onDelete:SetNull)
|
||||
revisions Revision[]
|
||||
outgoing PositionLink[] @relation("Source")
|
||||
incoming PositionLink[] @relation("Target")
|
||||
@@ -82,3 +85,18 @@ model ExchangeRate {
|
||||
source String @db.VarChar(30)
|
||||
@@unique([userId,currency,baseCurrency,date])
|
||||
}
|
||||
|
||||
model Icon {
|
||||
id String @id @default(uuid()) @db.Char(36)
|
||||
ownerId String? @db.Char(36)
|
||||
owner User? @relation(fields:[ownerId],references:[id],onDelete:SetNull)
|
||||
name String @db.VarChar(100)
|
||||
shared Boolean @default(false)
|
||||
hash String @db.Char(64)
|
||||
data Bytes @db.MediumBlob
|
||||
source String? @db.VarChar(500)
|
||||
createdAt DateTime @default(now())
|
||||
positions Position[]
|
||||
@@unique([ownerId,hash,shared])
|
||||
@@index([shared,name])
|
||||
}
|
||||
Reference in new issue
Block a user