A decentralized music tracking and discovery platform built on AT Protocol 馃幍
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
1import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
2import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
3import albums from "./albums";
4import artists from "./artists";
5import tracks from "./tracks";
6import users from "./users";
7
8const scrobbles = pgTable("scrobbles", {
9 id: text("xata_id").primaryKey().default(sql`xata_id()`),
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 createdAt: timestamp("xata_createdat").defaultNow().notNull(),
16 updatedAt: timestamp("xata_updatedat").defaultNow().notNull(),
17 xataVersion: integer("xata_version"),
18 timestamp: timestamp("timestamp").defaultNow().notNull(),
19});
20
21export type SelectScrobble = InferSelectModel<typeof scrobbles>;
22export type InsertScrobble = InferInsertModel<typeof scrobbles>;
23
24export default scrobbles;