update models to use string type for id fields

This commit is contained in:
Thomas Peetz
2025-05-02 11:21:57 +02:00
committed by Thomas Peetz
parent e5fa32d653
commit 1786fecfed
16 changed files with 264 additions and 125 deletions
+7 -7
View File
@@ -6,7 +6,7 @@ from src.db.models.base import Base, BaseMixin
class MetaDataTable(Base, BaseMixin):
__tablename__ = 'meta_data_table'
table_name = Column(String(255), unique=True)
table_name = Column(String, unique=True)
table_columns = relationship("MetaDataColumn")
def __repr__(self):
@@ -18,15 +18,15 @@ class MetaDataTable(Base, BaseMixin):
class MetaDataColumn(Base, BaseMixin):
__tablename__ = 'meta_data_column'
column_name = Column(String(255), nullable=False)
column_sync_name = Column(String(255))
column_type = Column(String(255))
column_modifier = Column(String(255), nullable=True)
column_name = Column(String, nullable=False)
column_sync_name = Column(String)
column_type = Column(String)
column_modifier = Column(String, nullable=True)
column_order = Column(Integer)
table_id = Column(String, ForeignKey('meta_data_table.id'))
table = relationship("MetaDataTable", back_populates="table_columns")
column_label = Column(String(255))
filter_label = Column(String(255))
column_label = Column(String)
filter_label = Column(String)
is_shown = Column(Boolean)
show_filter = Column(Boolean)
ref_column = Column(String, nullable=True)
+27
View File
@@ -0,0 +1,27 @@
from typing import List, Type
from sqlalchemy.orm import Session
from src.db.models.comic import Artist, Comic
from src.schema.comics.artist import ArtistDetailResponse
def get_artist_details(artist: Artist) -> ArtistDetailResponse:
works = {}
for work in artist.comic_works:
work_type = work.work_type.name
comic_title = work.comic.title
if work_type in works:
works[work_type].append(comic_title)
else:
works[work_type] = [comic_title]
response = ArtistDetailResponse(
id=artist.id,
name=artist.name,
works=works
)
return response
def list_comics(db: Session) -> List[Type[Comic]]:
comics = db.query(Comic).all()
return comics