fix: alembic 003 avoid :r bind param in fingerprint backfill SQL
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -26,9 +26,11 @@ def upgrade() -> None:
|
|||||||
op.create_index("ix_problems_last_seen_at", "problems", ["last_seen_at"])
|
op.create_index("ix_problems_last_seen_at", "problems", ["last_seen_at"])
|
||||||
|
|
||||||
op.execute(
|
op.execute(
|
||||||
|
sa.text(
|
||||||
"""
|
"""
|
||||||
UPDATE problems p SET
|
UPDATE problems p SET
|
||||||
fingerprint = 'h' || COALESCE(p.host_id::text, '0') || ':r' || COALESCE(p.rule_id, 'unknown'),
|
fingerprint = 'h' || COALESCE(p.host_id::text, '0') || chr(58) || 'r'
|
||||||
|
|| COALESCE(p.rule_id, 'unknown'),
|
||||||
event_count = COALESCE(
|
event_count = COALESCE(
|
||||||
(SELECT COUNT(*)::int FROM problem_events pe WHERE pe.problem_id = p.id),
|
(SELECT COUNT(*)::int FROM problem_events pe WHERE pe.problem_id = p.id),
|
||||||
1
|
1
|
||||||
@@ -36,6 +38,7 @@ def upgrade() -> None:
|
|||||||
last_seen_at = COALESCE(p.updated_at, p.created_at)
|
last_seen_at = COALESCE(p.updated_at, p.created_at)
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
op.alter_column("problems", "fingerprint", nullable=False)
|
op.alter_column("problems", "fingerprint", nullable=False)
|
||||||
op.alter_column("problems", "last_seen_at", nullable=False)
|
op.alter_column("problems", "last_seen_at", nullable=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user