chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
@@ -1,19 +1,30 @@
|
||||
"""Comment model."""
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import String, DateTime, ForeignKey, func, Index
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
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)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
record_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("records.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=True)
|
||||
content: Mapped[str] = mapped_column(String, nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
|
||||
author = relationship("User", back_populates="comments")
|
||||
# Relationships
|
||||
record = relationship("Record", back_populates="comments")
|
||||
user = relationship("User", back_populates="comments")
|
||||
|
||||
__table_args__ = (Index("idx_comments_record", "record_id"),)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Comment(id={self.id}, record_id={self.record_id})>"
|
||||
|
||||
Reference in New Issue
Block a user