25 lines
702 B
TypeScript
25 lines
702 B
TypeScript
/**
|
|
* Lets a poster upload a thumbnail that replaces the fetched one. It adds
|
|
* `dumps.custom_thumbnail_mime`, which holds the uploaded image's type; 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;`,
|
|
);
|
|
}
|
|
}
|