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

update database, lint issues, etc.

+405 -28
+2 -2
drizzle.config.ts packages/db/drizzle.config.ts
··· 2 2 3 3 export default defineConfig({ 4 4 dialect: "sqlite", 5 - schema: "./packages/db/schema.ts", 6 - out: "./packages/db/.drizzle", 5 + schema: "./schema.ts", 6 + out: "./.drizzle", 7 7 casing: "snake_case", 8 8 dbCredentials: { 9 9 url: process.env.DATABASE_URL ?? "./db.sqlite",
+2 -4
package.json
··· 10 10 "fix": "biome lint --apply . && biome format --write . && biome check . --apply" 11 11 }, 12 12 "devDependencies": { 13 + "@types/node": "^20.17.10", 13 14 "biome": "^0.3.3", 14 15 "turbo": "^2.3.3" 15 16 }, 16 17 "workspaces": [ 17 18 "apps/*", 18 19 "packages/*" 19 - ], 20 - "dependencies": { 21 - "drizzle-kit": "^0.30.1" 22 - } 20 + ] 23 21 }
+29
packages/db/.drizzle/0004_exotic_ironclad.sql
··· 1 + CREATE TABLE `follow` ( 2 + `follower` text PRIMARY KEY NOT NULL, 3 + `followed` text PRIMARY KEY NOT NULL, 4 + `created_at` text NOT NULL 5 + ); 6 + --> statement-breakpoint 7 + CREATE TABLE `play` ( 8 + `uri` text PRIMARY KEY NOT NULL, 9 + `author_did` text NOT NULL, 10 + `created_at` text NOT NULL, 11 + `indexed_at` text NOT NULL, 12 + `track_name` text NOT NULL, 13 + `track_mb_id` text, 14 + `recording_mb_id` text, 15 + `duration` integer, 16 + `artist_name` text NOT NULL, 17 + `artist_mb_ids` text, 18 + `release_name` text, 19 + `release_mb_id` text, 20 + `isrc` text, 21 + `origin_url` text, 22 + `music_service_base_domain` text, 23 + `submission_client_agent` text, 24 + `played_time` text 25 + ); 26 + --> statement-breakpoint 27 + ALTER TABLE `teal_user` ADD `avatar` text NOT NULL;--> statement-breakpoint 28 + ALTER TABLE `teal_user` ADD `bio` text;--> statement-breakpoint 29 + ALTER TABLE `teal_user` DROP COLUMN `email`;
+347
packages/db/.drizzle/meta/0004_snapshot.json
··· 1 + { 2 + "version": "6", 3 + "dialect": "sqlite", 4 + "id": "639ec806-61a1-448d-a922-1935bf8f6cf3", 5 + "prevId": "7710000b-44fd-4d23-a768-0117f22926c3", 6 + "tables": { 7 + "atp_session": { 8 + "name": "atp_session", 9 + "columns": { 10 + "key": { 11 + "name": "key", 12 + "type": "text", 13 + "primaryKey": true, 14 + "notNull": true, 15 + "autoincrement": false 16 + }, 17 + "session": { 18 + "name": "session", 19 + "type": "text", 20 + "primaryKey": false, 21 + "notNull": true, 22 + "autoincrement": false 23 + } 24 + }, 25 + "indexes": {}, 26 + "foreignKeys": {}, 27 + "compositePrimaryKeys": {}, 28 + "uniqueConstraints": {}, 29 + "checkConstraints": {} 30 + }, 31 + "auth_state": { 32 + "name": "auth_state", 33 + "columns": { 34 + "key": { 35 + "name": "key", 36 + "type": "text", 37 + "primaryKey": true, 38 + "notNull": true, 39 + "autoincrement": false 40 + }, 41 + "state": { 42 + "name": "state", 43 + "type": "text", 44 + "primaryKey": false, 45 + "notNull": true, 46 + "autoincrement": false 47 + } 48 + }, 49 + "indexes": {}, 50 + "foreignKeys": {}, 51 + "compositePrimaryKeys": {}, 52 + "uniqueConstraints": {}, 53 + "checkConstraints": {} 54 + }, 55 + "follow": { 56 + "name": "follow", 57 + "columns": { 58 + "follower": { 59 + "name": "follower", 60 + "type": "text", 61 + "primaryKey": true, 62 + "notNull": true, 63 + "autoincrement": false 64 + }, 65 + "followed": { 66 + "name": "followed", 67 + "type": "text", 68 + "primaryKey": true, 69 + "notNull": true, 70 + "autoincrement": false 71 + }, 72 + "created_at": { 73 + "name": "created_at", 74 + "type": "text", 75 + "primaryKey": false, 76 + "notNull": true, 77 + "autoincrement": false 78 + } 79 + }, 80 + "indexes": {}, 81 + "foreignKeys": {}, 82 + "compositePrimaryKeys": {}, 83 + "uniqueConstraints": {}, 84 + "checkConstraints": {} 85 + }, 86 + "play": { 87 + "name": "play", 88 + "columns": { 89 + "uri": { 90 + "name": "uri", 91 + "type": "text", 92 + "primaryKey": true, 93 + "notNull": true, 94 + "autoincrement": false 95 + }, 96 + "author_did": { 97 + "name": "author_did", 98 + "type": "text", 99 + "primaryKey": false, 100 + "notNull": true, 101 + "autoincrement": false 102 + }, 103 + "created_at": { 104 + "name": "created_at", 105 + "type": "text", 106 + "primaryKey": false, 107 + "notNull": true, 108 + "autoincrement": false 109 + }, 110 + "indexed_at": { 111 + "name": "indexed_at", 112 + "type": "text", 113 + "primaryKey": false, 114 + "notNull": true, 115 + "autoincrement": false 116 + }, 117 + "track_name": { 118 + "name": "track_name", 119 + "type": "text", 120 + "primaryKey": false, 121 + "notNull": true, 122 + "autoincrement": false 123 + }, 124 + "track_mb_id": { 125 + "name": "track_mb_id", 126 + "type": "text", 127 + "primaryKey": false, 128 + "notNull": false, 129 + "autoincrement": false 130 + }, 131 + "recording_mb_id": { 132 + "name": "recording_mb_id", 133 + "type": "text", 134 + "primaryKey": false, 135 + "notNull": false, 136 + "autoincrement": false 137 + }, 138 + "duration": { 139 + "name": "duration", 140 + "type": "integer", 141 + "primaryKey": false, 142 + "notNull": false, 143 + "autoincrement": false 144 + }, 145 + "artist_name": { 146 + "name": "artist_name", 147 + "type": "text", 148 + "primaryKey": false, 149 + "notNull": true, 150 + "autoincrement": false 151 + }, 152 + "artist_mb_ids": { 153 + "name": "artist_mb_ids", 154 + "type": "text", 155 + "primaryKey": false, 156 + "notNull": false, 157 + "autoincrement": false 158 + }, 159 + "release_name": { 160 + "name": "release_name", 161 + "type": "text", 162 + "primaryKey": false, 163 + "notNull": false, 164 + "autoincrement": false 165 + }, 166 + "release_mb_id": { 167 + "name": "release_mb_id", 168 + "type": "text", 169 + "primaryKey": false, 170 + "notNull": false, 171 + "autoincrement": false 172 + }, 173 + "isrc": { 174 + "name": "isrc", 175 + "type": "text", 176 + "primaryKey": false, 177 + "notNull": false, 178 + "autoincrement": false 179 + }, 180 + "origin_url": { 181 + "name": "origin_url", 182 + "type": "text", 183 + "primaryKey": false, 184 + "notNull": false, 185 + "autoincrement": false 186 + }, 187 + "music_service_base_domain": { 188 + "name": "music_service_base_domain", 189 + "type": "text", 190 + "primaryKey": false, 191 + "notNull": false, 192 + "autoincrement": false 193 + }, 194 + "submission_client_agent": { 195 + "name": "submission_client_agent", 196 + "type": "text", 197 + "primaryKey": false, 198 + "notNull": false, 199 + "autoincrement": false 200 + }, 201 + "played_time": { 202 + "name": "played_time", 203 + "type": "text", 204 + "primaryKey": false, 205 + "notNull": false, 206 + "autoincrement": false 207 + } 208 + }, 209 + "indexes": {}, 210 + "foreignKeys": {}, 211 + "compositePrimaryKeys": {}, 212 + "uniqueConstraints": {}, 213 + "checkConstraints": {} 214 + }, 215 + "status": { 216 + "name": "status", 217 + "columns": { 218 + "uri": { 219 + "name": "uri", 220 + "type": "text", 221 + "primaryKey": true, 222 + "notNull": true, 223 + "autoincrement": false 224 + }, 225 + "author_did": { 226 + "name": "author_did", 227 + "type": "text", 228 + "primaryKey": false, 229 + "notNull": true, 230 + "autoincrement": false 231 + }, 232 + "status": { 233 + "name": "status", 234 + "type": "text", 235 + "primaryKey": false, 236 + "notNull": true, 237 + "autoincrement": false 238 + }, 239 + "created_at": { 240 + "name": "created_at", 241 + "type": "text", 242 + "primaryKey": false, 243 + "notNull": true, 244 + "autoincrement": false 245 + }, 246 + "indexed_at": { 247 + "name": "indexed_at", 248 + "type": "text", 249 + "primaryKey": false, 250 + "notNull": true, 251 + "autoincrement": false 252 + } 253 + }, 254 + "indexes": {}, 255 + "foreignKeys": {}, 256 + "compositePrimaryKeys": {}, 257 + "uniqueConstraints": {}, 258 + "checkConstraints": {} 259 + }, 260 + "teal_session": { 261 + "name": "teal_session", 262 + "columns": { 263 + "key": { 264 + "name": "key", 265 + "type": "text", 266 + "primaryKey": true, 267 + "notNull": true, 268 + "autoincrement": false 269 + }, 270 + "session": { 271 + "name": "session", 272 + "type": "text", 273 + "primaryKey": false, 274 + "notNull": true, 275 + "autoincrement": false 276 + }, 277 + "provider": { 278 + "name": "provider", 279 + "type": "text", 280 + "primaryKey": false, 281 + "notNull": true, 282 + "autoincrement": false 283 + } 284 + }, 285 + "indexes": {}, 286 + "foreignKeys": {}, 287 + "compositePrimaryKeys": {}, 288 + "uniqueConstraints": {}, 289 + "checkConstraints": {} 290 + }, 291 + "teal_user": { 292 + "name": "teal_user", 293 + "columns": { 294 + "did": { 295 + "name": "did", 296 + "type": "text", 297 + "primaryKey": true, 298 + "notNull": true, 299 + "autoincrement": false 300 + }, 301 + "handle": { 302 + "name": "handle", 303 + "type": "text", 304 + "primaryKey": false, 305 + "notNull": true, 306 + "autoincrement": false 307 + }, 308 + "avatar": { 309 + "name": "avatar", 310 + "type": "text", 311 + "primaryKey": false, 312 + "notNull": true, 313 + "autoincrement": false 314 + }, 315 + "bio": { 316 + "name": "bio", 317 + "type": "text", 318 + "primaryKey": false, 319 + "notNull": false, 320 + "autoincrement": false 321 + }, 322 + "created_at": { 323 + "name": "created_at", 324 + "type": "text", 325 + "primaryKey": false, 326 + "notNull": true, 327 + "autoincrement": false 328 + } 329 + }, 330 + "indexes": {}, 331 + "foreignKeys": {}, 332 + "compositePrimaryKeys": {}, 333 + "uniqueConstraints": {}, 334 + "checkConstraints": {} 335 + } 336 + }, 337 + "views": {}, 338 + "enums": {}, 339 + "_meta": { 340 + "schemas": {}, 341 + "tables": {}, 342 + "columns": {} 343 + }, 344 + "internal": { 345 + "indexes": {} 346 + } 347 + }
+7
packages/db/.drizzle/meta/_journal.json
··· 29 29 "when": 1731093709171, 30 30 "tag": "0003_sharp_medusa", 31 31 "breakpoints": true 32 + }, 33 + { 34 + "idx": 4, 35 + "version": "6", 36 + "when": 1735101894454, 37 + "tag": "0004_exotic_ironclad", 38 + "breakpoints": true 32 39 } 33 40 ] 34 41 }
+7 -5
packages/db/connect.ts
··· 1 1 import { drizzle } from "drizzle-orm/libsql"; 2 + import { createClient } from "@libsql/client"; 2 3 import * as schema from "./schema"; 3 4 import process from "node:process"; 4 5 import path from "node:path"; 5 6 6 7 console.log("Loading SQLite file at", path.join(process.cwd(), "./db.sqlite")); 7 8 8 - export const db = drizzle({ 9 - connection: 10 - // default is in project root / db.sqlite 9 + const client = createClient({ 10 + url: 11 11 process.env.DATABASE_URL ?? 12 12 "file:" + path.join(process.cwd(), "./db.sqlite"), 13 - // doesn't seem to work? 14 - //casing: "snake_case", 13 + }); 14 + 15 + export const db = drizzle(client, { 15 16 schema: schema, 16 17 }); 17 18 19 + // If you need to export the type: 18 20 export type Database = typeof db;
+1
packages/db/package.json
··· 5 5 "main": "index.js", 6 6 "type": "module", 7 7 "scripts": { 8 + "db": "drizzle-kit", 8 9 "db:generate": "drizzle-kit generate", 9 10 "db:migrate": "drizzle-kit migrate", 10 11 "db:studio": "drizzle-kit studio"
+10 -17
pnpm-lock.yaml
··· 7 7 importers: 8 8 9 9 .: 10 - dependencies: 11 - drizzle-kit: 12 - specifier: ^0.30.1 13 - version: 0.30.1 14 10 devDependencies: 11 + '@types/node': 12 + specifier: ^20.17.10 13 + version: 20.17.10 15 14 biome: 16 15 specifier: ^0.3.3 17 16 version: 0.3.3 ··· 1102 1101 '@types/estree@1.0.6': 1103 1102 resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} 1104 1103 1104 + '@types/node@20.17.10': 1105 + resolution: {integrity: sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==} 1106 + 1105 1107 '@types/node@20.17.9': 1106 1108 resolution: {integrity: sha512-0JOXkRyLanfGPE2QRCwgxhzlBAvaRdCNMcvbd7jFfpmD4eEXll7LRwy5ymJmyeZqk7Nh7eD2LeUyQ68BbndmXw==} 1107 1109 ··· 1418 1420 1419 1421 drizzle-kit@0.27.2: 1420 1422 resolution: {integrity: sha512-F6cFZ1wxa9XzFyeeQsp/0/lIzUbDuQjS8/njpYBDWa+wdWmXuY+Z/X2hHFK/9PGHZkv3c9mER+mVWfKlp/B6Vw==} 1421 - hasBin: true 1422 - 1423 - drizzle-kit@0.30.1: 1424 - resolution: {integrity: sha512-HmA/NeewvHywhJ2ENXD3KvOuM/+K2dGLJfxVfIHsGwaqKICJnS+Ke2L6UcSrSrtMJLJaT0Im1Qv4TFXfaZShyw==} 1425 1423 hasBin: true 1426 1424 1427 1425 drizzle-orm@0.36.4: ··· 3403 3401 3404 3402 '@types/estree@1.0.6': {} 3405 3403 3404 + '@types/node@20.17.10': 3405 + dependencies: 3406 + undici-types: 6.19.8 3407 + 3406 3408 '@types/node@20.17.9': 3407 3409 dependencies: 3408 3410 undici-types: 6.19.8 ··· 3704 3706 dotenv@16.4.7: {} 3705 3707 3706 3708 drizzle-kit@0.27.2: 3707 - dependencies: 3708 - '@drizzle-team/brocli': 0.10.2 3709 - '@esbuild-kit/esm-loader': 2.6.5 3710 - esbuild: 0.19.12 3711 - esbuild-register: 3.6.0(esbuild@0.19.12) 3712 - transitivePeerDependencies: 3713 - - supports-color 3714 - 3715 - drizzle-kit@0.30.1: 3716 3709 dependencies: 3717 3710 '@drizzle-team/brocli': 0.10.2 3718 3711 '@esbuild-kit/esm-loader': 2.6.5