Add Tree model
This commit is contained in:
parent
5e59b61c8b
commit
35156a028e
20
models/tree.py
Normal file
20
models/tree.py
Normal file
@ -0,0 +1,20 @@
|
||||
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())
|
Loading…
x
Reference in New Issue
Block a user