···1+import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
2+import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
3+import tracks from "./tracks.ts";
4+import users from "./users.ts";
5+6+const lovedTracks = pgTable("loved_tracks", {
7+ id: text("xata_id")
8+ .primaryKey()
9+ .default(sql`xata_id()`),
10+ userId: text("user_id")
11+ .notNull()
12+ .references(() => users.id),
13+ trackId: text("track_id")
14+ .notNull()
15+ .references(() => tracks.id),
16+ uri: text("uri").unique(),
17+ createdAt: timestamp("xata_createdat").defaultNow().notNull(),
18+});
19+20+export type SelectLovedTrack = InferSelectModel<typeof lovedTracks>;
21+export type InsertLovedTrack = InferInsertModel<typeof lovedTracks>;
22+23+export default lovedTracks;
+15
apps/ws/src/schema/mod.ts
···000000000000000
···1+import albums from "./albums.ts";
2+import artists from "./artists.ts";
3+import tracks from "./tracks.ts";
4+import scrobbles from "./scrobbles.ts";
5+import users from "./users.ts";
6+import lovedTracks from "./loved-tracks.ts";
7+8+export default {
9+ albums,
10+ artists,
11+ lovedTracks,
12+ tracks,
13+ scrobbles,
14+ users,
15+};
+26
apps/ws/src/schema/scrobbles.ts
···00000000000000000000000000
···1+import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
2+import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
3+import albums from "./albums.ts";
4+import artists from "./artists.ts";
5+import tracks from "./tracks.ts";
6+import users from "./users.ts";
7+8+const scrobbles = pgTable("scrobbles", {
9+ id: text("xata_id")
10+ .primaryKey()
11+ .default(sql`xata_id()`),
12+ userId: text("user_id").references(() => users.id),
13+ trackId: text("track_id").references(() => tracks.id),
14+ albumId: text("album_id").references(() => albums.id),
15+ artistId: text("artist_id").references(() => artists.id),
16+ uri: text("uri").unique(),
17+ createdAt: timestamp("xata_createdat").defaultNow().notNull(),
18+ updatedAt: timestamp("xata_updatedat").defaultNow().notNull(),
19+ xataVersion: integer("xata_version"),
20+ timestamp: timestamp("timestamp").defaultNow().notNull(),
21+});
22+23+export type SelectScrobble = InferSelectModel<typeof scrobbles>;
24+export type InsertScrobble = InferInsertModel<typeof scrobbles>;
25+26+export default scrobbles;