···11+import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
22+import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
33+import tracks from "./tracks.ts";
44+import users from "./users.ts";
55+66+const lovedTracks = pgTable("loved_tracks", {
77+ id: text("xata_id")
88+ .primaryKey()
99+ .default(sql`xata_id()`),
1010+ userId: text("user_id")
1111+ .notNull()
1212+ .references(() => users.id),
1313+ trackId: text("track_id")
1414+ .notNull()
1515+ .references(() => tracks.id),
1616+ uri: text("uri").unique(),
1717+ createdAt: timestamp("xata_createdat").defaultNow().notNull(),
1818+});
1919+2020+export type SelectLovedTrack = InferSelectModel<typeof lovedTracks>;
2121+export type InsertLovedTrack = InferInsertModel<typeof lovedTracks>;
2222+2323+export default lovedTracks;
+15
apps/ws/src/schema/mod.ts
···11+import albums from "./albums.ts";
22+import artists from "./artists.ts";
33+import tracks from "./tracks.ts";
44+import scrobbles from "./scrobbles.ts";
55+import users from "./users.ts";
66+import lovedTracks from "./loved-tracks.ts";
77+88+export default {
99+ albums,
1010+ artists,
1111+ lovedTracks,
1212+ tracks,
1313+ scrobbles,
1414+ users,
1515+};
+26
apps/ws/src/schema/scrobbles.ts
···11+import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
22+import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
33+import albums from "./albums.ts";
44+import artists from "./artists.ts";
55+import tracks from "./tracks.ts";
66+import users from "./users.ts";
77+88+const scrobbles = pgTable("scrobbles", {
99+ id: text("xata_id")
1010+ .primaryKey()
1111+ .default(sql`xata_id()`),
1212+ userId: text("user_id").references(() => users.id),
1313+ trackId: text("track_id").references(() => tracks.id),
1414+ albumId: text("album_id").references(() => albums.id),
1515+ artistId: text("artist_id").references(() => artists.id),
1616+ uri: text("uri").unique(),
1717+ createdAt: timestamp("xata_createdat").defaultNow().notNull(),
1818+ updatedAt: timestamp("xata_updatedat").defaultNow().notNull(),
1919+ xataVersion: integer("xata_version"),
2020+ timestamp: timestamp("timestamp").defaultNow().notNull(),
2121+});
2222+2323+export type SelectScrobble = InferSelectModel<typeof scrobbles>;
2424+export type InsertScrobble = InferInsertModel<typeof scrobbles>;
2525+2626+export default scrobbles;