From e4d9a9812a44e45011ec9491f7c896e3eb06c6fa Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 15:59:15 +0000 Subject: [PATCH] Add migration for Food --- .../20250328_155859_77d2612a_create_food.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 alembic/versions/20250328_155859_77d2612a_create_food.py diff --git a/alembic/versions/20250328_155859_77d2612a_create_food.py b/alembic/versions/20250328_155859_77d2612a_create_food.py new file mode 100644 index 0000000..9c810f1 --- /dev/null +++ b/alembic/versions/20250328_155859_77d2612a_create_food.py @@ -0,0 +1,35 @@ +"""create foods table + +Revision ID: 6d7a3c2b1f5a +Revises: 2f6c1d1f8f28 +Create Date: 2023-05-11 15:23:47.550116 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects.postgresql import UUID +import uuid + + +# revision identifiers, used by Alembic. +revision = '6d7a3c2b1f5a' +down_revision = '2f6c1d1f8f28' +branch_labels = None +depends_on = None + + +def upgrade(): + op.create_table( + 'foods', + sa.Column('id', UUID(as_uuid=True), primary_key=True, default=uuid.uuid4), + sa.Column('name', sa.String, nullable=False, unique=True), + sa.Column('description', sa.String, nullable=True), + sa.Column('price', sa.Float, nullable=False), + sa.Column('category_id', UUID, sa.ForeignKey("food_categories.id")), + sa.Column('created_at', sa.DateTime, server_default=sa.func.now()), + sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now()) + ) + + +def downgrade(): + op.drop_table('foods') \ No newline at end of file