21 lines
511 B
TypeScript
21 lines
511 B
TypeScript
/**
|
|
* Drops `users.is_admin`, now that 0004 has copied it into `users.role`.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
import type { DatabaseSync } from "node:sqlite";
|
|
|
|
/**
|
|
* Run once by `runMigrations`, after 0004. A database made from schema.sql
|
|
* never had the column.
|
|
*/
|
|
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;`);
|
|
}
|
|
}
|