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