Add migration for Food

This commit is contained in:
Backend IM Bot 2025-03-28 13:53:11 +00:00
parent 88d312a3e3
commit 7e0e17401e

View File

@ -0,0 +1,34 @@
"""create foods table
Revision ID: 8a7c6b9d2e3f
Revises: 0001
Create Date: 2023-05-25 16:32:45.123456
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.sql import func
from app.models import FoodCategory
# revision identifiers, used by Alembic.
revision = '8a7c6b9d2e3f'
down_revision = '0001'
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.Text, nullable=True),
sa.Column('price', sa.Float, nullable=False),
sa.Column('category', sa.Enum(FoodCategory), nullable=False),
sa.Column('is_available', sa.Boolean, default=True),
sa.Column('created_at', sa.DateTime, server_default=func.now()),
sa.Column('updated_at', sa.DateTime, server_default=func.now(), onupdate=func.now())
)
def downgrade():
op.drop_table('foods')