28 lines
995 B
Python
28 lines
995 B
Python
"""
|
|
Database model for orbits table
|
|
"""
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, Float, Text, DateTime, ForeignKey, Index
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from app.database import Base
|
|
|
|
|
|
class Orbit(Base):
|
|
"""Orbital path data for celestial bodies"""
|
|
|
|
__tablename__ = "orbits"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
body_id = Column(Text, ForeignKey("celestial_bodies.id", ondelete="CASCADE"), nullable=False, unique=True)
|
|
points = Column(JSONB, nullable=False) # Array of {x, y, z} points
|
|
num_points = Column(Integer, nullable=False)
|
|
period_days = Column(Float, nullable=True)
|
|
color = Column(String(20), nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
__table_args__ = (
|
|
Index('idx_orbits_body_id', 'body_id'),
|
|
Index('idx_orbits_updated_at', 'updated_at'),
|
|
)
|