Skip to content

Commit

Permalink
Pipeline Versions (#271)
Browse files Browse the repository at this point in the history
* Adds version tables

* Remove organization id

* fix alembic

* submodule & hotfix

* Adds change

* Alembic for fkey remove

* Submodule change

* Submodule merge
  • Loading branch information
JWittmeyer authored Nov 27, 2024
1 parent 0d61cb2 commit f2f0c1e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
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 ###

0 comments on commit f2f0c1e

Please sign in to comment.