Add migration to prune previous ticket self-mentions

This commit is contained in:
наб 2020-08-21 18:39:21 +02:00 committed by Drew DeVault
parent 2c881a696e
commit 44d05940ed
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
"""Remove self-referencing ticket mention events
Revision ID: 074182407bb2
Revises: 61e241dc978c
Create Date: 2020-08-21 18:25:15.512581
"""
# revision identifiers, used by Alembic.
revision = '074182407bb2'
down_revision = '61e241dc978c'
from alembic import op
from todosrht.types import Event, EventType
from sqlalchemy.orm import sessionmaker
Session = sessionmaker()
def upgrade():
bind = op.get_bind()
session = Session(bind=bind)
(session.query(Event)
.filter(Event.event_type == EventType.ticket_mentioned)
.filter(Event.from_ticket_id == Event.ticket_id)).delete()
def downgrade():
pass