spiff-arena/spiffworkflow-backend/migrations/versions/44a8f46cc508_.py

633 lines
38 KiB
Python

"""empty message
Revision ID: 44a8f46cc508
Revises:
Create Date: 2023-04-17 15:40:28.658588
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '44a8f46cc508'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('bpmn_process_definition',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('single_process_hash', sa.String(length=255), nullable=False),
sa.Column('full_process_model_hash', sa.String(length=255), nullable=True),
sa.Column('bpmn_identifier', sa.String(length=255), nullable=False),
sa.Column('bpmn_name', sa.String(length=255), nullable=True),
sa.Column('properties_json', sa.JSON(), nullable=False),
sa.Column('bpmn_version_control_type', sa.String(length=50), nullable=True),
sa.Column('bpmn_version_control_identifier', sa.String(length=255), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('full_process_model_hash'),
sa.UniqueConstraint('full_process_model_hash', 'single_process_hash', name='process_hash_unique')
)
with op.batch_alter_table('bpmn_process_definition', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_bpmn_process_definition_bpmn_identifier'), ['bpmn_identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_bpmn_process_definition_bpmn_name'), ['bpmn_name'], unique=False)
op.create_table('correlation_property_cache',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=50), nullable=False),
sa.Column('message_name', sa.String(length=50), nullable=False),
sa.Column('process_model_id', sa.String(length=255), nullable=False),
sa.Column('retrieval_expression', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('correlation_property_cache', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_correlation_property_cache_message_name'), ['message_name'], unique=False)
batch_op.create_index(batch_op.f('ix_correlation_property_cache_name'), ['name'], unique=False)
op.create_table('group',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('identifier', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('group', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_group_identifier'), ['identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_group_name'), ['name'], unique=False)
op.create_table('json_data',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('hash', sa.String(length=255), nullable=False),
sa.Column('data', sa.JSON(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('hash')
)
op.create_table('message_triggerable_process_model',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('message_name', sa.String(length=255), nullable=True),
sa.Column('process_model_identifier', sa.String(length=50), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('message_triggerable_process_model', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_message_triggerable_process_model_message_name'), ['message_name'], unique=False)
batch_op.create_index(batch_op.f('ix_message_triggerable_process_model_process_model_identifier'), ['process_model_identifier'], unique=False)
op.create_table('permission_target',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('uri', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('uri')
)
op.create_table('spec_reference_cache',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('identifier', sa.String(length=255), nullable=True),
sa.Column('display_name', sa.String(length=255), nullable=True),
sa.Column('process_model_id', sa.String(length=255), nullable=True),
sa.Column('type', sa.String(length=255), nullable=True),
sa.Column('file_name', sa.String(length=255), nullable=True),
sa.Column('relative_path', sa.String(length=255), nullable=True),
sa.Column('has_lanes', sa.Boolean(), nullable=True),
sa.Column('is_executable', sa.Boolean(), nullable=True),
sa.Column('is_primary', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('identifier', 'type', name='_identifier_type_unique')
)
with op.batch_alter_table('spec_reference_cache', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_spec_reference_cache_display_name'), ['display_name'], unique=False)
batch_op.create_index(batch_op.f('ix_spec_reference_cache_identifier'), ['identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_spec_reference_cache_process_model_id'), ['process_model_id'], unique=False)
batch_op.create_index(batch_op.f('ix_spec_reference_cache_type'), ['type'], unique=False)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=255), nullable=False),
sa.Column('email', sa.String(length=255), nullable=True),
sa.Column('service', sa.String(length=255), nullable=False),
sa.Column('service_id', sa.String(length=255), nullable=False),
sa.Column('display_name', sa.String(length=255), nullable=True),
sa.Column('tenant_specific_field_1', sa.String(length=255), nullable=True),
sa.Column('tenant_specific_field_2', sa.String(length=255), nullable=True),
sa.Column('tenant_specific_field_3', sa.String(length=255), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('service', 'service_id', name='service_key'),
sa.UniqueConstraint('username')
)
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_user_email'), ['email'], unique=False)
batch_op.create_index(batch_op.f('ix_user_service'), ['service'], unique=False)
batch_op.create_index(batch_op.f('ix_user_service_id'), ['service_id'], unique=False)
op.create_table('bpmn_process',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('guid', sa.String(length=36), nullable=True),
sa.Column('bpmn_process_definition_id', sa.Integer(), nullable=False),
sa.Column('top_level_process_id', sa.Integer(), nullable=True),
sa.Column('direct_parent_process_id', sa.Integer(), nullable=True),
sa.Column('properties_json', sa.JSON(), nullable=False),
sa.Column('json_data_hash', sa.String(length=255), nullable=False),
sa.Column('start_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=True),
sa.Column('end_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=True),
sa.ForeignKeyConstraint(['bpmn_process_definition_id'], ['bpmn_process_definition.id'], ),
sa.ForeignKeyConstraint(['direct_parent_process_id'], ['bpmn_process.id'], ),
sa.ForeignKeyConstraint(['top_level_process_id'], ['bpmn_process.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('guid')
)
with op.batch_alter_table('bpmn_process', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_bpmn_process_bpmn_process_definition_id'), ['bpmn_process_definition_id'], unique=False)
batch_op.create_index(batch_op.f('ix_bpmn_process_direct_parent_process_id'), ['direct_parent_process_id'], unique=False)
batch_op.create_index(batch_op.f('ix_bpmn_process_json_data_hash'), ['json_data_hash'], unique=False)
batch_op.create_index(batch_op.f('ix_bpmn_process_top_level_process_id'), ['top_level_process_id'], unique=False)
op.create_table('bpmn_process_definition_relationship',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_definition_parent_id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_definition_child_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['bpmn_process_definition_child_id'], ['bpmn_process_definition.id'], ),
sa.ForeignKeyConstraint(['bpmn_process_definition_parent_id'], ['bpmn_process_definition.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('bpmn_process_definition_parent_id', 'bpmn_process_definition_child_id', name='bpmn_process_definition_relationship_unique')
)
with op.batch_alter_table('bpmn_process_definition_relationship', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_bpmn_process_definition_relationship_bpmn_process_definition_parent_id'), ['bpmn_process_definition_parent_id'], unique=False)
batch_op.create_index(batch_op.f('ix_bpmn_process_definition_relationship_bpmn_process_definition_child_id'), ['bpmn_process_definition_child_id'], unique=False)
op.create_table('principal',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.CheckConstraint('NOT(user_id IS NULL AND group_id IS NULL)'),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('group_id'),
sa.UniqueConstraint('user_id')
)
op.create_table('process_instance_report',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('identifier', sa.String(length=50), nullable=False),
sa.Column('report_metadata', sa.JSON(), nullable=True),
sa.Column('created_by_id', sa.Integer(), nullable=False),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['created_by_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('created_by_id', 'identifier', name='process_instance_report_unique')
)
with op.batch_alter_table('process_instance_report', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_report_created_by_id'), ['created_by_id'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_report_identifier'), ['identifier'], unique=False)
op.create_table('refresh_token',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('token', sa.String(length=1024), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id')
)
op.create_table('secret',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=50), nullable=False),
sa.Column('value', sa.Text(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('key')
)
with op.batch_alter_table('secret', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_secret_user_id'), ['user_id'], unique=False)
op.create_table('task_definition',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_definition_id', sa.Integer(), nullable=False),
sa.Column('bpmn_identifier', sa.String(length=255), nullable=False),
sa.Column('bpmn_name', sa.String(length=255), nullable=True),
sa.Column('typename', sa.String(length=255), nullable=False),
sa.Column('properties_json', sa.JSON(), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['bpmn_process_definition_id'], ['bpmn_process_definition.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('bpmn_process_definition_id', 'bpmn_identifier', name='task_definition_unique')
)
with op.batch_alter_table('task_definition', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_task_definition_bpmn_identifier'), ['bpmn_identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_task_definition_bpmn_name'), ['bpmn_name'], unique=False)
batch_op.create_index(batch_op.f('ix_task_definition_bpmn_process_definition_id'), ['bpmn_process_definition_id'], unique=False)
batch_op.create_index(batch_op.f('ix_task_definition_typename'), ['typename'], unique=False)
op.create_table('user_group_assignment',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('group_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', 'group_id', name='user_group_assignment_unique')
)
with op.batch_alter_table('user_group_assignment', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_user_group_assignment_group_id'), ['group_id'], unique=False)
batch_op.create_index(batch_op.f('ix_user_group_assignment_user_id'), ['user_id'], unique=False)
op.create_table('user_group_assignment_waiting',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=255), nullable=False),
sa.Column('group_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('username', 'group_id', name='user_group_assignment_staged_unique')
)
with op.batch_alter_table('user_group_assignment_waiting', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_user_group_assignment_waiting_group_id'), ['group_id'], unique=False)
op.create_table('permission_assignment',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('principal_id', sa.Integer(), nullable=False),
sa.Column('permission_target_id', sa.Integer(), nullable=False),
sa.Column('grant_type', sa.String(length=50), nullable=False),
sa.Column('permission', sa.String(length=50), nullable=False),
sa.ForeignKeyConstraint(['permission_target_id'], ['permission_target.id'], ),
sa.ForeignKeyConstraint(['principal_id'], ['principal.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('principal_id', 'permission_target_id', 'permission', name='permission_assignment_uniq')
)
with op.batch_alter_table('permission_assignment', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_permission_assignment_permission_target_id'), ['permission_target_id'], unique=False)
batch_op.create_index(batch_op.f('ix_permission_assignment_principal_id'), ['principal_id'], unique=False)
op.create_table('process_instance',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_model_identifier', sa.String(length=255), nullable=False),
sa.Column('process_model_display_name', sa.String(length=255), nullable=False),
sa.Column('process_initiator_id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_definition_id', sa.Integer(), nullable=True),
sa.Column('bpmn_process_id', sa.Integer(), nullable=True),
sa.Column('spiff_serializer_version', sa.String(length=50), nullable=True),
sa.Column('start_in_seconds', sa.Integer(), nullable=True),
sa.Column('end_in_seconds', sa.Integer(), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('status', sa.String(length=50), nullable=True),
sa.Column('bpmn_version_control_type', sa.String(length=50), nullable=True),
sa.Column('bpmn_version_control_identifier', sa.String(length=255), nullable=True),
sa.ForeignKeyConstraint(['bpmn_process_definition_id'], ['bpmn_process_definition.id'], ),
sa.ForeignKeyConstraint(['bpmn_process_id'], ['bpmn_process.id'], ),
sa.ForeignKeyConstraint(['process_initiator_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('process_instance', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_bpmn_process_definition_id'), ['bpmn_process_definition_id'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_bpmn_process_id'), ['bpmn_process_id'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_end_in_seconds'), ['end_in_seconds'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_process_initiator_id'), ['process_initiator_id'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_process_model_display_name'), ['process_model_display_name'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_process_model_identifier'), ['process_model_identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_start_in_seconds'), ['start_in_seconds'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_status'), ['status'], unique=False)
op.create_table('message_instance',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('message_type', sa.String(length=20), nullable=False),
sa.Column('payload', sa.JSON(), nullable=True),
sa.Column('correlation_keys', sa.JSON(), nullable=True),
sa.Column('status', sa.String(length=20), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('counterpart_id', sa.Integer(), nullable=True),
sa.Column('failure_cause', sa.Text(), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('message_instance', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_message_instance_process_instance_id'), ['process_instance_id'], unique=False)
batch_op.create_index(batch_op.f('ix_message_instance_status'), ['status'], unique=False)
batch_op.create_index(batch_op.f('ix_message_instance_user_id'), ['user_id'], unique=False)
op.create_table('process_instance_event',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('task_guid', sa.String(length=36), nullable=True),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('event_type', sa.String(length=50), nullable=False),
sa.Column('timestamp', sa.DECIMAL(precision=17, scale=6), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('process_instance_event', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_event_event_type'), ['event_type'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_event_process_instance_id'), ['process_instance_id'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_event_task_guid'), ['task_guid'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_event_timestamp'), ['timestamp'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_event_user_id'), ['user_id'], unique=False)
op.create_table('process_instance_file_data',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('identifier', sa.String(length=255), nullable=False),
sa.Column('list_index', sa.Integer(), nullable=True),
sa.Column('mimetype', sa.String(length=255), nullable=False),
sa.Column('filename', sa.String(length=255), nullable=False),
sa.Column('contents', sa.LargeBinary().with_variant(mysql.LONGBLOB(), 'mysql'), nullable=False),
sa.Column('digest', sa.String(length=64), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=False),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('process_instance_file_data', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_file_data_digest'), ['digest'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_file_data_process_instance_id'), ['process_instance_id'], unique=False)
op.create_table('process_instance_metadata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=255), nullable=False),
sa.Column('value', sa.String(length=255), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=False),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('process_instance_id', 'key', name='process_instance_metadata_unique')
)
with op.batch_alter_table('process_instance_metadata', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_metadata_key'), ['key'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_metadata_process_instance_id'), ['process_instance_id'], unique=False)
op.create_table('process_instance_queue',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('run_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('locked_by', sa.String(length=80), nullable=True),
sa.Column('locked_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('status', sa.String(length=50), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('process_instance_id')
)
with op.batch_alter_table('process_instance_queue', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_process_instance_queue_locked_at_in_seconds'), ['locked_at_in_seconds'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_queue_locked_by'), ['locked_by'], unique=False)
batch_op.create_index(batch_op.f('ix_process_instance_queue_status'), ['status'], unique=False)
op.create_table('task',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('guid', sa.String(length=36), nullable=False),
sa.Column('bpmn_process_id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('task_definition_id', sa.Integer(), nullable=False),
sa.Column('state', sa.String(length=10), nullable=False),
sa.Column('properties_json', sa.JSON(), nullable=False),
sa.Column('json_data_hash', sa.String(length=255), nullable=False),
sa.Column('python_env_data_hash', sa.String(length=255), nullable=False),
sa.Column('start_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=True),
sa.Column('end_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=True),
sa.ForeignKeyConstraint(['bpmn_process_id'], ['bpmn_process.id'], ),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.ForeignKeyConstraint(['task_definition_id'], ['task_definition.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('guid')
)
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_task_bpmn_process_id'), ['bpmn_process_id'], unique=False)
batch_op.create_index(batch_op.f('ix_task_json_data_hash'), ['json_data_hash'], unique=False)
batch_op.create_index(batch_op.f('ix_task_process_instance_id'), ['process_instance_id'], unique=False)
batch_op.create_index(batch_op.f('ix_task_python_env_data_hash'), ['python_env_data_hash'], unique=False)
batch_op.create_index(batch_op.f('ix_task_state'), ['state'], unique=False)
batch_op.create_index(batch_op.f('ix_task_task_definition_id'), ['task_definition_id'], unique=False)
op.create_table('human_task',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('lane_assignment_id', sa.Integer(), nullable=True),
sa.Column('completed_by_user_id', sa.Integer(), nullable=True),
sa.Column('actual_owner_id', sa.Integer(), nullable=True),
sa.Column('form_file_name', sa.String(length=50), nullable=True),
sa.Column('ui_form_file_name', sa.String(length=50), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('task_model_id', sa.Integer(), nullable=True),
sa.Column('task_id', sa.String(length=50), nullable=True),
sa.Column('task_name', sa.String(length=255), nullable=True),
sa.Column('task_title', sa.String(length=50), nullable=True),
sa.Column('task_type', sa.String(length=50), nullable=True),
sa.Column('task_status', sa.String(length=50), nullable=True),
sa.Column('process_model_display_name', sa.String(length=255), nullable=True),
sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=True),
sa.Column('completed', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['actual_owner_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['completed_by_user_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['lane_assignment_id'], ['group.id'], ),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
sa.ForeignKeyConstraint(['task_model_id'], ['task.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('human_task', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_human_task_actual_owner_id'), ['actual_owner_id'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_completed'), ['completed'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_completed_by_user_id'), ['completed_by_user_id'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_lane_assignment_id'), ['lane_assignment_id'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_process_instance_id'), ['process_instance_id'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_task_model_id'), ['task_model_id'], unique=False)
op.create_table('message_instance_correlation_rule',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('message_instance_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=50), nullable=False),
sa.Column('retrieval_expression', sa.String(length=255), nullable=True),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['message_instance_id'], ['message_instance.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('message_instance_id', 'name', name='message_instance_id_name_unique')
)
with op.batch_alter_table('message_instance_correlation_rule', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_message_instance_correlation_rule_message_instance_id'), ['message_instance_id'], unique=False)
batch_op.create_index(batch_op.f('ix_message_instance_correlation_rule_name'), ['name'], unique=False)
op.create_table('human_task_user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('human_task_id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['human_task_id'], ['human_task.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('human_task_id', 'user_id', name='human_task_user_unique')
)
with op.batch_alter_table('human_task_user', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_human_task_user_human_task_id'), ['human_task_id'], unique=False)
batch_op.create_index(batch_op.f('ix_human_task_user_user_id'), ['user_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('human_task_user', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_human_task_user_user_id'))
batch_op.drop_index(batch_op.f('ix_human_task_user_human_task_id'))
op.drop_table('human_task_user')
with op.batch_alter_table('message_instance_correlation_rule', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_message_instance_correlation_rule_name'))
batch_op.drop_index(batch_op.f('ix_message_instance_correlation_rule_message_instance_id'))
op.drop_table('message_instance_correlation_rule')
with op.batch_alter_table('human_task', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_human_task_task_model_id'))
batch_op.drop_index(batch_op.f('ix_human_task_process_instance_id'))
batch_op.drop_index(batch_op.f('ix_human_task_lane_assignment_id'))
batch_op.drop_index(batch_op.f('ix_human_task_completed_by_user_id'))
batch_op.drop_index(batch_op.f('ix_human_task_completed'))
batch_op.drop_index(batch_op.f('ix_human_task_actual_owner_id'))
op.drop_table('human_task')
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_task_task_definition_id'))
batch_op.drop_index(batch_op.f('ix_task_state'))
batch_op.drop_index(batch_op.f('ix_task_python_env_data_hash'))
batch_op.drop_index(batch_op.f('ix_task_process_instance_id'))
batch_op.drop_index(batch_op.f('ix_task_json_data_hash'))
batch_op.drop_index(batch_op.f('ix_task_bpmn_process_id'))
op.drop_table('task')
with op.batch_alter_table('process_instance_queue', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_queue_status'))
batch_op.drop_index(batch_op.f('ix_process_instance_queue_locked_by'))
batch_op.drop_index(batch_op.f('ix_process_instance_queue_locked_at_in_seconds'))
op.drop_table('process_instance_queue')
with op.batch_alter_table('process_instance_metadata', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_metadata_process_instance_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_metadata_key'))
op.drop_table('process_instance_metadata')
with op.batch_alter_table('process_instance_file_data', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_file_data_process_instance_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_file_data_digest'))
op.drop_table('process_instance_file_data')
with op.batch_alter_table('process_instance_event', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_event_user_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_event_timestamp'))
batch_op.drop_index(batch_op.f('ix_process_instance_event_task_guid'))
batch_op.drop_index(batch_op.f('ix_process_instance_event_process_instance_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_event_event_type'))
op.drop_table('process_instance_event')
with op.batch_alter_table('message_instance', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_message_instance_user_id'))
batch_op.drop_index(batch_op.f('ix_message_instance_status'))
batch_op.drop_index(batch_op.f('ix_message_instance_process_instance_id'))
op.drop_table('message_instance')
with op.batch_alter_table('process_instance', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_status'))
batch_op.drop_index(batch_op.f('ix_process_instance_start_in_seconds'))
batch_op.drop_index(batch_op.f('ix_process_instance_process_model_identifier'))
batch_op.drop_index(batch_op.f('ix_process_instance_process_model_display_name'))
batch_op.drop_index(batch_op.f('ix_process_instance_process_initiator_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_end_in_seconds'))
batch_op.drop_index(batch_op.f('ix_process_instance_bpmn_process_id'))
batch_op.drop_index(batch_op.f('ix_process_instance_bpmn_process_definition_id'))
op.drop_table('process_instance')
with op.batch_alter_table('permission_assignment', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_permission_assignment_principal_id'))
batch_op.drop_index(batch_op.f('ix_permission_assignment_permission_target_id'))
op.drop_table('permission_assignment')
with op.batch_alter_table('user_group_assignment_waiting', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_group_assignment_waiting_group_id'))
op.drop_table('user_group_assignment_waiting')
with op.batch_alter_table('user_group_assignment', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_group_assignment_user_id'))
batch_op.drop_index(batch_op.f('ix_user_group_assignment_group_id'))
op.drop_table('user_group_assignment')
with op.batch_alter_table('task_definition', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_task_definition_typename'))
batch_op.drop_index(batch_op.f('ix_task_definition_bpmn_process_definition_id'))
batch_op.drop_index(batch_op.f('ix_task_definition_bpmn_name'))
batch_op.drop_index(batch_op.f('ix_task_definition_bpmn_identifier'))
op.drop_table('task_definition')
with op.batch_alter_table('secret', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_secret_user_id'))
op.drop_table('secret')
op.drop_table('refresh_token')
with op.batch_alter_table('process_instance_report', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_process_instance_report_identifier'))
batch_op.drop_index(batch_op.f('ix_process_instance_report_created_by_id'))
op.drop_table('process_instance_report')
op.drop_table('principal')
with op.batch_alter_table('bpmn_process_definition_relationship', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_bpmn_process_definition_relationship_bpmn_process_definition_child_id'))
batch_op.drop_index(batch_op.f('ix_bpmn_process_definition_relationship_bpmn_process_definition_parent_id'))
op.drop_table('bpmn_process_definition_relationship')
with op.batch_alter_table('bpmn_process', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_bpmn_process_top_level_process_id'))
batch_op.drop_index(batch_op.f('ix_bpmn_process_json_data_hash'))
batch_op.drop_index(batch_op.f('ix_bpmn_process_direct_parent_process_id'))
batch_op.drop_index(batch_op.f('ix_bpmn_process_bpmn_process_definition_id'))
op.drop_table('bpmn_process')
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_service_id'))
batch_op.drop_index(batch_op.f('ix_user_service'))
batch_op.drop_index(batch_op.f('ix_user_email'))
op.drop_table('user')
with op.batch_alter_table('spec_reference_cache', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_spec_reference_cache_type'))
batch_op.drop_index(batch_op.f('ix_spec_reference_cache_process_model_id'))
batch_op.drop_index(batch_op.f('ix_spec_reference_cache_identifier'))
batch_op.drop_index(batch_op.f('ix_spec_reference_cache_display_name'))
op.drop_table('spec_reference_cache')
op.drop_table('permission_target')
with op.batch_alter_table('message_triggerable_process_model', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_message_triggerable_process_model_process_model_identifier'))
batch_op.drop_index(batch_op.f('ix_message_triggerable_process_model_message_name'))
op.drop_table('message_triggerable_process_model')
op.drop_table('json_data')
with op.batch_alter_table('group', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_group_name'))
batch_op.drop_index(batch_op.f('ix_group_identifier'))
op.drop_table('group')
with op.batch_alter_table('correlation_property_cache', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_correlation_property_cache_name'))
batch_op.drop_index(batch_op.f('ix_correlation_property_cache_message_name'))
op.drop_table('correlation_property_cache')
with op.batch_alter_table('bpmn_process_definition', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_bpmn_process_definition_bpmn_name'))
batch_op.drop_index(batch_op.f('ix_bpmn_process_definition_bpmn_identifier'))
op.drop_table('bpmn_process_definition')
# ### end Alembic commands ###