Add migration for Food
This commit is contained in:
parent
ecb161828d
commit
cd7497daea
34
alembic/versions/20250328_094500_dd291f0d_create_food.py
Normal file
34
alembic/versions/20250328_094500_dd291f0d_create_food.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""create foods table
|
||||
|
||||
Revision ID: 1c2d3e4f5a6b
|
||||
Revises: 9d0e4bcd7e8f
|
||||
Create Date: 2023-05-23 10:15:32.815048
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c2d3e4f5a6b'
|
||||
down_revision = '9d0e4bcd7e8f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'foods',
|
||||
sa.Column('id', UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||
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_id', UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=func.now(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=func.now(), nullable=False, onupdate=func.now())
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('foods')
|
Loading…
x
Reference in New Issue
Block a user