From e3743127e80cbb29bf6fc40e5427417a10feeaef Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 22:53:47 +0100 Subject: [PATCH] Add migration for Product --- ...20250329_225323_996dc55a_create_product.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 alembic/versions/20250329_225323_996dc55a_create_product.py diff --git a/alembic/versions/20250329_225323_996dc55a_create_product.py b/alembic/versions/20250329_225323_996dc55a_create_product.py new file mode 100644 index 0000000..5c664ef --- /dev/null +++ b/alembic/versions/20250329_225323_996dc55a_create_product.py @@ -0,0 +1,34 @@ +"""create products table + +Revision ID: 2b9e68d80af4 +Revises: 0001 +Create Date: 2023-05-30 15:17:09.710252 + +""" +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 = '2b9e68d80af4' +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') \ No newline at end of file