7export const thinkTool = tool({
8 description:
9 "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.",
10 parameters: z.object({
11 thought: z.string().describe("A thought to think about."),
174```
175βββ backend/
176β βββ database/
177β β βββ migrations.ts # Schema definitions
178β β βββ queries.ts # DB query functions
234 ```
235
236### Database Patterns
237- Run migrations on startup or comment out for performance
238- Change table names when modifying schemas rather than altering
10 overLimit,
11 startTrackingUsage,
12} from "../database/queries.tsx";
13import { makeChangeValTypeTool, makeFetchTool, makeTextEditorTool } from "../tools/index.ts";
14import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
5
6// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
198```
199βββ backend/
200β βββ database/
201β β βββ migrations.ts # Schema definitions
202β β βββ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3// Database schema for Kids Phone Safety App
4// Note: Change table names when modifying schemas (add _2, _3, etc.)
5
14
15/**
16 * Initialize all database tables
17 */
18export async function initializeDatabase(): Promise<void> {
19 await createParentsTable();
20 await createDevicesTable();
16βββ backend/
17β βββ index.ts # Main Hono server
18β βββ database/
19β β βββ migrations.ts # Database schema
20β β βββ queries.ts # Database operations
21β βββ routes/
22β βββ auth.ts # Authentication routes
39 // 1. Validate the form data
40 // 2. Send an email notification
41 // 3. Store the message in a database
42 // 4. Return a success response
43
46 "slug": "codegen",
47 "link": "/blog/codegen",
48 "description": "Like Claude Artifacts, but with a backend and database",
49 "pubDate": "Thu, 22 Aug 2024 00:00:00 GMT",
50 "author": "JP Posma",
1---
2title: "Post-mortem: A Backward Incompatible Database Migration"
3description: Val runs failed due to a database migration that was not backward compatible
4pubDate: 2025-04-02T00:00:00.000Z
5author: Sophie Houser
6---
7
8Today at 10:11am we experienced a 12-minute outage, which caused HTTP vals to return 503 errors and other types of vals to fail. In the end, the root cause was a deployment timing issue where database migrations were deployed successfully, but our application code deployment hung for several minutes. The new database migrations were incompatible with the old application code and crashed the process.
9
10We aim to make all database migrations maintain backward compatibility, but in this case, we only discovered through the delayed deployment feedback that the new migrations were not compatible with previous versions.
11
12## Timeline
27## Next Steps
28
29Reliability is important to us and weβve taken steps to make sure this doesnβt happen again. Weβve added a test to ensure database migrations are backward compatible, which weβll run before we deploy any new code that includes database migrations.