/** * Adds `dumps.custom_thumbnail_mime`, so a poster can upload a thumbnail that * replaces the fetched one. It holds the uploaded image's type, and NULL means * the dump has none. * * @module */ import type { DatabaseSync } from "node:sqlite"; /** * Run once by `runMigrations`. Existing dumps keep their fetched thumbnails, * and a database made from schema.sql already has the column. */ export function up(db: DatabaseSync): void { const dumpCols = db.prepare(`PRAGMA table_info(dumps);`).all() as { name: string; }[]; if (!dumpCols.some((c) => c.name === "custom_thumbnail_mime")) { db.exec( `ALTER TABLE dumps ADD COLUMN custom_thumbnail_mime TEXT;`, ); } }