mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-12 12:37:32 +00:00
Persist OCR captions in gallery
This commit is contained in:
@@ -276,6 +276,7 @@ class GalleryImage(TimestampMixin, Base):
|
||||
id = Column(String, primary_key=True, index=True)
|
||||
filename = Column(String, nullable=False, unique=True)
|
||||
prompt = Column(Text, nullable=False, default="")
|
||||
caption = Column(Text, nullable=True, default="")
|
||||
model = Column(String, nullable=True)
|
||||
size = Column(String, nullable=True)
|
||||
quality = Column(String, nullable=True)
|
||||
@@ -1182,6 +1183,29 @@ def _migrate_add_multiuser_owner_columns():
|
||||
_migrate_add_owner_to_table("documents", "ix_documents_owner")
|
||||
|
||||
|
||||
def _migrate_add_gallery_caption_column():
|
||||
"""Add OCR/vision caption storage for gallery images."""
|
||||
import sqlite3
|
||||
db_path = DATABASE_URL.replace("sqlite:///", "")
|
||||
if not os.path.exists(db_path):
|
||||
return
|
||||
conn = None
|
||||
try:
|
||||
conn = sqlite3.connect(db_path)
|
||||
columns = [row[1] for row in conn.execute("PRAGMA table_info(gallery_images)").fetchall()]
|
||||
if columns and "caption" not in columns:
|
||||
conn.execute("ALTER TABLE gallery_images ADD COLUMN caption TEXT DEFAULT ''")
|
||||
conn.commit()
|
||||
logging.getLogger(__name__).info("Migrated: added caption column to gallery_images")
|
||||
except Exception as e:
|
||||
logging.getLogger(__name__).warning(f"Migration gallery caption column failed: {e}")
|
||||
finally:
|
||||
try:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _migrate_add_api_token_scopes_column():
|
||||
"""Add API token scopes for existing installs.
|
||||
|
||||
@@ -1812,6 +1836,7 @@ def init_db():
|
||||
_migrate_add_token_columns()
|
||||
_migrate_add_mode_column()
|
||||
_migrate_add_multiuser_owner_columns()
|
||||
_migrate_add_gallery_caption_column()
|
||||
_migrate_add_api_token_scopes_column()
|
||||
_migrate_backfill_document_owner_from_session()
|
||||
_migrate_assign_legacy_owner()
|
||||
|
||||
Reference in New Issue
Block a user