Add migration for Food
This commit is contained in:
parent
88d312a3e3
commit
7e0e17401e
34
alembic/versions/20250328_135301_7412a8fc_create_food.py
Normal file
34
alembic/versions/20250328_135301_7412a8fc_create_food.py
Normal 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')
|
Loading…
x
Reference in New Issue
Block a user