Spaces:
Sleeping
Sleeping
| from sqlalchemy import Column, Integer, String, DateTime, Text, JSON, Boolean, Float, ForeignKey | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import relationship | |
| from datetime import datetime | |
| Base = declarative_base() | |
| class Deployment(Base): | |
| __tablename__ = "deployments" | |
| id = Column(Integer, primary_key=True) | |
| deployment_id = Column(String(64), unique=True, nullable=False) | |
| name = Column(String(128), nullable=False) | |
| platform = Column(String(32), nullable=False) # render, cloudflare, huggingface, docker, kubernetes | |
| status = Column(String(32), default="pending") # pending, deploying, deployed, failed, rolled_back | |
| config = Column(JSON, nullable=False) # platform-specific config | |
| version = Column(String(32), nullable=True) # deployed version tag | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) | |
| deployed_at = Column(DateTime, nullable=True) | |
| health_checks = relationship("DeploymentHealth", back_populates="deployment") | |
| rollbacks = relationship("DeploymentRollback", back_populates="deployment") | |
| class DeploymentHealth(Base): | |
| __tablename__ = "deployment_health" | |
| id = Column(Integer, primary_key=True) | |
| deployment_id = Column(Integer, ForeignKey("deployments.id")) | |
| status = Column(String(32), default="pending") # healthy, degraded, unhealthy | |
| endpoint = Column(String(256), nullable=True) # health check URL | |
| response_time_ms = Column(Float, nullable=True) | |
| error = Column(Text, nullable=True) | |
| checked_at = Column(DateTime, default=datetime.utcnow) | |
| deployment = relationship("Deployment", back_populates="health_checks") | |
| class DeploymentRollback(Base): | |
| __tablename__ = "deployment_rollbacks" | |
| id = Column(Integer, primary_key=True) | |
| deployment_id = Column(Integer, ForeignKey("deployments.id")) | |
| rollback_to_version = Column(String(32), nullable=False) | |
| reason = Column(Text, nullable=True) | |
| triggered_by = Column(String(64), nullable=True) | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| deployment = relationship("Deployment", back_populates="rollbacks") | |