29 lines
932 B
TypeScript
29 lines
932 B
TypeScript
/**
|
|
* Gives each user settings stored on the server, so that they follow the
|
|
* account across browsers and the server can read them: the digests need the
|
|
* reader's choice to receive them and their style. `user_settings` holds one
|
|
* row per user who changed anything; a user without one has the defaults.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
import type { DatabaseSync } from "node:sqlite";
|
|
|
|
/**
|
|
* Run once by `runMigrations`. Existing users get no row, so they start with
|
|
* the defaults, digests on, like a new account.
|
|
*/
|
|
export function up(db: DatabaseSync): void {
|
|
db.exec(`
|
|
CREATE TABLE IF NOT EXISTS user_settings (
|
|
user_id TEXT PRIMARY KEY,
|
|
style TEXT,
|
|
color_scheme TEXT,
|
|
digest_weekly INTEGER NOT NULL DEFAULT 1,
|
|
digest_monthly INTEGER NOT NULL DEFAULT 1,
|
|
updated_at TEXT NOT NULL,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
`);
|
|
}
|