Add Bird model
This commit is contained in:
parent
2dad31ee49
commit
d652ee0add
27
models/bird.py
Normal file
27
models/bird.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from sqlalchemy import Column, String, Integer, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
from core.database import Base
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
class Bird(Base):
|
||||||
|
__tablename__ = "birds"
|
||||||
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
name = Column(String, nullable=False, unique=True, index=True)
|
||||||
|
species = Column(String, nullable=False)
|
||||||
|
description = Column(String)
|
||||||
|
age = Column(Integer)
|
||||||
|
created_at = Column(
|
||||||
|
"created_at",
|
||||||
|
ForeignKey("created_at_metadata.id"),
|
||||||
|
nullable=False,
|
||||||
|
default=func.now(),
|
||||||
|
)
|
||||||
|
updated_at = Column(
|
||||||
|
"updated_at",
|
||||||
|
ForeignKey("updated_at_metadata.id"),
|
||||||
|
nullable=False,
|
||||||
|
default=func.now(),
|
||||||
|
onupdate=func.now(),
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user