Add migration for Product
This commit is contained in:
parent
d71d20b9f3
commit
fc6f6d2ab7
34
alembic/versions/20250330_083327_786e7863_create_product.py
Normal file
34
alembic/versions/20250330_083327_786e7863_create_product.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""create products table
|
||||
|
||||
Revision ID: 2b4c6d8ea0f2
|
||||
Revises: 0001
|
||||
Create Date: 2023-05-19 14:27:59.123456
|
||||
|
||||
"""
|
||||
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 = '2b4c6d8ea0f2'
|
||||
down_revision = '0001'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'products',
|
||||
sa.Column('id', UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||
sa.Column('name', sa.String, nullable=False),
|
||||
sa.Column('description', sa.Text, nullable=True),
|
||||
sa.Column('price', sa.Float, nullable=False),
|
||||
sa.Column('stock_quantity', sa.Integer, nullable=False),
|
||||
sa.Column('created_at', sa.DateTime, server_default=func.now(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('products')
|
Loading…
x
Reference in New Issue
Block a user