A decentralized music tracking and discovery platform built on AT Protocol 馃幍 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
at main 30 lines 1.1 kB view raw
1import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm"; 2import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; 3import albums from "./albums"; 4import artists from "./artists"; 5import tracks from "./tracks"; 6import users from "./users"; 7 8const scrobbles = sqliteTable("scrobbles", { 9 id: text("xata_id").primaryKey().notNull(), 10 userId: text("user_id").references(() => users.id), 11 trackId: text("track_id").references(() => tracks.id), 12 albumId: text("album_id").references(() => albums.id), 13 artistId: text("artist_id").references(() => artists.id), 14 uri: text("uri").unique(), 15 cid: text("cid").unique(), 16 createdAt: integer("created_at", { mode: "timestamp" }) 17 .notNull() 18 .default(sql`(unixepoch())`), 19 updatedAt: integer("updated_at", { mode: "timestamp" }) 20 .notNull() 21 .default(sql`(unixepoch())`), 22 timestamp: integer("timestamp", { mode: "timestamp" }) 23 .notNull() 24 .default(sql`(unixepoch())`), 25}); 26 27export type SelectScrobble = InferSelectModel<typeof scrobbles>; 28export type InsertScrobble = InferInsertModel<typeof scrobbles>; 29 30export default scrobbles;