| 310 | |
| 311 | |
| 312 | class Project(Base): |
| 313 | __tablename__: str = "project" |
| 314 | |
| 315 | id: Mapped[str] = mapped_column( |
| 316 | String(32), primary_key=True, default=lambda: token_hex(16) |
| 317 | ) |
| 318 | name: Mapped[str] = mapped_column(String(100), index=True) |
| 319 | has_avatar: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) |
| 320 | repo_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True) |
| 321 | repo_full_name: Mapped[str] = mapped_column(String(255), nullable=False, index=True) |
| 322 | repo_status: Mapped[str] = mapped_column( |
| 323 | SQLAEnum( |
| 324 | "active", "deleted", "removed", "transferred", name="project_github_status" |
| 325 | ), |
| 326 | nullable=False, |
| 327 | default="active", |
| 328 | ) |
| 329 | github_installation_id: Mapped[int] = mapped_column( |
| 330 | ForeignKey("github_installation.installation_id"), nullable=False, index=True |
| 331 | ) |
| 332 | environments: Mapped[list[dict[str, str]]] = mapped_column( |
| 333 | JSON, nullable=False, default=list |
| 334 | ) |
| 335 | _env_vars: Mapped[str] = mapped_column("env_vars", Text, nullable=False, default="") |
| 336 | slug: Mapped[str] = mapped_column(String(40), nullable=True, unique=True) |
| 337 | config: Mapped[dict[str, object]] = mapped_column( |
| 338 | JSON, nullable=False, default=dict |
| 339 | ) |
| 340 | created_by_user_id: Mapped[int | None] = mapped_column( |
| 341 | ForeignKey("user.id", use_alter=True, ondelete="SET NULL"), nullable=True |
| 342 | ) |
| 343 | created_at: Mapped[datetime] = mapped_column( |
| 344 | index=True, nullable=False, default=utc_now |
| 345 | ) |
| 346 | updated_at: Mapped[datetime] = mapped_column( |
| 347 | index=True, nullable=False, default=utc_now, onupdate=utc_now |
| 348 | ) |
| 349 | status: Mapped[str] = mapped_column( |
| 350 | SQLAEnum("active", "paused", "deleted", name="project_status"), |
| 351 | nullable=False, |
| 352 | default="active", |
| 353 | ) |
| 354 | team_id: Mapped[str] = mapped_column(ForeignKey("team.id"), index=True) |
| 355 | |
| 356 | # Relationships |
| 357 | github_installation: Mapped[GithubInstallation] = relationship( |
| 358 | back_populates="projects" |
| 359 | ) |
| 360 | deployments: Mapped[list["Deployment"]] = relationship(back_populates="project") |
| 361 | team: Mapped[Team] = relationship(back_populates="projects") |
| 362 | created_by_user: Mapped[User | None] = relationship( |
| 363 | foreign_keys=[created_by_user_id] |
| 364 | ) |
| 365 | domains: Mapped[list["Domain"]] = relationship(back_populates="project") |
| 366 | storage_links: Mapped[list["StorageProject"]] = relationship( |
| 367 | back_populates="project" |
| 368 | ) |
| 369 |
no outgoing calls
no test coverage detected