21 lines
840 B
Python
21 lines
840 B
Python
|
|
"""Table 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 Table(Base):
|
||
|
|
"""Table model."""
|
||
|
|
__tablename__ = "tables"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True, index=True)
|
||
|
|
name = Column(String(255), nullable=False)
|
||
|
|
description = Column(Text)
|
||
|
|
workspace_id = Column(Integer, ForeignKey("workspaces.id"), nullable=False)
|
||
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||
|
|
|
||
|
|
workspace = relationship("Workspace", back_populates="tables")
|
||
|
|
columns = relationship("Column", back_populates="table", cascade="all, delete-orphan")
|
||
|
|
views = relationship("View", back_populates="table")
|