11from datetime import datetime
22
33from sqlmodel import Field , Relationship , SQLModel
4+ from embeddr_core .models .lineage import ImageLineage
45
56
67class LibraryPath (SQLModel , table = True ):
@@ -16,14 +17,39 @@ class LocalImage(SQLModel, table=True):
1617 id : int | None = Field (default = None , primary_key = True )
1718 path : str = Field (index = True , unique = True )
1819 filename : str
19- library_path_id : int | None = Field (default = None , foreign_key = "librarypath.id" )
20+ library_path_id : int | None = Field (
21+ default = None , foreign_key = "librarypath.id" )
2022 created_at : datetime = Field (default_factory = datetime .utcnow )
2123
2224 # Metadata
2325 width : int | None = None
2426 height : int | None = None
2527 file_size : int | None = None
2628 mime_type : str | None = None
29+ media_type : str = Field (default = "image" , index = True )
30+ duration : float | None = None
31+ fps : float | None = None
32+ frame_count : int | None = None
2733 prompt : str | None = None
34+ tags : str | None = None
35+ phash : str | None = Field (default = None , index = True )
36+ is_archived : bool = Field (default = False , index = True )
2837
2938 library : LibraryPath | None = Relationship (back_populates = "images" )
39+
40+ parents : list ["LocalImage" ] = Relationship (
41+ back_populates = "children" ,
42+ link_model = ImageLineage ,
43+ sa_relationship_kwargs = {
44+ "primaryjoin" : "LocalImage.id==ImageLineage.child_id" ,
45+ "secondaryjoin" : "LocalImage.id==ImageLineage.parent_id" ,
46+ },
47+ )
48+ children : list ["LocalImage" ] = Relationship (
49+ back_populates = "parents" ,
50+ link_model = ImageLineage ,
51+ sa_relationship_kwargs = {
52+ "primaryjoin" : "LocalImage.id==ImageLineage.parent_id" ,
53+ "secondaryjoin" : "LocalImage.id==ImageLineage.child_id" ,
54+ },
55+ )
0 commit comments