From f2f0c1ec6cc27488150264bc9ce3963582090375 Mon Sep 17 00:00:00 2001 From: JWittmeyer <91723236+JWittmeyer@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:46:31 +0100 Subject: [PATCH] Pipeline Versions (#271) * Adds version tables * Remove organization id * fix alembic * submodule & hotfix * Adds change * Alembic for fkey remove * Submodule change * Submodule merge --- .../89a5f2211130_pipeline_version_table.py | 52 +++++++++++++++++++ submodules/model | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 alembic/versions/89a5f2211130_pipeline_version_table.py diff --git a/alembic/versions/89a5f2211130_pipeline_version_table.py b/alembic/versions/89a5f2211130_pipeline_version_table.py new file mode 100644 index 00000000..da94d60a --- /dev/null +++ b/alembic/versions/89a5f2211130_pipeline_version_table.py @@ -0,0 +1,52 @@ +"""Pipeline Version table + +Revision ID: 89a5f2211130 +Revises: 2c0029684bd7 +Create Date: 2024-11-21 14:23:59.233725 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '89a5f2211130' +down_revision = '2c0029684bd7' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('pipeline_version', + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), + sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True), + sa.Column('name', sa.String(), nullable=True), + sa.Column('version_type', sa.String(), nullable=True), + sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('pipeline_dump', sa.JSON(), nullable=True), + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['project_id'], ['cognition.project.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + schema='cognition' + ) + op.create_index(op.f('ix_cognition_pipeline_version_created_by'), 'pipeline_version', ['created_by'], unique=False, schema='cognition') + op.create_index(op.f('ix_cognition_pipeline_version_project_id'), 'pipeline_version', ['project_id'], unique=False, schema='cognition') + op.add_column('message', sa.Column('version_id', postgresql.UUID(as_uuid=True), nullable=True), schema='cognition') + op.create_index(op.f('ix_cognition_message_version_id'), 'message', ['version_id'], unique=False, schema='cognition') + op.create_foreign_key(None, 'message', 'pipeline_version', ['version_id'], ['id'], source_schema='cognition', referent_schema='cognition', ondelete='SET NULL') + op.drop_constraint('pipeline_logs_strategy_step_id_fkey', 'pipeline_logs', schema='cognition', type_='foreignkey') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'message', schema='cognition', type_='foreignkey') + op.drop_index(op.f('ix_cognition_message_version_id'), table_name='message', schema='cognition') + op.drop_column('message', 'version_id', schema='cognition') + op.drop_index(op.f('ix_cognition_pipeline_version_project_id'), table_name='pipeline_version', schema='cognition') + op.drop_index(op.f('ix_cognition_pipeline_version_created_by'), table_name='pipeline_version', schema='cognition') + op.drop_table('pipeline_version', schema='cognition') + op.create_foreign_key('pipeline_logs_strategy_step_id_fkey', 'pipeline_logs', 'strategy_step', ['strategy_step_id'], ['id'], source_schema='cognition', referent_schema='cognition', ondelete='CASCADE') + # ### end Alembic commands ### diff --git a/submodules/model b/submodules/model index bf76a4da..348c4586 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit bf76a4daec06a56b267b958df6da6b6e49564ed2 +Subproject commit 348c4586a64f68a4873aabe8126a3f8ee9fcba06