23 lines
834 B
Python
23 lines
834 B
Python
from __future__ import annotations
|
|
|
|
from sqlalchemy import ForeignKey, Index, Integer, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.db.base import Base
|
|
|
|
|
|
class RfProjectYear(Base):
|
|
__tablename__ = "rf_project_year"
|
|
__table_args__ = (
|
|
UniqueConstraint("project_id", "year", name="uq_v3_rf_project_year"),
|
|
Index("ix_v3_rf_project_year_project", "project_id"),
|
|
{"schema": "v3"},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
project_id: Mapped[int] = mapped_column(Integer, ForeignKey("v3.project.id"))
|
|
year: Mapped[int] = mapped_column(Integer)
|
|
|
|
project: Mapped["Project"] = relationship("Project") # type: ignore
|
|
smetas: Mapped[list["Smeta"]] = relationship("Smeta", back_populates="rf_project_year") # type: ignore
|