Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline Versions #271

Merged
merged 14 commits into from
Nov 27, 2024
52 changes: 52 additions & 0 deletions alembic/versions/89a5f2211130_pipeline_version_table.py
Original file line number Diff line number Diff line change
@@ -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 ###