feat(db): introduce SQLite (better-sqlite3) backing store
First step of the folder/video refactor. Adds an app-local SQLite DB at
data/app.db with schema for nested folders (max 2 levels enforced in
code, not SQL) and user-editable globally-unique video IDs.
- src/db.ts: open + WAL + schema (folders, videos) + partial unique
index for top-level folder names (NULL parent_id case)
- One-shot disk-tree migration: on first start scans data/folders/*
and seeds folder rows; reads each {videoId}/meta.json to seed video
rows. Skips invalid/missing meta gracefully.
- Wired into app.ts startup before routes mount.
- gitignore: data/app.db* (DB + WAL/journal sidecars).
Schema only — no routes or store.ts changes yet. Next step swaps the
file-based store calls to DB-backed equivalents.
Smoke-tested on the current data dir: 3 folders migrated, 0 videos
(folders were empty). Build (npx tsc) passes.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
"dev": "tsc -p tsconfig.json && node dist/app.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"better-sqlite3": "^12.10.0",
|
||||
"dotenv": "^16.6.1",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
|
||||
Reference in New Issue
Block a user