forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";
2import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
3import artists from "./artists";
4import users from "./users";
5
6const userArtists = sqliteTable(
7 "user_artists",
8 {
9 id: text("id").primaryKey().notNull(),
10 userId: text("user_id")
11 .notNull()
12 .references(() => users.id),
13 artistId: text("artist_id")
14 .notNull()
15 .references(() => artists.id),
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 scrobbles: integer("scrobbles"),
23 uri: text("uri").unique().notNull(),
24 },
25
26 (t) => [unique("user_artists_unique_index").on(t.userId, t.artistId)],
27);
28
29export type SelectUserArtist = InferSelectModel<typeof userArtists>;
30export type InsertUserArtist = InferInsertModel<typeof userArtists>;
31
32export default userArtists;