""" Celestial Event ORM model """ from sqlalchemy import Column, String, Integer, TIMESTAMP, Text, JSON, ForeignKey from sqlalchemy.sql import func from sqlalchemy.orm import relationship from app.database import Base class CelestialEvent(Base): """Celestial event model (e.g., close approaches, oppositions)""" __tablename__ = "celestial_events" id = Column(Integer, primary_key=True, autoincrement=True) body_id = Column(String(50), ForeignKey("celestial_bodies.id", ondelete="CASCADE"), nullable=False) title = Column(String(200), nullable=False) event_type = Column(String(50), nullable=False) # 'approach', 'opposition', 'conjunction' event_time = Column(TIMESTAMP, nullable=False) description = Column(Text, nullable=True) details = Column(JSON, nullable=True) # JSONB for PostgreSQL, JSON for SQLite/other source = Column(String(50), default='nasa_sbdb') # 'nasa_sbdb', 'calculated' created_at = Column(TIMESTAMP, server_default=func.now()) # Relationship to celestial body body = relationship("CelestialBody", foreign_keys=[body_id]) def __repr__(self): return f""