Remove unused columns and simplify schema across database and routes

Drop `parent_id` from categories, remove `ai_category` and
`review_notes` from
transactions, and eliminate category/reviewed filters from transaction
queries.
Clean up code style and formatting.
This commit is contained in:
2026-05-06 22:16:36 +08:00
parent 965ef2058d
commit 08fbde8a39
4 changed files with 50 additions and 112 deletions
+1 -6
View File
@@ -59,7 +59,6 @@ function initDB() {
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
keywords TEXT,
parent_id INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
@@ -77,11 +76,9 @@ function initDB() {
description TEXT,
match_count INTEGER DEFAULT 1,
category TEXT,
ai_category TEXT,
ai_description TEXT,
ai_confidence REAL,
reviewed INTEGER DEFAULT 0,
review_notes TEXT,
reviewed_at DATETIME,
tags TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
@@ -98,7 +95,7 @@ function initDB() {
CREATE INDEX IF NOT EXISTS idx_tx_date ON transactions(transaction_date);
CREATE INDEX IF NOT EXISTS idx_tx_code ON transactions(transaction_code);
CREATE INDEX IF NOT EXISTS idx_tx_amount ON transactions(amount);
CREATE INDEX IF NOT EXISTS idx_tx_amount ON transactions(ABS(amount));
CREATE INDEX IF NOT EXISTS idx_tx_source ON transactions(source_type);
CREATE INDEX IF NOT EXISTS idx_tx_matched ON transactions(matched_transaction_id);
CREATE INDEX IF NOT EXISTS idx_deal_date ON deals(deal_date);
@@ -114,11 +111,9 @@ function initDB() {
const newCols = [
["direction", "TEXT"],
["category", "TEXT"],
["ai_category", "TEXT"],
["ai_description", "TEXT"],
["ai_confidence", "REAL"],
["reviewed", "INTEGER DEFAULT 0"],
["review_notes", "TEXT"],
["reviewed_at", "DATETIME"],
["tags", "TEXT"],
["updated_at", "DATETIME"],