20 lines
598 B
TypeScript
20 lines
598 B
TypeScript
/**
|
|
* Drops the legacy is_admin column now that `role` is the single source of
|
|
* truth. Idempotent: skips when the column is already gone (fresh databases
|
|
* created from schema.sql never had it). Must run after 0004 has backfilled.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
import type { DatabaseSync } from "node:sqlite";
|
|
|
|
/** Applies this migration to `db`. */
|
|
export function up(db: DatabaseSync): void {
|
|
const userCols = db.prepare(`PRAGMA table_info(users);`).all() as {
|
|
name: string;
|
|
}[];
|
|
if (userCols.some((c) => c.name === "is_admin")) {
|
|
db.exec(`ALTER TABLE users DROP COLUMN is_admin;`);
|
|
}
|
|
}
|