55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
"""empty message
|
|
|
|
Revision ID: b21476e11a57
|
|
Revises:
|
|
Create Date: 2024-01-01 14:11:31.822410
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'b21476e11a57'
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('owner',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('medicine',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('owner_id', sa.Integer(), nullable=True),
|
|
sa.Column('pzn', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('uuid', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.ForeignKeyConstraint(['owner_id'], ['owner.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_medicine_uuid'), 'medicine', ['uuid'], unique=False)
|
|
op.create_table('medicinelog',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('medicine_id', sa.Integer(), nullable=True),
|
|
sa.Column('timestamp', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['medicine_id'], ['medicine.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('medicinelog')
|
|
op.drop_index(op.f('ix_medicine_uuid'), table_name='medicine')
|
|
op.drop_table('medicine')
|
|
op.drop_table('owner')
|
|
# ### end Alembic commands ###
|