208```
209βββ backend/
210β βββ database/
211β β βββ migrations.ts # Schema definitions
212β β βββ queries.ts # DB query functions
270- Handle API calls properly with proper error catching
271
272### Database Patterns
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
548 }
549 const domain = payload.policyDomain.toLowerCase();
550 // Mock Database / Retrieval Logic
551 const mockKB = {
552 "environmental": [
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
8Today at 10:11am we experienced a 12-minute outage, which caused HTTP vals to
9return 503 errors and other types of vals to fail. In the end, the root cause
10was a deployment timing issue where database migrations were deployed
11successfully, but our application code deployment hung for several minutes. The
12new database migrations were incompatible with the old application code and
13crashed the process.
14
15We aim to make all database migrations maintain backward compatibility, but in
16this case, we only discovered through the delayed deployment feedback that the
17new migrations were not compatible with previous versions.
39
40Reliability is important to us and weβve taken steps to make sure this doesnβt
41happen again. Weβve added a test to ensure database migrations are backward
42compatible, which weβll run before we deploy any new code that includes database
43migrations.
44
47 "slug": "codegen",
48 "link": "/blog/codegen",
49 "description": "Like Claude Artifacts, but with a backend and database",
50 "pubDate": "Thu, 22 Aug 2024 00:00:00 GMT",
51 "author": "JP Posma",
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
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
46 }
47
48 // Now it's time to upload things to database and blob storage
49 // First, add to database, and get the ID
50 const id = await sqlite.execute(
51 `INSERT INTO ${TABLE_NAME} (title, data, type, time) VALUES ($title, $data, $type, $time)`,
1import { parseProject, readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
2import { Hono } from "npm:hono";
3import { getMessages, insertMessage } from "./database/queries.ts";
4
5const app = new Hono();
190
191/**
192 * Get database statistics for the homepage
193 */
194export async function getSearchStats(): Promise<{
873 const offset = (page - 1) * pageSize;
874
875 // Start all database queries in parallel
876 // 1. Launch count queries
877 const countsPromise = withTiming(() => Promise.all([
960 ));
961
962 // Wait for all database operations to complete in parallel
963 const [
964 [countsResult, countsTime],
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