|
| 1 | +"""Converstaion tags |
| 2 | +
|
| 3 | +Revision ID: 580fd6de4f15 |
| 4 | +Revises: 6868ac66ea92 |
| 5 | +Create Date: 2025-08-07 08:07:27.548324 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = '580fd6de4f15' |
| 14 | +down_revision = '6868ac66ea92' |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.create_table('conversation_tag', |
| 22 | + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), |
| 23 | + sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True), |
| 24 | + sa.Column('name', sa.String(), nullable=True), |
| 25 | + sa.Column('created_at', sa.DateTime(), nullable=True), |
| 26 | + sa.Column('config', sa.JSON(), nullable=True), |
| 27 | + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='CASCADE'), |
| 28 | + sa.PrimaryKeyConstraint('id'), |
| 29 | + schema='cognition' |
| 30 | + ) |
| 31 | + op.create_index(op.f('ix_cognition_conversation_tag_created_by'), 'conversation_tag', ['created_by'], unique=False, schema='cognition') |
| 32 | + op.create_table('conversation_tag_association', |
| 33 | + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), |
| 34 | + sa.Column('conversation_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 35 | + sa.Column('tag_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 36 | + sa.Column('created_at', sa.DateTime(), nullable=True), |
| 37 | + sa.ForeignKeyConstraint(['conversation_id'], ['cognition.conversation.id'], ondelete='CASCADE'), |
| 38 | + sa.ForeignKeyConstraint(['tag_id'], ['cognition.conversation_tag.id'], ondelete='CASCADE'), |
| 39 | + sa.PrimaryKeyConstraint('id'), |
| 40 | + schema='cognition' |
| 41 | + ) |
| 42 | + op.create_index(op.f('ix_cognition_conversation_tag_association_conversation_id'), 'conversation_tag_association', ['conversation_id'], unique=False, schema='cognition') |
| 43 | + op.create_index(op.f('ix_cognition_conversation_tag_association_tag_id'), 'conversation_tag_association', ['tag_id'], unique=False, schema='cognition') |
| 44 | + # ### end Alembic commands ### |
| 45 | + |
| 46 | + |
| 47 | +def downgrade(): |
| 48 | + # ### commands auto generated by Alembic - please adjust! ### |
| 49 | + op.drop_index(op.f('ix_cognition_conversation_tag_association_tag_id'), table_name='conversation_tag_association', schema='cognition') |
| 50 | + op.drop_index(op.f('ix_cognition_conversation_tag_association_conversation_id'), table_name='conversation_tag_association', schema='cognition') |
| 51 | + op.drop_table('conversation_tag_association', schema='cognition') |
| 52 | + op.drop_index(op.f('ix_cognition_conversation_tag_created_by'), table_name='conversation_tag', schema='cognition') |
| 53 | + op.drop_table('conversation_tag', schema='cognition') |
| 54 | + # ### end Alembic commands ### |
0 commit comments