+2
-2
libs/database/lib/schema.ts
+2
-2
libs/database/lib/schema.ts
···
55
55
56
56
export const profilesTable = sqliteTable("profiles", {
57
57
uri: text('uri')
58
-
.generatedAlwaysAs((): SQL => sql`'at://' || ${profilesTable.did} || '/${BlueRecipesActorProfile.mainSchema.object.shape.$type}/self'`)
58
+
.generatedAlwaysAs((): SQL => sql`'at://' || ${profilesTable.did} || '/blue.recipes.actor.profile/self'`)
59
59
.$type<ResourceUri>(),
60
60
did: text("did").$type<AtprotoDid>().notNull().primaryKey(),
61
61
ingestedAt: dateIsoText("ingested_at").notNull().default(sql`CURRENT_TIMESTAMP`),
···
74
74
75
75
export const recipeTable = sqliteTable("recipes", {
76
76
uri: text('uri')
77
-
.generatedAlwaysAs((): SQL => sql`'at://' || ${recipeTable.did} || '/${BlueRecipesFeedRecipe.mainSchema.object.shape.$type}/' || ${recipeTable.rkey}`),
77
+
.generatedAlwaysAs((): SQL => sql`'at://' || ${recipeTable.did} || '/blue.recipes.feed.recipe/' || ${recipeTable.rkey}`),
78
78
79
79
did: text("author_did")
80
80
.$type<AtprotoDid>()
+4
libs/database/migrations/0002_cheerful_venom.sql
+4
libs/database/migrations/0002_cheerful_venom.sql
···
1
+
ALTER TABLE `profiles` DROP COLUMN `uri`;--> statement-breakpoint
2
+
ALTER TABLE `profiles` ADD `uri` text GENERATED ALWAYS AS ('at://' || "did" || '/blue.recipes.actor.profile/self') VIRTUAL;--> statement-breakpoint
3
+
ALTER TABLE `recipes` DROP COLUMN `uri`;--> statement-breakpoint
4
+
ALTER TABLE `recipes` ADD `uri` text GENERATED ALWAYS AS ('at://' || "author_did" || '/blue.recipes.feed.recipe/' || "rkey") VIRTUAL;
+284
libs/database/migrations/meta/0002_snapshot.json
+284
libs/database/migrations/meta/0002_snapshot.json
···
1
+
{
2
+
"version": "6",
3
+
"dialect": "sqlite",
4
+
"id": "25f6fc02-0357-4a4a-a43c-6fc138a21401",
5
+
"prevId": "d6f06b7d-9822-43ee-b96c-3b980a5e4953",
6
+
"tables": {
7
+
"profiles": {
8
+
"name": "profiles",
9
+
"columns": {
10
+
"uri": {
11
+
"name": "uri",
12
+
"type": "text",
13
+
"primaryKey": false,
14
+
"notNull": false,
15
+
"autoincrement": false,
16
+
"generated": {
17
+
"as": "('at://' || \"did\" || '/blue.recipes.actor.profile/self')",
18
+
"type": "virtual"
19
+
}
20
+
},
21
+
"did": {
22
+
"name": "did",
23
+
"type": "text",
24
+
"primaryKey": true,
25
+
"notNull": true,
26
+
"autoincrement": false
27
+
},
28
+
"ingested_at": {
29
+
"name": "ingested_at",
30
+
"type": "text",
31
+
"primaryKey": false,
32
+
"notNull": true,
33
+
"autoincrement": false,
34
+
"default": "CURRENT_TIMESTAMP"
35
+
},
36
+
"display_name": {
37
+
"name": "display_name",
38
+
"type": "text(640)",
39
+
"primaryKey": false,
40
+
"notNull": true,
41
+
"autoincrement": false
42
+
},
43
+
"description": {
44
+
"name": "description",
45
+
"type": "text(2500)",
46
+
"primaryKey": false,
47
+
"notNull": false,
48
+
"autoincrement": false
49
+
},
50
+
"pronouns": {
51
+
"name": "pronouns",
52
+
"type": "text(200)",
53
+
"primaryKey": false,
54
+
"notNull": false,
55
+
"autoincrement": false
56
+
},
57
+
"website": {
58
+
"name": "website",
59
+
"type": "text",
60
+
"primaryKey": false,
61
+
"notNull": false,
62
+
"autoincrement": false
63
+
},
64
+
"avatar": {
65
+
"name": "avatar",
66
+
"type": "text",
67
+
"primaryKey": false,
68
+
"notNull": false,
69
+
"autoincrement": false
70
+
},
71
+
"banner": {
72
+
"name": "banner",
73
+
"type": "text",
74
+
"primaryKey": false,
75
+
"notNull": false,
76
+
"autoincrement": false
77
+
},
78
+
"created_at": {
79
+
"name": "created_at",
80
+
"type": "text",
81
+
"primaryKey": false,
82
+
"notNull": true,
83
+
"autoincrement": false
84
+
}
85
+
},
86
+
"indexes": {
87
+
"profiles_cat_idx": {
88
+
"name": "profiles_cat_idx",
89
+
"columns": [
90
+
"created_at"
91
+
],
92
+
"isUnique": false
93
+
},
94
+
"profiles_iat_idx": {
95
+
"name": "profiles_iat_idx",
96
+
"columns": [
97
+
"ingested_at"
98
+
],
99
+
"isUnique": false
100
+
}
101
+
},
102
+
"foreignKeys": {},
103
+
"compositePrimaryKeys": {},
104
+
"uniqueConstraints": {},
105
+
"checkConstraints": {}
106
+
},
107
+
"recipes": {
108
+
"name": "recipes",
109
+
"columns": {
110
+
"uri": {
111
+
"name": "uri",
112
+
"type": "text",
113
+
"primaryKey": false,
114
+
"notNull": false,
115
+
"autoincrement": false,
116
+
"generated": {
117
+
"as": "('at://' || \"author_did\" || '/blue.recipes.feed.recipe/' || \"rkey\")",
118
+
"type": "virtual"
119
+
}
120
+
},
121
+
"author_did": {
122
+
"name": "author_did",
123
+
"type": "text",
124
+
"primaryKey": false,
125
+
"notNull": true,
126
+
"autoincrement": false
127
+
},
128
+
"rkey": {
129
+
"name": "rkey",
130
+
"type": "text",
131
+
"primaryKey": false,
132
+
"notNull": true,
133
+
"autoincrement": false
134
+
},
135
+
"image": {
136
+
"name": "image",
137
+
"type": "text",
138
+
"primaryKey": false,
139
+
"notNull": false,
140
+
"autoincrement": false
141
+
},
142
+
"title": {
143
+
"name": "title",
144
+
"type": "text",
145
+
"primaryKey": false,
146
+
"notNull": true,
147
+
"autoincrement": false
148
+
},
149
+
"time": {
150
+
"name": "time",
151
+
"type": "integer",
152
+
"primaryKey": false,
153
+
"notNull": true,
154
+
"autoincrement": false,
155
+
"default": 0
156
+
},
157
+
"serves": {
158
+
"name": "serves",
159
+
"type": "integer",
160
+
"primaryKey": false,
161
+
"notNull": false,
162
+
"autoincrement": false
163
+
},
164
+
"description": {
165
+
"name": "description",
166
+
"type": "text",
167
+
"primaryKey": false,
168
+
"notNull": false,
169
+
"autoincrement": false
170
+
},
171
+
"ingredients": {
172
+
"name": "ingredients",
173
+
"type": "text",
174
+
"primaryKey": false,
175
+
"notNull": true,
176
+
"autoincrement": false
177
+
},
178
+
"ingredients_count": {
179
+
"name": "ingredients_count",
180
+
"type": "integer",
181
+
"primaryKey": false,
182
+
"notNull": false,
183
+
"autoincrement": false,
184
+
"generated": {
185
+
"as": "(json_array_length(\"ingredients\"))",
186
+
"type": "virtual"
187
+
}
188
+
},
189
+
"steps": {
190
+
"name": "steps",
191
+
"type": "text",
192
+
"primaryKey": false,
193
+
"notNull": true,
194
+
"autoincrement": false
195
+
},
196
+
"steps_count": {
197
+
"name": "steps_count",
198
+
"type": "integer",
199
+
"primaryKey": false,
200
+
"notNull": false,
201
+
"autoincrement": false,
202
+
"generated": {
203
+
"as": "(json_array_length(\"steps\"))",
204
+
"type": "virtual"
205
+
}
206
+
},
207
+
"created_at": {
208
+
"name": "created_at",
209
+
"type": "text",
210
+
"primaryKey": false,
211
+
"notNull": true,
212
+
"autoincrement": false
213
+
},
214
+
"ingested_at": {
215
+
"name": "ingested_at",
216
+
"type": "text",
217
+
"primaryKey": false,
218
+
"notNull": true,
219
+
"autoincrement": false,
220
+
"default": "CURRENT_TIMESTAMP"
221
+
}
222
+
},
223
+
"indexes": {
224
+
"recipes_title_idx": {
225
+
"name": "recipes_title_idx",
226
+
"columns": [
227
+
"title"
228
+
],
229
+
"isUnique": false
230
+
},
231
+
"recipes_cat_idx": {
232
+
"name": "recipes_cat_idx",
233
+
"columns": [
234
+
"created_at"
235
+
],
236
+
"isUnique": false
237
+
},
238
+
"recipes_iat_idx": {
239
+
"name": "recipes_iat_idx",
240
+
"columns": [
241
+
"ingested_at"
242
+
],
243
+
"isUnique": false
244
+
}
245
+
},
246
+
"foreignKeys": {
247
+
"recipes_author_did_profiles_did_fk": {
248
+
"name": "recipes_author_did_profiles_did_fk",
249
+
"tableFrom": "recipes",
250
+
"tableTo": "profiles",
251
+
"columnsFrom": [
252
+
"author_did"
253
+
],
254
+
"columnsTo": [
255
+
"did"
256
+
],
257
+
"onDelete": "cascade",
258
+
"onUpdate": "no action"
259
+
}
260
+
},
261
+
"compositePrimaryKeys": {
262
+
"recipes_author_did_rkey_pk": {
263
+
"columns": [
264
+
"author_did",
265
+
"rkey"
266
+
],
267
+
"name": "recipes_author_did_rkey_pk"
268
+
}
269
+
},
270
+
"uniqueConstraints": {},
271
+
"checkConstraints": {}
272
+
}
273
+
},
274
+
"views": {},
275
+
"enums": {},
276
+
"_meta": {
277
+
"schemas": {},
278
+
"tables": {},
279
+
"columns": {}
280
+
},
281
+
"internal": {
282
+
"indexes": {}
283
+
}
284
+
}