mirror of
https://github.com/Sudo-JHare/FHIRFLARE-IG-Toolkit.git
synced 2025-06-15 17:20:00 +00:00
81 lines
3.4 KiB
Python
81 lines
3.4 KiB
Python
"""Initial migration with User, ModuleRegistry, ProcessedIg
|
|
|
|
Revision ID: 7d0cdff4c7ad
|
|
Revises:
|
|
Create Date: 2025-04-08 08:35:33.204706
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '7d0cdff4c7ad'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('module_registry',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('module_id', sa.String(length=100), nullable=False),
|
|
sa.Column('is_enabled', sa.Boolean(), nullable=False),
|
|
sa.Column('display_name', sa.String(length=100), nullable=True),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('version', sa.String(length=30), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('module_registry', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_module_registry_module_id'), ['module_id'], unique=True)
|
|
|
|
op.create_table('processed_ig',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('package_name', sa.String(length=150), nullable=False),
|
|
sa.Column('package_version', sa.String(length=50), nullable=False),
|
|
sa.Column('processed_at', sa.DateTime(), nullable=False),
|
|
sa.Column('status', sa.String(length=50), nullable=True),
|
|
sa.Column('resource_types_json', sa.Text(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('package_name', 'package_version', name='uq_processed_ig_name_version')
|
|
)
|
|
with op.batch_alter_table('processed_ig', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_processed_ig_package_name'), ['package_name'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_processed_ig_package_version'), ['package_version'], unique=False)
|
|
|
|
op.create_table('user',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(length=64), nullable=True),
|
|
sa.Column('email', sa.String(length=120), nullable=True),
|
|
sa.Column('password_hash', sa.String(length=256), nullable=True),
|
|
sa.Column('role', sa.String(length=20), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_user_email'), ['email'], unique=True)
|
|
batch_op.create_index(batch_op.f('ix_user_role'), ['role'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_user_username'), ['username'], unique=True)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_user_username'))
|
|
batch_op.drop_index(batch_op.f('ix_user_role'))
|
|
batch_op.drop_index(batch_op.f('ix_user_email'))
|
|
|
|
op.drop_table('user')
|
|
with op.batch_alter_table('processed_ig', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_processed_ig_package_version'))
|
|
batch_op.drop_index(batch_op.f('ix_processed_ig_package_name'))
|
|
|
|
op.drop_table('processed_ig')
|
|
with op.batch_alter_table('module_registry', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_module_registry_module_id'))
|
|
|
|
op.drop_table('module_registry')
|
|
# ### end Alembic commands ###
|