Added the foreign key in photo.py to the travel_diary table so a photo is contained in a diary

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-06-05 20:02:41 -03:00
parent 32b8a58c3a
commit f556d6906a
2 changed files with 15 additions and 13 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
from typing import Any
from sqlalchemy import Column, Integer, String
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from pilgrim.models.photo_in_entry import photo_entry_association
@@ -20,6 +20,8 @@ class Photo(Base):
back_populates="photos"
)
fk_travel_diary_id = Column(Integer, ForeignKey("travel_diaries.id"))
def __init__(self, filepath, name, addition_date=None, caption=None, entries=None, **kw: Any):
super().__init__(**kw)
self.filepath = filepath