完善节目管理与回放播放体验
This commit is contained in:
1 parent
b265518084
commit
a493ef2309
14 files changed
+446
-96
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
from sqlalchemy import text
|
||||
|
||||
from config import settings
|
||||
|
||||
@@ -19,3 +20,16 @@ async def get_db() -> AsyncSession:
|
||||
async def init_db():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
if settings.database_url.startswith("sqlite"):
|
||||
columns = {
|
||||
"replay_file": "VARCHAR(500)",
|
||||
"chapters_json": "TEXT",
|
||||
"transcode_profile": "VARCHAR(64) NOT NULL DEFAULT 'standard'",
|
||||
"homepage_visible": "BOOLEAN NOT NULL DEFAULT 1",
|
||||
"remote_control_enabled": "BOOLEAN NOT NULL DEFAULT 0",
|
||||
}
|
||||
rows = await conn.execute(text("PRAGMA table_info(streams)"))
|
||||
existing = {row[1] for row in rows}
|
||||
for name, definition in columns.items():
|
||||
if name not in existing:
|
||||
await conn.execute(text(f"ALTER TABLE streams ADD COLUMN {name} {definition}"))
|
||||
Reference in new issue
Block a user