48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""add drug table
|
|
|
|
Revision ID: c509dcf806d4
|
|
Revises:
|
|
Create Date: 2025-08-06 19:33:52.814812
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'c509dcf806d4'
|
|
down_revision: Union[str, Sequence[str], None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('drugs',
|
|
sa.Column('id', sa.BigInteger(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.Column('dosage', sa.Float(), nullable=False),
|
|
sa.Column('dosage_unit', sa.String(), nullable=False),
|
|
sa.Column('unit_price', sa.Float(), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('drugs', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_drugs_id'), ['id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_drugs_name'), ['name'], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('drugs', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_drugs_name'))
|
|
batch_op.drop_index(batch_op.f('ix_drugs_id'))
|
|
|
|
op.drop_table('drugs')
|
|
# ### end Alembic commands ###
|