"""Benachrichtigungen: Outbox, E-Mail am Nutzer, Webhook am Workspace Revision ID: 0013 Revises: 0012 Erstellt: 2026-10-22 10:50:29.843374 """ import sqlalchemy as sa from alembic import op revision = '0013' down_revision = '0012' branch_labels = None depends_on = None def upgrade() -> None: op.create_table('notifications', sa.Column('id', sa.Integer(), nullable=False), sa.Column('channel', sa.String(length=20), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=True), sa.Column('event', sa.String(length=50), nullable=False), sa.Column('subject', sa.String(length=300), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('attempts', sa.Integer(), nullable=False), sa.Column('error', sa.String(length=500), nullable=False), sa.Column('available_at', sa.DateTime(timezone=True), nullable=False), sa.Column('created', sa.DateTime(timezone=True), nullable=False), sa.Column('sent', sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_notifications_user_id_users'), ondelete='CASCADE'), sa.ForeignKeyConstraint(['workspace_id'], ['workspaces.id'], name=op.f('fk_notifications_workspace_id_workspaces'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('pk_notifications')) ) op.create_index(op.f('ix_notifications_status'), 'notifications', ['status'], unique=False) op.create_index(op.f('ix_notifications_workspace_id'), 'notifications', ['workspace_id'], unique=False) op.add_column('users', sa.Column('email', sa.String(length=254), nullable=True)) op.add_column('users', sa.Column('notify', sa.Boolean(), server_default=sa.text('true'), nullable=False)) op.add_column('workspaces', sa.Column('webhook', sa.Text(), nullable=True)) op.add_column('workspaces', sa.Column('webhook_hint', sa.String(length=40), server_default='', nullable=False)) def downgrade() -> None: op.drop_column('workspaces', 'webhook_hint') op.drop_column('workspaces', 'webhook') op.drop_column('users', 'notify') op.drop_column('users', 'email') op.drop_index(op.f('ix_notifications_workspace_id'), table_name='notifications') op.drop_index(op.f('ix_notifications_status'), table_name='notifications') op.drop_table('notifications')