fix the thousand year old bug

This commit is contained in:
cirroskais 2024-04-30 21:30:05 -04:00
parent 9809bd3793
commit ce4e014acb
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
4 changed files with 52 additions and 48 deletions

View file

@ -0,0 +1,7 @@
-- DropIndex
DROP INDEX `Upload_fileName_key` ON `Upload`;
-- AlterTable
ALTER TABLE `UserSettings` MODIFY `embedColor` INTEGER NOT NULL DEFAULT 0,
MODIFY `embedDescription` VARCHAR(191) NOT NULL DEFAULT 'Uploaded by {{username}} at {{time}}',
MODIFY `embedTitle` VARCHAR(191) NOT NULL DEFAULT '{{file}}';

View file

@ -1,56 +1,56 @@
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
createdAt DateTime @default(now())
lastSeen DateTime @default(now())
settings UserSettings?
// STORED AS MEGABYTES !!
maxUploadMB Int @default(100)
uploads Upload[]
sessions Session[]
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
createdAt DateTime @default(now())
lastSeen DateTime @default(now())
settings UserSettings?
// STORED AS MEGABYTES !!
maxUploadMB Int @default(100)
uploads Upload[]
sessions Session[]
}
model Session {
id String @id @unique
user User @relation(fields: [userId], references: [id])
userId Int
id String @id @unique
user User @relation(fields: [userId], references: [id])
userId Int
authorized Boolean
createdAt DateTime @default(now())
expiresAt DateTime
remoteAddress String?
authorized Boolean
createdAt DateTime @default(now())
expiresAt DateTime
remoteAddress String?
}
model UserSettings {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int @unique
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int @unique
newPostsPublic Boolean @default(false)
linkToRaw Boolean @default(false)
newPostsPublic Boolean @default(false)
linkToRaw Boolean @default(false)
embedTitle String
embedDescription String
embedColor Int
embedTitle String @default("{{file}}")
embedDescription String @default("Uploaded by {{username}} at {{time}}")
embedColor Int @default(0)
}
model Upload {
id String @id
uploader User @relation(fields: [uploaderId], references: [id])
uploaderId Int
id String @id
uploader User @relation(fields: [uploaderId], references: [id])
uploaderId Int
fileName String @unique
public Boolean @default(false)
uploaded DateTime @default(now())
fileName String
public Boolean @default(false)
uploaded DateTime @default(now())
}

View file

@ -1,10 +0,0 @@
/** @type {import("@sveltejs/kit").Load } */
export function load({ fetch }) {
const statistics = fetch('/api/statistics').then((response) => response.json());
return {
streamed: {
statistics
}
};
}

View file

@ -1,4 +1,11 @@
/** @type {import("@sveltejs/kit").Load} */
export function load({ locals }) {
return { user: locals?.user };
/** @type {import("@sveltejs/kit").ServerLoad} */
export function load({ locals, fetch }) {
const statistics = fetch('/api/statistics').then((response) => response.json());
return {
user: locals?.user,
streamed: {
statistics
}
};
}