20 lines
751 B
Python
20 lines
751 B
Python
|
|
"""Column model."""
|
||
|
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||
|
|
from sqlalchemy.orm import relationship
|
||
|
|
from datetime import datetime
|
||
|
|
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)
|
||
|
|
|
||
|
|
table = relationship("Table", back_populates="columns")
|
||
|
|
records = relationship("Record", back_populates="column")
|