chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
@@ -1,19 +1,38 @@
|
||||
"""Column model."""
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import String, DateTime, Boolean, ForeignKey, Integer, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy import JSON
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Column(Base):
|
||||
"""Column model."""
|
||||
__tablename__ = "columns"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
field_type = Column(String(50), nullable=False) # text, number, date, select, etc.
|
||||
table_id = Column(Integer, ForeignKey("tables.id"), nullable=False)
|
||||
position = Column(Integer, default=0)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
table_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("tables.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
type: Mapped[str] = mapped_column(
|
||||
String(50), nullable=False
|
||||
) # text, number, date, select, etc.
|
||||
required: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
default_value: Mapped[Optional[str]] = mapped_column(String, nullable=True)
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
options: Mapped[Optional[dict]] = mapped_column(
|
||||
JSON, nullable=True
|
||||
) # For select type: {"options": ["a", "b"]}
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=func.now())
|
||||
|
||||
# Relationships
|
||||
table = relationship("Table", back_populates="columns")
|
||||
records = relationship("Record", back_populates="column")
|
||||
cell_values = relationship(
|
||||
"CellValue", back_populates="column", cascade="all, delete-orphan"
|
||||
)
|
||||
attachments = relationship("Attachment", back_populates="column")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Column(id={self.id}, name={self.name}, type={self.type})>"
|
||||
|
||||
Reference in New Issue
Block a user