ервый импорт проекта
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""Comment model."""
|
||||
|
||||
from sqlalchemy import Column, Text, DateTime, ForeignKey, Integer
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.models.base import Base, TimestampMixin
|
||||
|
||||
|
||||
class Comment(Base, TimestampMixin):
|
||||
"""Comment model."""
|
||||
|
||||
__tablename__ = "comments"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
ticket_id = Column(Integer, ForeignKey("tickets.id", ondelete="CASCADE"), nullable=False)
|
||||
created_by = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
comment_text = Column(Text, nullable=False)
|
||||
|
||||
# Relationships
|
||||
ticket = relationship("Ticket", back_populates="comments")
|
||||
user = relationship("User", back_populates="comments")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Comment(id={self.id}, ticket_id={self.ticket_id})>"
|
||||
Reference in New Issue
Block a user