From ab64e9f8c5c48b68412e0bea0924f075436ea4bf Mon Sep 17 00:00:00 2001 From: "[esekyi]" <[sskert10@gmail.com]> Date: Tue, 27 Aug 2024 03:44:44 +0000 Subject: [PATCH] =?UTF-8?q?[Update=F0=9F=93=A2]=20Implement=20instructions?= =?UTF-8?q?=20model=20for=20recipe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/__init__.py | 1 + app/models/instruction.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 app/models/instruction.py diff --git a/app/models/__init__.py b/app/models/__init__.py index ed4693f..5b065ca 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -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 diff --git a/app/models/instruction.py b/app/models/instruction.py new file mode 100644 index 0000000..2444c91 --- /dev/null +++ b/app/models/instruction.py @@ -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''