diff --git a/spiffworkflow-backend/migrations/env.py b/spiffworkflow-backend/migrations/env.py index 630e381ad..68feded2a 100644 --- a/spiffworkflow-backend/migrations/env.py +++ b/spiffworkflow-backend/migrations/env.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import logging from logging.config import fileConfig diff --git a/spiffworkflow-backend/migrations/versions/1e8167de6df8_.py b/spiffworkflow-backend/migrations/versions/1e8167de6df8_.py deleted file mode 100644 index 18668aed1..000000000 --- a/spiffworkflow-backend/migrations/versions/1e8167de6df8_.py +++ /dev/null @@ -1,43 +0,0 @@ -"""empty message - -Revision ID: 1e8167de6df8 -Revises: 8930711a75a4 -Create Date: 2023-03-02 15:18:19.515864 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '1e8167de6df8' -down_revision = '8930711a75a4' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - 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(), 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') - ) - op.create_index(op.f('ix_process_instance_file_data_digest'), 'process_instance_file_data', ['digest'], unique=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_process_instance_file_data_digest'), table_name='process_instance_file_data') - op.drop_table('process_instance_file_data') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/ac6b60d7fee9_.py b/spiffworkflow-backend/migrations/versions/55b76c4528c5_.py similarity index 73% rename from spiffworkflow-backend/migrations/versions/ac6b60d7fee9_.py rename to spiffworkflow-backend/migrations/versions/55b76c4528c5_.py index 520af3804..efe373eb4 100644 --- a/spiffworkflow-backend/migrations/versions/ac6b60d7fee9_.py +++ b/spiffworkflow-backend/migrations/versions/55b76c4528c5_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: ac6b60d7fee9 +Revision ID: 55b76c4528c5 Revises: -Create Date: 2023-02-27 22:02:11.465980 +Create Date: 2023-03-06 11:11:55.431564 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'ac6b60d7fee9' +revision = '55b76c4528c5' down_revision = None branch_labels = None depends_on = None @@ -18,6 +18,29 @@ depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### + op.create_table('bpmn_process', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('guid', sa.String(length=36), nullable=True), + sa.Column('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.ForeignKeyConstraint(['parent_process_id'], ['bpmn_process.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_bpmn_process_guid'), 'bpmn_process', ['guid'], unique=True) + op.create_index(op.f('ix_bpmn_process_json_data_hash'), 'bpmn_process', ['json_data_hash'], unique=False) + op.create_table('bpmn_process_definition', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('hash', sa.String(length=255), nullable=False), + sa.Column('bpmn_identifier', sa.String(length=255), nullable=False), + sa.Column('properties_json', sa.JSON(), nullable=False), + sa.Column('type', sa.String(length=32), 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.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_bpmn_process_definition_bpmn_identifier'), 'bpmn_process_definition', ['bpmn_identifier'], unique=False) + op.create_index(op.f('ix_bpmn_process_definition_hash'), 'bpmn_process_definition', ['hash'], unique=True) op.create_table('correlation_property_cache', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50), nullable=False), @@ -32,6 +55,13 @@ def upgrade(): sa.Column('identifier', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id') ) + 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') + ) + op.create_index(op.f('ix_json_data_hash'), 'json_data', ['hash'], unique=True) op.create_table('message_triggerable_process_model', sa.Column('id', sa.Integer(), nullable=False), sa.Column('message_name', sa.String(length=255), nullable=True), @@ -68,6 +98,7 @@ def upgrade(): sa.Column('id', sa.Integer(), nullable=False), sa.Column('process_instance_id', sa.Integer(), nullable=False), sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=False), + sa.Column('bpmn_process_name', sa.String(length=255), nullable=True), sa.Column('bpmn_task_identifier', sa.String(length=255), nullable=False), sa.Column('bpmn_task_name', sa.String(length=255), nullable=True), sa.Column('bpmn_task_type', sa.String(length=255), nullable=True), @@ -94,6 +125,15 @@ def upgrade(): sa.UniqueConstraint('service', 'service_id', name='service_key'), sa.UniqueConstraint('username') ) + 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') + ) op.create_table('principal', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), @@ -110,6 +150,9 @@ def upgrade(): 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('bpmn_json', sa.JSON(), nullable=True), sa.Column('start_in_seconds', sa.Integer(), nullable=True), sa.Column('end_in_seconds', sa.Integer(), nullable=True), @@ -121,6 +164,8 @@ def upgrade(): sa.Column('spiff_step', 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.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') ) @@ -158,6 +203,29 @@ def upgrade(): sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('key') ) + 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('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.ForeignKeyConstraint(['bpmn_process_id'], ['bpmn_process.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_task_guid'), 'task', ['guid'], unique=True) + op.create_index(op.f('ix_task_json_data_hash'), 'task', ['json_data_hash'], 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('properties_json', sa.JSON(), nullable=False), + sa.Column('typename', sa.String(length=255), nullable=False), + 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') + ) + op.create_index(op.f('ix_task_definition_bpmn_identifier'), 'task_definition', ['bpmn_identifier'], unique=False) op.create_table('user_group_assignment', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), @@ -228,6 +296,21 @@ def upgrade(): sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('principal_id', 'permission_target_id', 'permission', name='permission_assignment_uniq') ) + 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(), 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') + ) + op.create_index(op.f('ix_process_instance_file_data_digest'), 'process_instance_file_data', ['digest'], unique=False) op.create_table('process_instance_metadata', sa.Column('id', sa.Integer(), nullable=False), sa.Column('process_instance_id', sa.Integer(), nullable=False), @@ -248,6 +331,7 @@ def upgrade(): sa.Column('task_id', sa.String(length=50), nullable=False), sa.Column('task_state', sa.String(length=50), nullable=False), sa.Column('bpmn_task_identifier', sa.String(length=255), nullable=False), + sa.Column('delta_json', sa.JSON(), nullable=True), sa.Column('start_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=False), sa.Column('end_in_seconds', sa.DECIMAL(precision=17, scale=6), nullable=True), sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ), @@ -290,12 +374,19 @@ def downgrade(): op.drop_table('spiff_step_details') op.drop_index(op.f('ix_process_instance_metadata_key'), table_name='process_instance_metadata') op.drop_table('process_instance_metadata') + op.drop_index(op.f('ix_process_instance_file_data_digest'), table_name='process_instance_file_data') + op.drop_table('process_instance_file_data') op.drop_table('permission_assignment') op.drop_table('message_instance') op.drop_index(op.f('ix_human_task_completed'), table_name='human_task') op.drop_table('human_task') op.drop_table('user_group_assignment_waiting') op.drop_table('user_group_assignment') + op.drop_index(op.f('ix_task_definition_bpmn_identifier'), table_name='task_definition') + op.drop_table('task_definition') + op.drop_index(op.f('ix_task_json_data_hash'), table_name='task') + op.drop_index(op.f('ix_task_guid'), table_name='task') + op.drop_table('task') op.drop_table('secret') op.drop_table('refresh_token') op.drop_index(op.f('ix_process_instance_report_identifier'), table_name='process_instance_report') @@ -305,6 +396,7 @@ def downgrade(): op.drop_index(op.f('ix_process_instance_process_model_display_name'), table_name='process_instance') op.drop_table('process_instance') op.drop_table('principal') + op.drop_table('bpmn_process_definition_relationship') op.drop_table('user') op.drop_table('spiff_logging') op.drop_index(op.f('ix_spec_reference_cache_type'), table_name='spec_reference_cache') @@ -314,6 +406,14 @@ def downgrade(): op.drop_table('permission_target') op.drop_index(op.f('ix_message_triggerable_process_model_process_model_identifier'), table_name='message_triggerable_process_model') op.drop_table('message_triggerable_process_model') + op.drop_index(op.f('ix_json_data_hash'), table_name='json_data') + op.drop_table('json_data') op.drop_table('group') op.drop_table('correlation_property_cache') + op.drop_index(op.f('ix_bpmn_process_definition_hash'), table_name='bpmn_process_definition') + op.drop_index(op.f('ix_bpmn_process_definition_bpmn_identifier'), table_name='bpmn_process_definition') + op.drop_table('bpmn_process_definition') + op.drop_index(op.f('ix_bpmn_process_json_data_hash'), table_name='bpmn_process') + op.drop_index(op.f('ix_bpmn_process_guid'), table_name='bpmn_process') + op.drop_table('bpmn_process') # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/61cd3e8462f5_.py b/spiffworkflow-backend/migrations/versions/61cd3e8462f5_.py deleted file mode 100644 index c6a5f000e..000000000 --- a/spiffworkflow-backend/migrations/versions/61cd3e8462f5_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""empty message - -Revision ID: 61cd3e8462f5 -Revises: 941f7b76d278 -Create Date: 2023-03-03 16:22:12.449757 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '61cd3e8462f5' -down_revision = '941f7b76d278' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('task_ibfk_2', 'task', type_='foreignkey') - op.drop_column('task', 'task_definition_id') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('task', sa.Column('task_definition_id', mysql.INTEGER(), autoincrement=False, nullable=False)) - op.create_foreign_key('task_ibfk_2', 'task', 'task_definition', ['task_definition_id'], ['id']) - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/7422be14adc4_.py b/spiffworkflow-backend/migrations/versions/7422be14adc4_.py deleted file mode 100644 index 6897e0f21..000000000 --- a/spiffworkflow-backend/migrations/versions/7422be14adc4_.py +++ /dev/null @@ -1,51 +0,0 @@ -"""empty message - -Revision ID: 7422be14adc4 -Revises: ac6b60d7fee9 -Create Date: 2023-03-01 15:39:25.731722 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '7422be14adc4' -down_revision = 'ac6b60d7fee9' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('process_instance_data', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('runtime_json', sa.JSON(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('serialized_bpmn_definition', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('hash', sa.String(length=255), nullable=False), - sa.Column('static_json', sa.JSON(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_serialized_bpmn_definition_hash'), 'serialized_bpmn_definition', ['hash'], unique=True) - op.add_column('process_instance', sa.Column('serialized_bpmn_definition_id', sa.Integer(), nullable=True)) - op.add_column('process_instance', sa.Column('process_instance_data_id', sa.Integer(), nullable=True)) - op.create_foreign_key(None, 'process_instance', 'process_instance_data', ['process_instance_data_id'], ['id']) - op.create_foreign_key(None, 'process_instance', 'serialized_bpmn_definition', ['serialized_bpmn_definition_id'], ['id']) - op.add_column('spiff_step_details', sa.Column('delta_json', sa.JSON(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('spiff_step_details', 'delta_json') - op.drop_constraint('process_instance_ibfk_3', 'process_instance', type_='foreignkey') - op.drop_constraint('process_instance_ibfk_2', 'process_instance', type_='foreignkey') - op.drop_column('process_instance', 'process_instance_data_id') - op.drop_column('process_instance', 'serialized_bpmn_definition_id') - op.drop_index(op.f('ix_serialized_bpmn_definition_hash'), table_name='serialized_bpmn_definition') - op.drop_table('serialized_bpmn_definition') - op.drop_table('process_instance_data') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/8930711a75a4_.py b/spiffworkflow-backend/migrations/versions/8930711a75a4_.py deleted file mode 100644 index 9947a6644..000000000 --- a/spiffworkflow-backend/migrations/versions/8930711a75a4_.py +++ /dev/null @@ -1,28 +0,0 @@ -"""empty message - -Revision ID: 8930711a75a4 -Revises: 7422be14adc4 -Create Date: 2023-03-01 16:16:50.446929 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '8930711a75a4' -down_revision = '7422be14adc4' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('spiff_logging', sa.Column('bpmn_process_name', sa.String(length=255), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('spiff_logging', 'bpmn_process_name') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/941f7b76d278_.py b/spiffworkflow-backend/migrations/versions/941f7b76d278_.py deleted file mode 100644 index 8705894a8..000000000 --- a/spiffworkflow-backend/migrations/versions/941f7b76d278_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""empty message - -Revision ID: 941f7b76d278 -Revises: b0b82fab4cf9 -Create Date: 2023-03-03 14:40:46.574985 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '941f7b76d278' -down_revision = 'b0b82fab4cf9' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('bpmn_process', sa.Column('guid', sa.String(length=36), nullable=True)) - op.create_index(op.f('ix_bpmn_process_guid'), 'bpmn_process', ['guid'], unique=True) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_bpmn_process_guid'), table_name='bpmn_process') - op.drop_column('bpmn_process', 'guid') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/a63a61a21398_.py b/spiffworkflow-backend/migrations/versions/a63a61a21398_.py deleted file mode 100644 index 2a4524b15..000000000 --- a/spiffworkflow-backend/migrations/versions/a63a61a21398_.py +++ /dev/null @@ -1,107 +0,0 @@ -"""empty message - -Revision ID: a63a61a21398 -Revises: 1e8167de6df8 -Create Date: 2023-03-03 13:07:51.665585 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'a63a61a21398' -down_revision = '1e8167de6df8' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('bpmn_process', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('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.ForeignKeyConstraint(['parent_process_id'], ['bpmn_process.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_bpmn_process_json_data_hash'), 'bpmn_process', ['json_data_hash'], unique=False) - op.create_table('bpmn_process_definition', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('hash', sa.String(length=255), nullable=False), - sa.Column('bpmn_identifier', sa.String(length=255), nullable=False), - sa.Column('properties_json', sa.JSON(), nullable=False), - sa.Column('type', sa.String(length=32), 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.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_bpmn_process_definition_bpmn_identifier'), 'bpmn_process_definition', ['bpmn_identifier'], unique=False) - op.create_index(op.f('ix_bpmn_process_definition_hash'), 'bpmn_process_definition', ['hash'], unique=True) - 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') - ) - op.create_index(op.f('ix_json_data_hash'), 'json_data', ['hash'], unique=True) - 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') - ) - 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('properties_json', sa.JSON(), nullable=False), - sa.Column('typename', sa.String(length=255), nullable=False), - 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') - ) - op.create_index(op.f('ix_task_definition_bpmn_identifier'), 'task_definition', ['bpmn_identifier'], 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('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.ForeignKeyConstraint(['bpmn_process_id'], ['bpmn_process.id'], ), - sa.ForeignKeyConstraint(['task_definition_id'], ['task_definition.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_task_guid'), 'task', ['guid'], unique=True) - op.create_index(op.f('ix_task_json_data_hash'), 'task', ['json_data_hash'], unique=False) - op.add_column('process_instance', sa.Column('bpmn_process_definition_id', sa.Integer(), nullable=True)) - op.add_column('process_instance', sa.Column('spiff_serializer_version', sa.String(length=50), nullable=True)) - op.create_foreign_key(None, 'process_instance', 'bpmn_process_definition', ['bpmn_process_definition_id'], ['id']) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'process_instance', type_='foreignkey') - op.drop_column('process_instance', 'spiff_serializer_version') - op.drop_column('process_instance', 'bpmn_process_definition_id') - op.drop_index(op.f('ix_task_json_data_hash'), table_name='task') - op.drop_index(op.f('ix_task_guid'), table_name='task') - op.drop_table('task') - op.drop_index(op.f('ix_task_definition_bpmn_identifier'), table_name='task_definition') - op.drop_table('task_definition') - op.drop_table('bpmn_process_definition_relationship') - op.drop_index(op.f('ix_json_data_hash'), table_name='json_data') - op.drop_table('json_data') - op.drop_index(op.f('ix_bpmn_process_definition_hash'), table_name='bpmn_process_definition') - op.drop_index(op.f('ix_bpmn_process_definition_bpmn_identifier'), table_name='bpmn_process_definition') - op.drop_table('bpmn_process_definition') - op.drop_index(op.f('ix_bpmn_process_json_data_hash'), table_name='bpmn_process') - op.drop_table('bpmn_process') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/migrations/versions/b0b82fab4cf9_.py b/spiffworkflow-backend/migrations/versions/b0b82fab4cf9_.py deleted file mode 100644 index 61d199450..000000000 --- a/spiffworkflow-backend/migrations/versions/b0b82fab4cf9_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""empty message - -Revision ID: b0b82fab4cf9 -Revises: a63a61a21398 -Create Date: 2023-03-03 13:24:08.304492 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b0b82fab4cf9' -down_revision = 'a63a61a21398' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('process_instance', sa.Column('bpmn_process_id', sa.Integer(), nullable=True)) - op.create_foreign_key(None, 'process_instance', 'bpmn_process', ['bpmn_process_id'], ['id']) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'process_instance', type_='foreignkey') - op.drop_column('process_instance', 'bpmn_process_id') - # ### end Alembic commands ### diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py b/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py index d51abb494..376083cf2 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py @@ -50,12 +50,6 @@ from spiffworkflow_backend.models.group import GroupModel # noqa: F401 from spiffworkflow_backend.models.process_instance_metadata import ( ProcessInstanceMetadataModel, ) # noqa: F401 -from spiffworkflow_backend.models.serialized_bpmn_definition import ( - SerializedBpmnDefinitionModel, -) # noqa: F401 -from spiffworkflow_backend.models.process_instance_data import ( - ProcessInstanceDataModel, -) # noqa: F401 from spiffworkflow_backend.models.process_instance_file_data import ( ProcessInstanceFileDataModel, ) # noqa: F401 diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py index 5b3733710..ea7f45623 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py @@ -22,10 +22,6 @@ from spiffworkflow_backend.models.bpmn_process_definition import ( ) from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import SpiffworkflowBaseDBModel -from spiffworkflow_backend.models.process_instance_data import ProcessInstanceDataModel -from spiffworkflow_backend.models.serialized_bpmn_definition import ( - SerializedBpmnDefinitionModel, -) # noqa: F401 from spiffworkflow_backend.models.task import Task from spiffworkflow_backend.models.task import TaskSchema from spiffworkflow_backend.models.user import UserModel @@ -69,16 +65,6 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False) # type: ignore process_initiator = relationship("UserModel") - serialized_bpmn_definition_id: int | None = db.Column( - ForeignKey(SerializedBpmnDefinitionModel.id), nullable=True # type: ignore - ) - serialized_bpmn_definition = relationship("SerializedBpmnDefinitionModel") - - process_instance_data_id: int | None = db.Column( - ForeignKey(ProcessInstanceDataModel.id), nullable=True # type: ignore - ) - process_instance_data = relationship("ProcessInstanceDataModel", cascade="delete") - bpmn_process_definition_id: Optional[int] = db.Column( ForeignKey(BpmnProcessDefinitionModel.id), nullable=True # type: ignore ) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_data.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_data.py deleted file mode 100644 index 01f07e33c..000000000 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_data.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Process_instance.""" -from __future__ import annotations - -from spiffworkflow_backend.models.db import db -from spiffworkflow_backend.models.db import SpiffworkflowBaseDBModel - - -# the last three here should maybe become columns on process instance someday -# runtime_json -# "bpmn_messages", -# "correlations", -# "data", -# "subprocesses", -# "tasks", -# "last_task", # guid generated by spiff -# "root", # guid generated by spiff -# "success", # boolean -class ProcessInstanceDataModel(SpiffworkflowBaseDBModel): - __tablename__ = "process_instance_data" - id: int = db.Column(db.Integer, primary_key=True) - # this is not deferred because there is no reason to query this model if you do not want the runtime_json - runtime_json: str = db.Column(db.JSON, nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/serialized_bpmn_definition.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/serialized_bpmn_definition.py deleted file mode 100644 index 5ccb71466..000000000 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/serialized_bpmn_definition.py +++ /dev/null @@ -1,49 +0,0 @@ -"""Process_instance.""" -from __future__ import annotations - -from spiffworkflow_backend.models.db import db -from spiffworkflow_backend.models.db import SpiffworkflowBaseDBModel - - -# top level serialized keys -# -# static -# "subprocess_specs", -# "spec", -# "serializer_version", -# -# runtime -# "bpmn_messages", -# "correlations", -# "subprocesses", -# -# also in subprocesses -# "data", -# "tasks" -# "last_task", # guid generated by spiff -# "root", # guid generated by spiff -# "success", # boolean -# -# new columns on process_instance -# -# delta algorithm: -# a = {"hey": { "hey2": 2, "hey3": 3, "hey6": 7 }, "hey30": 3, "hey40": 4} -# b = {"hey": { "hey2": 4, "hey5": 3 }, "hey20": 2, "hey30": 3} -# a_keys = set(a.keys()) -# b_keys = set(b.keys()) -# removed = a_keys - b_keys -# added_keys = b_keys - a_keys -# keys_present_in_both = a_keys & b_keys -# changed = {} -# for key_in_both in keys_present_in_both: -# if a[key_in_both] != b[key_in_both]: -# changed[key_in_both] = b[key_in_both] -# added = {} -# for added_key in added_keys: -# added[added_key] = b[added_key] -# final_tuple = [added, removed, changed] -class SerializedBpmnDefinitionModel(SpiffworkflowBaseDBModel): - __tablename__ = "serialized_bpmn_definition" - id: int = db.Column(db.Integer, primary_key=True) - hash: str = db.Column(db.String(255), nullable=False, index=True, unique=True) - static_json: str = db.Column(db.JSON, nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index 6b41b44a7..f58cf3034 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -77,7 +77,6 @@ from spiffworkflow_backend.models.message_instance_correlation import ( ) from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus -from spiffworkflow_backend.models.process_instance_data import ProcessInstanceDataModel from spiffworkflow_backend.models.process_instance_metadata import ( ProcessInstanceMetadataModel, ) @@ -85,9 +84,6 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.models.script_attributes_context import ( ScriptAttributesContext, ) -from spiffworkflow_backend.models.serialized_bpmn_definition import ( - SerializedBpmnDefinitionModel, -) # noqa: F401 from spiffworkflow_backend.models.spec_reference import SpecReferenceCache from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel from spiffworkflow_backend.models.task_definition import TaskDefinitionModel @@ -928,53 +924,6 @@ class ProcessInstanceProcessor: ) return subprocesses_by_child_task_ids - def _add_bpmn_json_records(self) -> None: - """Adds serialized_bpmn_definition and process_instance_data records to the db session. - - Expects the save method to commit it. - """ - bpmn_dict = json.loads(self.serialize()) - bpmn_dict_keys = ("spec", "subprocess_specs", "serializer_version") - bpmn_spec_dict = {} - process_instance_data_dict = {} - for bpmn_key in bpmn_dict.keys(): - if bpmn_key in bpmn_dict_keys: - bpmn_spec_dict[bpmn_key] = bpmn_dict[bpmn_key] - else: - process_instance_data_dict[bpmn_key] = bpmn_dict[bpmn_key] - - # FIXME: always save new hash until we get updated Spiff without loopresettask - # if self.process_instance_model.serialized_bpmn_definition_id is None: - new_hash_digest = sha256( - json.dumps(bpmn_spec_dict, sort_keys=True).encode("utf8") - ).hexdigest() - serialized_bpmn_definition = SerializedBpmnDefinitionModel.query.filter_by( - hash=new_hash_digest - ).first() - if serialized_bpmn_definition is None: - serialized_bpmn_definition = SerializedBpmnDefinitionModel( - hash=new_hash_digest, static_json=json.dumps(bpmn_spec_dict) - ) - db.session.add(serialized_bpmn_definition) - if ( - self.process_instance_model.serialized_bpmn_definition_id is None - or self.process_instance_model.serialized_bpmn_definition.hash - != new_hash_digest - ): - self.process_instance_model.serialized_bpmn_definition = ( - serialized_bpmn_definition - ) - - process_instance_data = None - if self.process_instance_model.process_instance_data_id is None: - process_instance_data = ProcessInstanceDataModel() - else: - process_instance_data = self.process_instance_model.process_instance_data - - process_instance_data.runtime_json = json.dumps(process_instance_data_dict) - db.session.add(process_instance_data) - self.process_instance_model.process_instance_data = process_instance_data - def _store_bpmn_process_definition( self, process_bpmn_properties: dict, @@ -1090,7 +1039,7 @@ class ProcessInstanceProcessor: return bpmn_process - def _add_bpmn_json_records_new(self) -> None: + def _add_bpmn_json_records(self) -> None: """Adds serialized_bpmn_definition and process_instance_data records to the db session. Expects the save method to commit it. @@ -1117,8 +1066,7 @@ class ProcessInstanceProcessor: def save(self) -> None: """Saves the current state of this processor to the database.""" - # self._add_bpmn_json_records() - self._add_bpmn_json_records_new() + self._add_bpmn_json_records() self.process_instance_model.spiff_serializer_version = self.SERIALIZER_VERSION complete_states = [TaskState.CANCELLED, TaskState.COMPLETED]