The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Added tags to prisma schema
Steven Teyf316269acc20
diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex c538e0aba7..5547da9683 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -2,8 +2,8 @@// learn more about it in the docs: https://pris.ly/d/prisma-schemadatasource db {- provider = "mysql"- url = env("DATABASE_URL")+ provider = "mysql"+ url = env("DATABASE_URL")}generator client {@@ -11,37 +11,37 @@ generator client {}model User {- id String @id @default(cuid())- name String?- email String? @unique- emailVerified DateTime?- image String?- stripeId String? @unique // Stripe customer ID- usage Int @default(0)- usageLimit Int @default(1000)- billingCycleStart Int? // day of the month when the billing cycle starts- accounts Account[]- sessions Session[]- projects ProjectUsers[]- sentEmails SentEmail[]- links Link[]- createdAt DateTime @default(now())- usageUpdatedAt DateTime @default(now())+ id String @id @default(cuid())+ name String?+ email String? @unique+ emailVerified DateTime?+ image String?+ stripeId String? @unique // Stripe customer ID+ usage Int @default(0)+ usageLimit Int @default(1000)+ billingCycleStart Int? // day of the month when the billing cycle starts+ accounts Account[]+ sessions Session[]+ projects ProjectUsers[]+ sentEmails SentEmail[]+ links Link[]+ createdAt DateTime @default(now())+ usageUpdatedAt DateTime @default(now())}model Account {- id String @id @default(cuid())- userId String- type String- provider String- providerAccountId String- refresh_token String? @db.Text- access_token String? @db.Text- expires_at Int?- token_type String?- scope String?- id_token String? @db.Text- session_state String?+ id String @id @default(cuid())+ userId String+ type String+ provider String+ providerAccountId String+ refresh_token String? @db.Text+ access_token String? @db.Text+ expires_at Int?+ token_type String?+ scope String?+ id_token String? @db.Text+ session_state String?user User @relation(fields: [userId], references: [id], onDelete: Cascade)@@ -65,30 +65,41 @@ model VerificationToken {}model Project {- id String @id @default(cuid())- name String- slug String @unique- logo String?- domain String @unique- domainVerified Boolean @default(false)- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- users ProjectUsers[]- invites ProjectInvite[]- domainLastChecked DateTime @default(now())- usage Int @default(0)- ownerUsageLimit Int @default(1000)- ownerExceededUsage Boolean @default(false)- sentEmails SentEmail[]- links Link[]+ id String @id @default(cuid())+ name String+ slug String @unique+ logo String?+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ users ProjectUsers[]+ invites ProjectInvite[]+ usage Int @default(0)+ ownerUsageLimit Int @default(1000)+ ownerExceededUsage Boolean @default(false)+ sentEmails SentEmail[]+ domains Domain[]+ links Link[]+ tags Tag[]+}++model Domain {+ id String @id @default(cuid())+ slug String @unique+ domainVerified Boolean @default(false)+ domainLastChecked DateTime @default(now())+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String?+ links Link[]}model ProjectInvite {- email String- expires DateTime- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- projectId String- createdAt DateTime @default(now())+ email String+ expires DateTime+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String+ createdAt DateTime @default(now())@@unique([email, projectId])}@@ -114,60 +125,79 @@ enum EmailType {}model SentEmail {- id String @id @default(cuid())+ id String @id @default(cuid())type EmailType- createdAt DateTime @default(now())- user User? @relation(fields: [userId], references: [id], onDelete: Cascade)+ createdAt DateTime @default(now())+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)userId String?- project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)projectId String?}model Link {- id String @id @default(cuid())- domain String // domain of the link (e.g. dub.sh) – also stored on Redis- key String // key of the link (e.g. /github) – also stored on Redis- url String @db.LongText // target url (e.g. https://github.com/steven-tey/dub) – also stored on Redis- archived Boolean @default(false) // whether the link is archived or not- expiresAt DateTime? // when the link expires – stored on Redis via ttl- password String? // password to access the link – also stored on Redis-- proxy Boolean @default(false) // Proxy to use custom OG tags – if false, will use OG tags from target url- title String? // OG title for the link (e.g. Dub - Open-Source Bitly Alternative)- description String? @db.VarChar(280) // OG description for the link (e.g. An open-source link management tool for modern marketing teams to create, share, and track short links.)- image String? @db.LongText // OG image for the link (e.g. https://dub.sh/og-image.png)+ id String @id @default(cuid())+ domain String // domain of the link (e.g. dub.sh) – also stored on Redis+ key String // key of the link (e.g. /github) – also stored on Redis+ url String @db.LongText // target url (e.g. https://github.com/steven-tey/dub) – also stored on Redis+ archived Boolean @default(false) // whether the link is archived or not (TODO: REMOVE AFTER ADDING TAGS)+ expiresAt DateTime? // when the link expires – stored on Redis via ttl+ password String? // password to access the link – also stored on Redis++ proxy Boolean @default(false) // Proxy to use custom OG tags – if false, will use OG tags from target url+ title String? // OG title for the link (e.g. Dub - Open-Source Bitly Alternative)+ description String? @db.VarChar(280) // OG description for the link (e.g. An open-source link management tool for modern marketing teams to create, share, and track short links.)+ image String? @db.LongText // OG image for the link (e.g. https://dub.sh/og-image.png)// UTM parameters- utm_source String? // UTM source for the link (e.g. youtube.com)- utm_medium String? // UTM medium for the link (e.g. social)- utm_campaign String? // UTM campaign for the link (e.g. summer-sale)- utm_term String? // UTM term for the link (e.g. dub)- utm_content String? // UTM content for the link (e.g. description)+ utm_source String? // UTM source for the link (e.g. youtube.com)+ utm_medium String? // UTM medium for the link (e.g. social)+ utm_campaign String? // UTM campaign for the link (e.g. summer-sale)+ utm_term String? // UTM term for the link (e.g. dub)+ utm_content String? // UTM content for the link (e.g. description)// Custom device targeting- ios String? @db.LongText // custom link for iOS devices- android String? @db.LongText // custom link for Android devices-- clicks Int @default(0) // number of clicks+ ios String? @db.LongText // custom link for iOS devices+ android String? @db.LongText // custom link for Android devices// User who created the link- user User? @relation(fields: [userId], references: [id])- userId String?+ user User? @relation(fields: [userId], references: [id])+ userId String?// Project that the link belongs to- project Project? @relation(fields: [domain], references: [domain], onUpdate: Cascade, onDelete: Cascade)- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt-- @@unique([domain, key])+ project Project? @relation(fields: [projectId], references: [id], onUpdate: Cascade, onDelete: Cascade)+ projectId String+ // Relational reference to the project domain+ projectDomain Domain? @relation(fields: [domain], references: [slug], onUpdate: Cascade, onDelete: Cascade)- // indices for links per domain/project- @@index([domain, archived, expiresAt, createdAt(sort: Desc)])- @@index([domain, archived, expiresAt, clicks(sort: Desc)])+ // Link metadata+ clicks Int @default(0) // number of clicks+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt- // indices for links per domain/project specific to a user- @@index([domain, archived, expiresAt, userId, createdAt(sort: Desc)])- @@index([domain, archived, expiresAt, userId, clicks(sort: Desc)])+ // Link tags+ tag Tag? @relation(fields: [tagId], references: [id])+ tagId String?// TODO: might wanna add indices for utm_source, utm_medium, utm_campaign-}\ No newline at end of file++ @@unique([domain, key])+ @@index([projectId, key])+ @@index(domain)+ @@index(proxy)+ @@index(password)+ @@index(createdAt(sort: Desc))+ @@index(clicks(sort: Desc))+ @@index(userId)+}++model Tag {+ id String @id @default(cuid())+ name String+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ project Project @relation(fields: [projectId], references: [id], onUpdate: Cascade, onDelete: Cascade)+ projectId String+ links Link[]++ @@unique([name, projectId])+}