"""bots and webhooks Revision ID: 3350c67553ad Revises: 6ee71c8d5e07 Create Date: 2026-08-14 07:47:25.761745 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = '3350c67553ad' down_revision: Union[str, Sequence[str], None] = '6ee71c8d5e07' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: """Upgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table('api_tokens', sa.Column('id', sa.Uuid(), nullable=False), sa.Column('owner_id', sa.Uuid(), nullable=False), sa.Column('token_hash', sa.String(length=64), nullable=False), sa.Column('scopes', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column('last_used_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_api_tokens_owner_id'), 'api_tokens', ['owner_id'], unique=False) op.create_index(op.f('ix_api_tokens_token_hash'), 'api_tokens', ['token_hash'], unique=True) op.create_table('event_subscriptions', sa.Column('id', sa.Uuid(), nullable=False), sa.Column('room_id', sa.Uuid(), nullable=True), sa.Column('event_types', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column('target_url', sa.String(length=2048), nullable=False), sa.Column('signing_secret', sa.String(length=64), nullable=False), sa.Column('created_by', sa.Uuid(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.ForeignKeyConstraint(['room_id'], ['rooms.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_event_subscriptions_room_id'), 'event_subscriptions', ['room_id'], unique=False) op.create_table('webhooks_incoming', sa.Column('id', sa.Uuid(), nullable=False), sa.Column('room_id', sa.Uuid(), nullable=False), sa.Column('token', sa.String(length=64), nullable=False), sa.Column('created_by', sa.Uuid(), nullable=False), sa.Column('description', sa.String(length=500), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.ForeignKeyConstraint(['room_id'], ['rooms.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_webhooks_incoming_room_id'), 'webhooks_incoming', ['room_id'], unique=False) op.create_index(op.f('ix_webhooks_incoming_token'), 'webhooks_incoming', ['token'], unique=True) # ### end Alembic commands ### def downgrade() -> None: """Downgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_webhooks_incoming_token'), table_name='webhooks_incoming') op.drop_index(op.f('ix_webhooks_incoming_room_id'), table_name='webhooks_incoming') op.drop_table('webhooks_incoming') op.drop_index(op.f('ix_event_subscriptions_room_id'), table_name='event_subscriptions') op.drop_table('event_subscriptions') op.drop_index(op.f('ix_api_tokens_token_hash'), table_name='api_tokens') op.drop_index(op.f('ix_api_tokens_owner_id'), table_name='api_tokens') op.drop_table('api_tokens') # ### end Alembic commands ###