14 lines
650 B
Python
14 lines
650 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 Organization(Base):
|
|
__tablename__ = 'organizations'
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
|
name: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
|
|
owner_id: Mapped[int] = mapped_column(Integer, ForeignKey('users.id'), nullable=False)
|
|
owner: Mapped['User'] = relationship('User', back_populates='orgs')
|
|
files: Mapped[list['File']] = relationship('File', back_populates='org') |