// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) spotifyId String @unique displayName String email String profileImage String? accessToken String refreshToken String tokenExpiresAt DateTime createdAt DateTime @default(now()) updatedAt DateTime @updatedAt // Relationships recentlyPlayed RecentlyPlayed[] currentlyPlaying CurrentlyPlaying[] topTracks TopTrack[] topArtists TopArtist[] playlists Playlist[] @@map("users") } model RecentlyPlayed { id String @id @default(cuid()) userId String trackId String trackName String artistName String albumName String albumImage String? playedAt DateTime duration Int createdAt DateTime @default(now()) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([userId, trackId, playedAt]) @@map("recently_played") } model CurrentlyPlaying { id String @id @default(cuid()) userId String trackId String? trackName String? artistName String? albumName String? albumImage String? isPlaying Boolean @default(false) progressMs Int? durationMs Int? updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("currently_playing") } model TopTrack { id String @id @default(cuid()) userId String trackId String trackName String artistName String albumName String albumImage String? popularity Int timeRange String // short_term, medium_term, long_term createdAt DateTime @default(now()) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("top_tracks") } model TopArtist { id String @id @default(cuid()) userId String artistId String artistName String artistImage String? popularity Int timeRange String // short_term, medium_term, long_term createdAt DateTime @default(now()) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("top_artists") } model Playlist { id String @id @default(cuid()) userId String spotifyId String? // Spotify playlist ID if created name String description String? imageUrl String? isShared Boolean @default(false) createdAt DateTime @default(now()) user User @relation(fields: [userId], references: [id], onDelete: Cascade) tracks PlaylistTrack[] @@map("playlists") } model PlaylistTrack { id String @id @default(cuid()) playlistId String trackId String trackName String artistName String albumName String albumImage String? addedAt DateTime @default(now()) playlist Playlist @relation(fields: [playlistId], references: [id], onDelete: Cascade) @@map("playlist_tracks") }