fix(epg): preserve source metadata through cache cleanup

This commit is contained in:
4gray committed 2026-09-05 23:28:40 +02:00
1 parent 6d406c85e2
commit dc0b7581cb
16 files changed
+514 -59

No files matched your search

@@ -288,6 +288,17 @@ const CREATE_TABLE_STATEMENTS = [
source_url TEXT NOT NULL,
updated_at TEXT DEFAULT (datetime('now'))
)`,
`CREATE TABLE IF NOT EXISTS epg_channel_sources (
channel_id TEXT NOT NULL,
source_url TEXT NOT NULL,
display_name TEXT NOT NULL,
icon_url TEXT,
url TEXT,
updated_at TEXT DEFAULT (datetime('now')),
PRIMARY KEY (channel_id, source_url),
FOREIGN KEY (channel_id) REFERENCES epg_channels(id) ON DELETE CASCADE
)`,
`CREATE INDEX IF NOT EXISTS idx_epg_channel_sources_source ON epg_channel_sources(source_url)`,
`CREATE TABLE IF NOT EXISTS epg_programs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
channel_id TEXT NOT NULL,
+20
View File
@@ -11,6 +11,7 @@ import { sql } from 'drizzle-orm';
import {
index,
integer,
primaryKey,
sqliteTable,
text,
uniqueIndex,
@@ -204,6 +205,25 @@ export const epgChannels = sqliteTable(
})
);
// A global XMLTV ID can be shared by sources with different channel metadata.
export const epgChannelSources = sqliteTable(
'epg_channel_sources',
{
channelId: text('channel_id')
.notNull()
.references(() => epgChannels.id, { onDelete: 'cascade' }),
sourceUrl: text('source_url').notNull(),
displayName: text('display_name').notNull(),
iconUrl: text('icon_url'),
url: text('url'),
updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`),
},
(table) => [
primaryKey({ columns: [table.channelId, table.sourceUrl] }),
index('idx_epg_channel_sources_source').on(table.sourceUrl),
]
);
// EPG Programs table
export const epgPrograms = sqliteTable(
'epg_programs',