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 tracks from "./tracks";
4import users from "./users";
5
6const userTracks = pgTable("user_tracks", {
7 id: text("xata_id").primaryKey().default(sql`xata_id()`),
8 userId: text("user_id")
9 .notNull()
10 .references(() => users.id),
11 trackId: text("track_id")
12 .notNull()
13 .references(() => tracks.id),
14 createdAt: timestamp("xata_createdat").defaultNow().notNull(),
15 updatedAt: timestamp("xata_updatedat").defaultNow().notNull(),
16 xataVersion: integer("xata_version"),
17 uri: text("uri").unique().notNull(),
18 scrobbles: integer("scrobbles"),
19});
20
21export type SelectUserTrack = InferSelectModel<typeof userTracks>;
22export type InsertUserTrack = InferInsertModel<typeof userTracks>;
23
24export default userTracks;