Evo-ERP/migrations/versions/17999512d1a8_initial_migration.py
2024-11-06 02:39:48 +08:00

52 lines
1.9 KiB
Python

"""Initial migration
Revision ID: 17999512d1a8
Revises:
Create Date: 2024-11-06 01:10:41.690672
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '17999512d1a8'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('products',
sa.Column('code', sa.String(length=50), nullable=False, comment='商品代碼'),
sa.Column('name', sa.String(length=100), nullable=False, comment='商品名稱'),
sa.Column('price', sa.Numeric(precision=10, scale=2), nullable=False, comment='單價'),
sa.Column('quantity', sa.Integer(), nullable=True, comment='庫存數量'),
sa.Column('min_quantity', sa.Integer(), nullable=True, comment='最低庫存量'),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code')
)
op.create_table('transactions',
sa.Column('product_id', sa.Integer(), nullable=False, comment='商品ID'),
sa.Column('type', sa.String(length=20), nullable=False, comment='交易類型: in=入庫, out=出庫'),
sa.Column('quantity', sa.Integer(), nullable=False, comment='交易數量'),
sa.Column('notes', sa.Text(), nullable=True, comment='備註'),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['product_id'], ['products.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('transactions')
op.drop_table('products')
# ### end Alembic commands ###