23 lines
872 B
Python
23 lines
872 B
Python
from sqlalchemy import Column, Integer, String, Text, Boolean, TIMESTAMP, ForeignKey, func
|
|
from sqlalchemy.orm import relationship
|
|
from geoalchemy2 import Geometry
|
|
from app.models.base import Base
|
|
|
|
class Route(Base):
|
|
__tablename__ = "routes"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
peak_id = Column(Integer, ForeignKey("peaks.id", ondelete="CASCADE"))
|
|
name = Column(String(100), nullable=False)
|
|
difficulty = Column(String(50))
|
|
# PostGIS LineStringZ (3D): SRID 4326
|
|
path_geometry = Column(Geometry("LINESTRINGZ", srid=4326))
|
|
description = Column(Text)
|
|
is_standard_route = Column(Boolean, default=False)
|
|
|
|
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now())
|
|
|
|
# Relationships
|
|
peak = relationship("Peak")
|
|
camps = relationship("Camp", back_populates="route", cascade="all, delete-orphan")
|