Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto

add schema

Changed files
+53 -28
packages
+53 -28
packages/db/schema.ts
··· 1 - import { sqliteTable, text } from "drizzle-orm/sqlite-core"; 1 + import { 2 + numeric, 3 + sqliteTable, 4 + text, 5 + customType, 6 + integer, 7 + } from "drizzle-orm/sqlite-core"; 2 8 3 - export type DatabaseSchema = { 4 - status: Status; 5 - auth_session: AuthSession; 6 - auth_state: AuthState; 7 - }; 8 - 9 - export type Status = { 10 - uri: string; 11 - authorDid: string; 12 - status: string; 13 - createdAt: string; 14 - indexedAt: string; 15 - }; 16 - 17 - export type AuthSession = { 18 - key: string; 19 - session: AuthSessionJson; 20 - }; 21 - 22 - export type AuthState = { 23 - key: string; 24 - state: AuthStateJson; 25 - }; 26 - 27 - type AuthStateJson = string; 28 - 29 - type AuthSessionJson = string; 9 + // string array custom type 10 + const json = <TData>() => 11 + customType<{ data: TData; driverData: string }>({ 12 + dataType() { 13 + return "text"; 14 + }, 15 + toDriver(value: TData): string { 16 + return JSON.stringify(value); 17 + }, 18 + })(); 30 19 31 20 // Tables 32 21 ··· 70 59 followed: text().primaryKey(), 71 60 createdAt: text().notNull(), 72 61 }); 62 + 63 + // play 64 + export const play = sqliteTable("play", { 65 + uri: text().primaryKey(), 66 + authorDid: text().notNull(), 67 + createdAt: text().notNull(), 68 + indexedAt: text().notNull(), 69 + 70 + /** The name of the track */ 71 + trackName: text().notNull(), 72 + /** The Musicbrainz ID of the track */ 73 + trackMbId: text(), 74 + /** The Musicbrainz recording ID of the track */ 75 + recordingMbId: text(), 76 + /** The length of the track in seconds */ 77 + duration: integer(), 78 + /** The name of the artist */ 79 + artistName: text().notNull(), 80 + /** Array of Musicbrainz artist IDs */ 81 + // type of string[] 82 + artistMbIds: json<string[]>(), 83 + /** The name of the release/album */ 84 + releaseName: text(), 85 + /** The Musicbrainz release ID */ 86 + releaseMbId: text(), 87 + /** The ISRC code associated with the recording */ 88 + isrc: text(), 89 + /** The URL associated with this track */ 90 + originUrl: text(), 91 + /** The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com. */ 92 + musicServiceBaseDomain: text(), 93 + /** A user-agent style string specifying the user agent. e.g. tealtracker/0.0.1b */ 94 + submissionClientAgent: text(), 95 + /** The unix timestamp of when the track was played */ 96 + playedTime: text(), 97 + });