Add backend/app/models/comment.py
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
"""Comment model."""
|
||||||
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Text
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from datetime import datetime
|
||||||
|
from app.database import Base
|
||||||
|
|
||||||
|
class Comment(Base):
|
||||||
|
"""Comment model."""
|
||||||
|
__tablename__ = "comments"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
content = Column(Text, nullable=False)
|
||||||
|
author_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||||
|
table_id = Column(Integer, ForeignKey("tables.id"), nullable=True)
|
||||||
|
record_id = Column(Integer, nullable=True)
|
||||||
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
|
author = relationship("User", back_populates="comments")
|
||||||
Reference in New Issue
Block a user