add scanning
This commit is contained in:
@@ -71,9 +71,46 @@ function initDb(db: Database.Database): void {
|
||||
tv_loop INTEGER NOT NULL DEFAULT 0,
|
||||
tv_muted INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS app_settings (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS media_items (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
library_id TEXT NOT NULL REFERENCES libraries(id) ON DELETE CASCADE,
|
||||
item_key TEXT NOT NULL UNIQUE,
|
||||
item_type TEXT NOT NULL CHECK(item_type IN ('movie','tv_series','tv_season','tv_episode','game','game_series')),
|
||||
parent_key TEXT,
|
||||
title TEXT,
|
||||
year INTEGER,
|
||||
plot TEXT,
|
||||
genres TEXT,
|
||||
metadata TEXT,
|
||||
scanned_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS media_items_library_id ON media_items(library_id);
|
||||
CREATE INDEX IF NOT EXISTS media_items_parent_key ON media_items(parent_key);
|
||||
`)
|
||||
|
||||
migrateLibrariesType(db)
|
||||
seedAppSettings(db)
|
||||
}
|
||||
|
||||
function seedAppSettings(db: Database.Database): void {
|
||||
const defaults: Record<string, string> = {
|
||||
scan_schedule: '0 * * * *',
|
||||
scan_enabled: 'true',
|
||||
scan_last_ran: '',
|
||||
}
|
||||
const insert = db.prepare(
|
||||
'INSERT OR IGNORE INTO app_settings (key, value) VALUES (?, ?)'
|
||||
)
|
||||
for (const [key, value] of Object.entries(defaults)) {
|
||||
insert.run(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
function migrateLibrariesType(db: Database.Database): void {
|
||||
|
||||
Reference in New Issue
Block a user