fastfood-sg2gok/alembic/versions/20250328_155859_77d2612a_create_food.py
2025-03-28 15:59:15 +00:00

35 lines
984 B
Python

"""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')