Add migration for Food
This commit is contained in:
parent
577d40634b
commit
e4d9a9812a
35
alembic/versions/20250328_155859_77d2612a_create_food.py
Normal file
35
alembic/versions/20250328_155859_77d2612a_create_food.py
Normal file
@ -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')
|
Loading…
x
Reference in New Issue
Block a user