|
| 1 | +"""Remove CaseAction and CaseContext and remove workspace ID from CaseEvent |
| 2 | +
|
| 3 | +Revision ID: 9331e7a72410 |
| 4 | +Revises: ebf7613506e0 |
| 5 | +Create Date: 2024-08-22 21:22:39.732969 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence, Union |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | +from sqlalchemy.dialects import postgresql |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision: str = '9331e7a72410' |
| 16 | +down_revision: Union[str, None] = 'ebf7613506e0' |
| 17 | +branch_labels: Union[str, Sequence[str], None] = None |
| 18 | +depends_on: Union[str, Sequence[str], None] = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade() -> None: |
| 22 | + # ### commands auto generated by Alembic - please adjust! ### |
| 23 | + op.drop_index('ix_casecontext_id', table_name='casecontext') |
| 24 | + op.drop_table('casecontext') |
| 25 | + op.drop_index('ix_caseaction_id', table_name='caseaction') |
| 26 | + op.drop_table('caseaction') |
| 27 | + op.alter_column('caseevent', 'case_id', |
| 28 | + existing_type=sa.VARCHAR(), |
| 29 | + nullable=True) |
| 30 | + op.create_foreign_key(None, 'caseevent', 'case', ['case_id'], ['id'], ondelete='CASCADE') |
| 31 | + op.drop_column('caseevent', 'workflow_id') |
| 32 | + # ### end Alembic commands ### |
| 33 | + |
| 34 | + |
| 35 | +def downgrade() -> None: |
| 36 | + # ### commands auto generated by Alembic - please adjust! ### |
| 37 | + op.add_column('caseevent', sa.Column('workflow_id', sa.VARCHAR(), autoincrement=False, nullable=False)) |
| 38 | + op.drop_constraint(None, 'caseevent', type_='foreignkey') |
| 39 | + op.alter_column('caseevent', 'case_id', |
| 40 | + existing_type=sa.VARCHAR(), |
| 41 | + nullable=False) |
| 42 | + op.create_table('caseaction', |
| 43 | + sa.Column('surrogate_id', sa.INTEGER(), autoincrement=True, nullable=False), |
| 44 | + sa.Column('owner_id', sa.UUID(), autoincrement=False, nullable=False), |
| 45 | + sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"), autoincrement=False, nullable=False), |
| 46 | + sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"), autoincrement=False, nullable=False), |
| 47 | + sa.Column('id', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 48 | + sa.Column('tag', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 49 | + sa.Column('value', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 50 | + sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=True), |
| 51 | + sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='caseaction_user_id_fkey'), |
| 52 | + sa.PrimaryKeyConstraint('surrogate_id', name='caseaction_pkey') |
| 53 | + ) |
| 54 | + op.create_index('ix_caseaction_id', 'caseaction', ['id'], unique=True) |
| 55 | + op.create_table('casecontext', |
| 56 | + sa.Column('surrogate_id', sa.INTEGER(), autoincrement=True, nullable=False), |
| 57 | + sa.Column('owner_id', sa.UUID(), autoincrement=False, nullable=False), |
| 58 | + sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"), autoincrement=False, nullable=False), |
| 59 | + sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"), autoincrement=False, nullable=False), |
| 60 | + sa.Column('id', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 61 | + sa.Column('tag', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 62 | + sa.Column('value', sa.VARCHAR(), autoincrement=False, nullable=False), |
| 63 | + sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=True), |
| 64 | + sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='casecontext_user_id_fkey'), |
| 65 | + sa.PrimaryKeyConstraint('surrogate_id', name='casecontext_pkey') |
| 66 | + ) |
| 67 | + op.create_index('ix_casecontext_id', 'casecontext', ['id'], unique=True) |
| 68 | + # ### end Alembic commands ### |
0 commit comments