Fix incorrect reference to the breadcrumb event, as this was being overridden by the referring event ID.

develop
Sam Black 6 years ago
parent e435a65051
commit fd91a17e95
Signed by: samwwwblack
GPG Key ID: 0FF0223994EA47D8

@ -332,7 +332,7 @@ def record_data(project_id, data, sentry_client):
bc_event = Event.query.filter_by(
event_id=bc_event_id).first()
if bc_event:
bc_data["event_id"] = bc_event.id
bc_data["related_event_id"] = bc_event.id
break
else:
# This sleep shouldn't matter

@ -165,8 +165,14 @@ class Breadcrumb(db.Model):
data = db.Column(JSONType())
message = db.Column(db.Text())
# `event_id` isn't listed in the documentation as existing,
# but clients do send it.
# Clients send an "event_id" not in the documentation,
# which refers to the bread crumb event.
# We need both the breadcrumb event ID and
# the event ID of the the reporting event.
related_event_id = db.Column(db.Integer(), db.ForeignKey("event.id"))
related_event = db.relationship("Event", foreign_keys=[related_event_id])
# Associate the breadcrumb with this event
event_id = db.Column(db.Integer(), db.ForeignKey("event.id"))
@ -238,6 +244,7 @@ class Event(db.Model):
sql_query = db.Column(JSONType())
# Breadcrumbs
breadcrumbs = db.relationship("Breadcrumb", cascade="all, delete",
foreign_keys=[Breadcrumb.event_id],
backref=db.backref("event", uselist=False))
# These are all listed as deprecated in the source code,

@ -0,0 +1,27 @@
"""Link to the related event ID,
rather than allow the referring event to override it.
Revision ID: 0b5f2e6b1861
Revises: 1ec0718b81d5
Create Date: 2017-11-11 18:21:17.931612
"""
# revision identifiers, used by Alembic.
revision = '0b5f2e6b1861'
down_revision = '1ec0718b81d5'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('breadcrumb',
sa.Column('related_event_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'breadcrumb', 'event', ['related_event_id'],
['id'])
def downgrade():
op.drop_constraint(None, 'breadcrumb', type_='foreignkey')
op.drop_column('breadcrumb', 'related_event_id')
Loading…
Cancel
Save