Skip to content

Commit

Permalink
[Update📢] Implement instructions model for recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
[esekyi] committed Aug 27, 2024
1 parent be53859 commit ab64e9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from app.models.recipe import Recipe
from app.models.comment import Comment
from app.models.ingredient import Ingredient
from app.models.instruction import Instruction
19 changes: 19 additions & 0 deletions app/models/instruction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from app import db
from datetime import datetime
import uuid
from sqlalchemy.dialects.postgresql import UUID


class Instruction(db.Model):
id = db.Column(UUID(as_uuid=True), primary_key=True,
default=uuid.uuid4)
step_number = db.Column(db.Integer, nullable=False)
name = db.Column(db.Text, nullable=False)
recipe_id = db.Column(UUID(as_uuid=True), db.ForeignKey(
'recipe.id'), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(
db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

def __repr__(self) -> str:
return f'<Instruction {self.step_number}: {self.name[:20]}>'

0 comments on commit ab64e9f

Please sign in to comment.