backend
This commit is contained in:
commit
d7666f7b2c
44 changed files with 2246 additions and 0 deletions
19
backend/models/document.py
Normal file
19
backend/models/document.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
from core.database import Base
|
||||
|
||||
class Document(Base):
|
||||
__tablename__ = "documents"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
filename = Column(String, nullable=False)
|
||||
filepath = Column(String, unique=True, nullable=False) # Chemin unique pour le stockage
|
||||
owner_id = Column(Integer, ForeignKey("users.id")) # Clé étrangère vers l'utilisateur
|
||||
uploaded_at = Column(DateTime, default=func.now())
|
||||
|
||||
# Relation avec l'utilisateur propriétaire
|
||||
owner = relationship("User", back_populates="documents")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Document(filename='{self.filename}', owner_id={self.owner_id})>"
|
Loading…
Add table
Add a link
Reference in a new issue