feat(database): add index on content type and added fields, set busy timeout and journal mode for database initialization

This commit is contained in:
4gray committed 2026-03-28 15:41:17 +01:00
1 parent 70b4d29b4b
commit 145fe74781
2 files changed
+10

No files matched your search

@@ -104,6 +104,7 @@ const CREATE_TABLE_STATEMENTS = [
`CREATE INDEX IF NOT EXISTS idx_categories_playlist ON categories(playlist_id)`,
`CREATE INDEX IF NOT EXISTS idx_content_title ON content(title)`,
`CREATE INDEX IF NOT EXISTS idx_content_xtream ON content(xtream_id)`,
`CREATE INDEX IF NOT EXISTS idx_content_type_added ON content(type, added)`,
`CREATE INDEX IF NOT EXISTS idx_categories_type ON categories(type)`,
`CREATE UNIQUE INDEX IF NOT EXISTS favorites_content_playlist_unique ON favorites(content_id, playlist_id)`,
`CREATE INDEX IF NOT EXISTS favorites_playlist_idx ON favorites(playlist_id)`,
@@ -300,6 +301,11 @@ export async function initDatabase(
// Enable foreign keys
sqlite.pragma('foreign_keys = ON');
sqlite.pragma('busy_timeout = 5000');
if (!readonly) {
sqlite.pragma('journal_mode = WAL');
}
// Create tables only for read-write connections
if (!readonly && !skipTableCreation) {
+4
View File
@@ -92,6 +92,10 @@ export const content = sqliteTable(
categoryIdx: index('idx_content_category').on(table.categoryId),
titleIdx: index('idx_content_title').on(table.title),
xtreamIdx: index('idx_content_xtream').on(table.xtreamId),
typeAddedIdx: index('idx_content_type_added').on(
table.type,
table.added
),
})
);