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 { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
3
4const events = sqliteTable(
5 "events",
6 {
7 id: integer("id").primaryKey(),
8 type: text("type").notNull(),
9 action: text("action"),
10 did: text("did").notNull(),
11 // identity
12 status: text("status"),
13 handle: text("handle"),
14 isActive: integer("is_active", { mode: "boolean" }),
15 // record
16 collection: text("collection"),
17 rev: text("rev"),
18 rkey: text("rkey"),
19 record: text("record"),
20 live: integer("live", { mode: "boolean" }),
21 cid: text("cid").unique(),
22 createdAt: integer("created_at", { mode: "timestamp" })
23 .notNull()
24 .default(sql`(unixepoch())`),
25 },
26 (t) => [
27 index("did_idx").on(t.did),
28 index("type_idx").on(t.type),
29 index("collection_idx").on(t.collection),
30 index("did_collection_rkey_idx").on(t.did, t.collection, t.rkey),
31 index("created_at").on(t.createdAt),
32 ],
33);
34
35export type SelectEvent = InferSelectModel<typeof events>;
36export type InsertEvent = InferInsertModel<typeof events>;
37
38export default events;