categories as dropdown

This commit is contained in:
MDeeApp
2025-10-11 14:02:20 +02:00
parent 6d15382464
commit 17e094e8ac
11 changed files with 471 additions and 25 deletions

View File

@@ -43,8 +43,34 @@ CREATE TABLE IF NOT EXISTS settings (
value TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS categories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE COLLATE NOCASE,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
);
`);
const defaultCategories = [
"Versicherung",
"Strom & Energie",
"Internet & Telefon",
"Miete & Wohnen",
"Mobilfunk",
"Streaming & Medien",
"Wartung & Service"
];
const categoryRow = db.prepare(`SELECT COUNT(*) as count FROM categories`).get() as { count: number } | undefined;
const categoryCount = categoryRow?.count ?? 0;
if (categoryCount === 0) {
const insertStmt = db.prepare(`INSERT OR IGNORE INTO categories (name) VALUES (?)`);
for (const name of defaultCategories) {
insertStmt.run(name);
}
}
export type ContractDbRow = {
id: number;
title: string;