20 lines
934 B
Python
20 lines
934 B
Python
from sqlalchemy import Integer, String, ForeignKey
|
|
from sqlalchemy.orm import relationship, Mapped, mapped_column
|
|
from database import Base
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class File(Base):
|
|
__tablename__ = 'files'
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
|
file_handle: Mapped[str] = mapped_column(String, nullable=False)
|
|
document_handle: Mapped[str] = mapped_column(String, nullable=False)
|
|
name: Mapped[str] = mapped_column(String, nullable=False)
|
|
created_at: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
org_id: Mapped[int] = mapped_column(Integer, ForeignKey('organizations.id'), nullable=False)
|
|
creator_id: Mapped[int] = mapped_column(Integer, ForeignKey('users.id'), nullable=False)
|
|
org: Mapped['Organization'] = relationship('Organization', back_populates='files')
|
|
creator: Mapped['User'] = relationship('User', back_populates='files')
|