2025-03-25 13:12:18 -05:00

20 lines
736 B
Python

from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.api.db.base_class import Base
import uuid
class Tree(Base):
__tablename__ = "trees"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
species = Column(String, nullable=False)
height = Column(Integer, nullable=False)
diameter = Column(Integer, nullable=False)
location_id = Column(Integer, ForeignKey("locations.id"), nullable=False)
location = relationship("Location", back_populates="trees")
created_at = Column(DateTime, default=func.now())
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())