From 61fb563fbdeb85fd1e64d6a87e81581713f84b30 Mon Sep 17 00:00:00 2001 From: Salem <40477317+SalemOurabi@users.noreply.github.com> Date: Sun, 19 Jul 2026 12:15:15 +0200 Subject: [PATCH] refactor(database): split EPG mapping schema out of oversized schema.ts (#1213) schema.ts grew past the 400-line lint budget with the manual EPG-to-channel mapping table (#1165), which breaks lint for every PR. Move the mapping table and its types into epg-mapping.schema.ts and re-export them from schema.ts so the schema namespace and all existing imports stay unchanged. --- .../database/src/lib/epg-mapping.schema.ts | 30 +++++++++++++++++++ libs/shared/database/src/lib/schema.ts | 24 +++------------ 2 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 libs/shared/database/src/lib/epg-mapping.schema.ts diff --git a/libs/shared/database/src/lib/epg-mapping.schema.ts b/libs/shared/database/src/lib/epg-mapping.schema.ts new file mode 100644 index 000000000..edb0c9538 --- /dev/null +++ b/libs/shared/database/src/lib/epg-mapping.schema.ts @@ -0,0 +1,30 @@ +/** + * Drizzle ORM schema for manual EPG-to-channel mappings. + * + * Split out of schema.ts to keep that file within the repository's + * max-lines budget; re-exported from there so `import * as schema` + * consumers keep seeing a single schema namespace. + */ + +import { sql } from 'drizzle-orm'; +import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; + +// EPG channel mappings (manual user overrides) +export const epgChannelMappings = sqliteTable( + 'epg_channel_mappings', + { + id: integer('id').primaryKey({ autoIncrement: true }), + channelKey: text('channel_key').notNull().unique(), + epgChannelId: text('epg_channel_id').notNull(), + playlistId: text('playlist_id'), + updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`), + }, + (table) => ({ + playlistIdx: index('idx_epg_channel_mappings_playlist').on( + table.playlistId + ), + }) +); + +export type EpgChannelMapping = typeof epgChannelMappings.$inferSelect; +export type NewEpgChannelMapping = typeof epgChannelMappings.$inferInsert; diff --git a/libs/shared/database/src/lib/schema.ts b/libs/shared/database/src/lib/schema.ts index 1c00709ba..fe12dce54 100644 --- a/libs/shared/database/src/lib/schema.ts +++ b/libs/shared/database/src/lib/schema.ts @@ -16,6 +16,10 @@ import { uniqueIndex, } from 'drizzle-orm/sqlite-core'; +// Manual EPG-to-channel mappings live in their own schema module; re-export +// them so `import * as schema from './schema'` keeps a complete namespace. +export * from './epg-mapping.schema'; + // Playlists table export const playlists = sqliteTable('playlists', { id: text('id').primaryKey(), @@ -350,26 +354,6 @@ export const downloads = sqliteTable( }) ); -// EPG channel mappings (manual user overrides) -export const epgChannelMappings = sqliteTable( - 'epg_channel_mappings', - { - id: integer('id').primaryKey({ autoIncrement: true }), - channelKey: text('channel_key').notNull().unique(), - epgChannelId: text('epg_channel_id').notNull(), - playlistId: text('playlist_id'), - updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`), - }, - (table) => ({ - playlistIdx: index('idx_epg_channel_mappings_playlist').on( - table.playlistId - ), - }) -); - -export type EpgChannelMapping = typeof epgChannelMappings.$inferSelect; -export type NewEpgChannelMapping = typeof epgChannelMappings.$inferInsert; - export type Download = typeof downloads.$inferSelect; export type NewDownload = typeof downloads.$inferInsert;