17 lines
707 B
Python
17 lines
707 B
Python
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, func
|
|
from sqlalchemy.orm import relationship
|
|
from app.database import Base
|
|
|
|
class Project(Base):
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
owner_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
created_at = Column(DateTime, default=func.now())
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
|
|
|
|
owner = relationship("User", back_populates="projects")
|
|
data_sources = relationship("DataSource", back_populates="project", cascade="all, delete-orphan")
|