worldhopper/lib/database/tables/publications_table.dart
Felipe M. 58a562abe8
feat: refactor server software abstraction with Kavita REST API integration
Rename all OPDS-prefixed models to generic names (Server, Feed, Entry,
Link, StreamLink), expand the ServerSoftware interface to cover all
server interactions, and implement a full Kavita REST API client that
replaces the OPDS delegation.

- Rename OPDS* models to generic names across ~60 files
- Add database migrations 13 (opds_id → entry_id) and 14 (unify credentials)
- Create OPDSServerSoftware wrapping existing OPDS services
- Create KavitaApiClient for direct Kavita REST API calls
- Create KavitaFeedMapper to convert Kavita JSON to Feed/Entry models
- Rewrite KavitaServerSoftware to use native API (no OPDS delegation)
- Unify server credentials (remove softwareUsername/softwarePassword)
- Simplify add/edit server UI to single auth section
- Add test connection button to server add/edit screens
- Add progress indicator to PublicationCard using local and server data
- Eliminate softwareType branching in reader screens
- Add EntryProgress and fetchEntryProgress to ServerSoftware interface
- Fix Entry.acquisitionLink crash on empty links
- Add 59 new tests covering models, services, and providers
2026-04-06 17:46:48 +02:00

59 lines
1.7 KiB
Dart

/// SQL schema for the publications table
class PublicationsTable {
PublicationsTable._();
static const String tableName = 'publications';
/// SQL statement to create the publications table
static const String createTable = '''
CREATE TABLE $tableName (
id TEXT PRIMARY KEY,
server_id TEXT NOT NULL,
entry_id TEXT NOT NULL,
title TEXT NOT NULL,
authors TEXT,
summary TEXT,
content TEXT,
cover_path TEXT,
thumbnail_path TEXT,
cover_url TEXT,
thumbnail_url TEXT,
series TEXT,
series_position REAL,
publisher TEXT,
language TEXT,
isbn TEXT,
categories TEXT,
links TEXT,
stream_link TEXT,
published INTEGER,
updated INTEGER,
first_cached_at INTEGER NOT NULL,
last_cached_at INTEGER NOT NULL,
last_accessed_at INTEGER NOT NULL,
FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE,
UNIQUE(server_id, entry_id)
)
''';
/// SQL statement to drop the publications table
static const String dropTable = 'DROP TABLE IF EXISTS $tableName';
/// Create index on server_id for faster lookups
static const String createServerIndex = '''
CREATE INDEX idx_publications_server_id
ON $tableName(server_id)
''';
/// Create composite index on server_id and entry_id for unique lookups
static const String createServerEntryIndex = '''
CREATE INDEX idx_publications_server_entry
ON $tableName(server_id, entry_id)
''';
/// Create index on last_accessed_at for cache cleanup
static const String createAccessedIndex = '''
CREATE INDEX idx_publications_last_accessed
ON $tableName(last_accessed_at)
''';
}