Initial commit — PlantGuideScraper project
This commit is contained in:
21
backend/app/models/species.py
Normal file
21
backend/app/models/species.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, func
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Species(Base):
|
||||
__tablename__ = "species"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
scientific_name = Column(String, unique=True, nullable=False, index=True)
|
||||
common_name = Column(String, nullable=True)
|
||||
genus = Column(String, nullable=True, index=True)
|
||||
family = Column(String, nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
# Relationships
|
||||
images = relationship("Image", back_populates="species", cascade="all, delete-orphan")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Species(id={self.id}, scientific_name='{self.scientific_name}')>"
|
||||
Reference in New Issue
Block a user