updated prisma schema

This commit is contained in:
daniel31x13 2023-10-27 16:06:42 -04:00
parent ea86737835
commit c08e7d4580
4 changed files with 79 additions and 53 deletions

View File

@ -31,7 +31,6 @@ async function checkFileExistence(path) {
Key: path, Key: path,
}; };
console.log(path);
try { try {
const headObjectAsync = util.promisify( const headObjectAsync = util.promisify(
s3Client.headObject.bind(s3Client) s3Client.headObject.bind(s3Client)

View File

@ -0,0 +1,24 @@
-- AlterTable
ALTER TABLE "Collection" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "Link" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "Tag" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "User" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "UsersAndCollections" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "VerificationToken" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "WhitelistedUser" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -0,0 +1,18 @@
/*
Warnings:
- You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey";
-- DropForeignKey
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";
-- DropTable
DROP TABLE "Account";
-- DropTable
DROP TABLE "Session";

View File

@ -7,75 +7,52 @@ datasource db {
url = env("DATABASE_URL") url = env("DATABASE_URL")
} }
model Account {
id String @id @default(cuid())
userId Int
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId Int
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User { model User {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
username String? @unique username String? @unique
email String? @unique email String? @unique
emailVerified DateTime? emailVerified DateTime?
imagePath String? imagePath String?
accounts Account[] password String
sessions Session[] collections Collection[]
password String tags Tag[]
collections Collection[]
tags Tag[] pinnedLinks Link[]
pinnedLinks Link[]
archiveAsScreenshot Boolean @default(true) archiveAsScreenshot Boolean @default(true)
archiveAsPDF Boolean @default(true) archiveAsPDF Boolean @default(true)
archiveAsWaybackMachine Boolean @default(false) archiveAsWaybackMachine Boolean @default(false)
collectionsJoined UsersAndCollections[] collectionsJoined UsersAndCollections[]
isPrivate Boolean @default(false) isPrivate Boolean @default(false)
whitelistedUsers WhitelistedUser[] whitelistedUsers WhitelistedUser[]
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
} }
model WhitelistedUser { model WhitelistedUser {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
username String @default("") username String @default("")
User User? @relation(fields: [userId], references: [id]) User User? @relation(fields: [userId], references: [id])
userId Int? userId Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
} }
model VerificationToken { model VerificationToken {
identifier String identifier String
token String @unique token String @unique
expires DateTime expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
@@unique([identifier, token]) @@unique([identifier, token])
} }
@ -91,7 +68,8 @@ model Collection {
ownerId Int ownerId Int
members UsersAndCollections[] members UsersAndCollections[]
links Link[] links Link[]
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
@@unique([name, ownerId]) @@unique([name, ownerId])
} }
@ -107,6 +85,9 @@ model UsersAndCollections {
canUpdate Boolean canUpdate Boolean
canDelete Boolean canDelete Boolean
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
@@id([userId, collectionId]) @@id([userId, collectionId])
} }
@ -126,6 +107,7 @@ model Link {
pdfPath String? pdfPath String?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
} }
model Tag { model Tag {
@ -135,5 +117,8 @@ model Tag {
owner User @relation(fields: [ownerId], references: [id]) owner User @relation(fields: [ownerId], references: [id])
ownerId Int ownerId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
@@unique([name, ownerId]) @@unique([name, ownerId])
} }