mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-22 02:24:38 +02:00
feat(schema): add adapter column to events, drop source
Replaces module-path-based source column (e.g. "central/adapters/nws") with stable adapter identifier (e.g. "nws") that foreign-keys to config.adapters.name. Migration 011: - ADD COLUMN adapter TEXT - Backfill via REPLACE(source, 'central/adapters/', '') - SET NOT NULL + FK RESTRICT - CREATE INDEX (adapter, received DESC) for dashboard queries - DROP COLUMN source Code changes: - Event model: source field renamed to adapter - All adapters: use adapter="name" instead of source="central/adapters/name" - Archive: write adapter column instead of source Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4c9ca176a9
commit
8601a19f60
10 changed files with 150 additions and 18 deletions
|
|
@ -25,7 +25,7 @@ def sample_event(sample_geo: Geo) -> Event:
|
|||
"""Sample Event object for testing."""
|
||||
return Event(
|
||||
id="urn:central:nws:alert:KBOI-202401151200-SVR",
|
||||
source="central/adapters/nws",
|
||||
adapter="nws",
|
||||
category="wx.alert.severe_thunderstorm_warning",
|
||||
time=datetime(2024, 1, 15, 12, 0, 0, tzinfo=timezone.utc),
|
||||
expires=datetime(2024, 1, 15, 13, 0, 0, tzinfo=timezone.utc),
|
||||
|
|
@ -75,7 +75,7 @@ class TestSubjectForEvent:
|
|||
)
|
||||
event = Event(
|
||||
id="test-zone",
|
||||
source="test",
|
||||
adapter="nws",
|
||||
category="wx.alert.winter_storm_warning",
|
||||
time=datetime(2024, 1, 15, 12, 0, 0, tzinfo=timezone.utc),
|
||||
geo=geo,
|
||||
|
|
@ -89,7 +89,7 @@ class TestSubjectForEvent:
|
|||
geo = Geo(regions=[], primary_region=None)
|
||||
event = Event(
|
||||
id="test-unknown",
|
||||
source="test",
|
||||
adapter="nws",
|
||||
category="wx.alert.test",
|
||||
time=datetime(2024, 1, 15, 12, 0, 0, tzinfo=timezone.utc),
|
||||
geo=geo,
|
||||
|
|
@ -144,7 +144,7 @@ class TestCloudEventsWire:
|
|||
"""When severity is None, centralseverity is omitted entirely."""
|
||||
event = Event(
|
||||
id="test-no-severity",
|
||||
source="test",
|
||||
adapter="nws",
|
||||
category="wx.alert.test",
|
||||
time=datetime(2024, 1, 15, 12, 0, 0, tzinfo=timezone.utc),
|
||||
severity=None, # Explicitly None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue