The original premise was wrong. events.events.type, events.triggers.event_type and events.groups.event_type never hold an events.event_types name, so they can't disagree with event_type_id after a rename. They hold the event kind the connector declares in its capabilities (for example incident.opened), plus three built-in kinds with no connector: schedule.tick (modules/events/schedule.go), approval.answer and account.link (modules/events/events.go). events.event_types is a different thing: an operator-defined classifier (rule and schema) on one source, already referenced only by event_type_id. There is no drafts.drafts table.
The defect is the naming: event_type next to event_type_id on events.triggers reads as two references to one thing.
Decision
Keep both concepts. Rename the declared-kind columns to declared_event_type. Not connector_event_type, because the built-in kinds have no connector. Don't fold declared kinds into events.event_types: they have a different lifecycle (they come from a connector manifest, and schedule.tick has no source).
Change
Edit the baseline internal/platform/pg/migrations/00003_events.sql in place (no new migration file; the database is recreated):
events.events.type becomes declared_event_type. Update the partial index events_schedule_slot (WHERE source_id IS NULL AND declared_event_type = 'schedule.tick').
Add a comment on each table saying the column is the kind the connector declares, matched by value, and is not a reference to events.event_types.
Go, in modules/events:
internal/store/store.go: Event.Type, Trigger.EventType, the triggerColumns list, the trigger upsert, Triggers (matching declared_event_type = $3 OR declared_event_type = ''), Recent (the type filter), and the e.type = 'schedule.tick' case in the outcome query.
internal/store/groups.go and internal/store/drafting.go: the events.groups insert, the open-groups query (its join t.event_type = g.event_type), and the event select.
events.go, grouping.go, schedule.go, drafting.go, api.go (triggerInput.EventType, triggerView.EventType, proposedTrigger.EventType, the type query parameter on the events list, eventView.Type, and the body.event_type error locations in checkEventType).
modules/proposals/trigger.go and modules/proposals/api.go: the EventType fields carried from a group into a trigger proposal and its JSON (event_type).
Rename the Go fields to DeclaredEventType and the JSON fields and query parameter to declared_event_type, so the API carries the same distinction. Then run task openapi:generate and update the dashboard callers: ui/src/lib/api.ts, ui/src/events/trigger.ts, ui/src/events/TriggerList.vue, ui/src/workflows/use-workflow-list.ts, ui/src/proposals/ProposalPage.vue. Check ui/src/captures/state.ts and ui/src/captures/event-types.ts: their event_type is the capture view's event type id (modules/events/api_capture.go, captureView.EventType) and should become event_type_id for the same reason.
Done when
No column, Go field or JSON field named event_type or type holds a declared kind; every one is declared_event_type.
events.event_types is referenced only through event_type_id, and its name is read from events.event_types when shown.
task check passes.
The original premise was wrong. `events.events.type`, `events.triggers.event_type` and `events.groups.event_type` never hold an `events.event_types` name, so they can't disagree with `event_type_id` after a rename. They hold the event kind the connector declares in its capabilities (for example `incident.opened`), plus three built-in kinds with no connector: `schedule.tick` (`modules/events/schedule.go`), `approval.answer` and `account.link` (`modules/events/events.go`). `events.event_types` is a different thing: an operator-defined classifier (`rule` and `schema`) on one source, already referenced only by `event_type_id`. There is no `drafts.drafts` table.
The defect is the naming: `event_type` next to `event_type_id` on `events.triggers` reads as two references to one thing.
## Decision
Keep both concepts. Rename the declared-kind columns to `declared_event_type`. Not `connector_event_type`, because the built-in kinds have no connector. Don't fold declared kinds into `events.event_types`: they have a different lifecycle (they come from a connector manifest, and `schedule.tick` has no source).
## Change
Edit the baseline `internal/platform/pg/migrations/00003_events.sql` in place (no new migration file; the database is recreated):
- `events.events.type` becomes `declared_event_type`. Update the partial index `events_schedule_slot` (`WHERE source_id IS NULL AND declared_event_type = 'schedule.tick'`).
- `events.triggers.event_type` becomes `declared_event_type`.
- `events.groups.event_type` becomes `declared_event_type`.
- Add a comment on each table saying the column is the kind the connector declares, matched by value, and is not a reference to `events.event_types`.
Go, in `modules/events`:
- `internal/store/store.go`: `Event.Type`, `Trigger.EventType`, the `triggerColumns` list, the trigger upsert, `Triggers` (matching `declared_event_type = $3 OR declared_event_type = ''`), `Recent` (the `type` filter), and the `e.type = 'schedule.tick'` case in the outcome query.
- `internal/store/groups.go` and `internal/store/drafting.go`: the `events.groups` insert, the open-groups query (its join `t.event_type = g.event_type`), and the event select.
- `events.go`, `grouping.go`, `schedule.go`, `drafting.go`, `api.go` (`triggerInput.EventType`, `triggerView.EventType`, `proposedTrigger.EventType`, the `type` query parameter on the events list, `eventView.Type`, and the `body.event_type` error locations in `checkEventType`).
- `modules/proposals/trigger.go` and `modules/proposals/api.go`: the `EventType` fields carried from a group into a trigger proposal and its JSON (`event_type`).
Rename the Go fields to `DeclaredEventType` and the JSON fields and query parameter to `declared_event_type`, so the API carries the same distinction. Then run `task openapi:generate` and update the dashboard callers: `ui/src/lib/api.ts`, `ui/src/events/trigger.ts`, `ui/src/events/TriggerList.vue`, `ui/src/workflows/use-workflow-list.ts`, `ui/src/proposals/ProposalPage.vue`. Check `ui/src/captures/state.ts` and `ui/src/captures/event-types.ts`: their `event_type` is the capture view's event type id (`modules/events/api_capture.go`, `captureView.EventType`) and should become `event_type_id` for the same reason.
## Done when
- No column, Go field or JSON field named `event_type` or `type` holds a declared kind; every one is `declared_event_type`.
- `events.event_types` is referenced only through `event_type_id`, and its name is read from `events.event_types` when shown.
- `task check` passes.
sam
added the bugmedium labels 2026-11-23 13:13:56 +00:00
sam
changed title from Event types are referenced by name next to their ID to Rename declared event type columns to avoid confusion with event_types2026-11-23 19:54:33 +00:00
Landed in 1c10378a4. Verified with task check and against a throwaway PostgreSQL 18 instance (baseline migrations 00001-00012, source + event type + trigger with declared_event_type and body.declared_event_type error location, events_schedule_slot partial unique index on schedule.tick, capture view event_type_id, and /api/events?declared_event_type filter).
Landed in 1c10378a4. Verified with task check and against a throwaway PostgreSQL 18 instance (baseline migrations 00001-00012, source + event type + trigger with declared_event_type and body.declared_event_type error location, events_schedule_slot partial unique index on schedule.tick, capture view event_type_id, and /api/events?declared_event_type filter).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The original premise was wrong.
events.events.type,events.triggers.event_typeandevents.groups.event_typenever hold anevents.event_typesname, so they can't disagree withevent_type_idafter a rename. They hold the event kind the connector declares in its capabilities (for exampleincident.opened), plus three built-in kinds with no connector:schedule.tick(modules/events/schedule.go),approval.answerandaccount.link(modules/events/events.go).events.event_typesis a different thing: an operator-defined classifier (ruleandschema) on one source, already referenced only byevent_type_id. There is nodrafts.draftstable.The defect is the naming:
event_typenext toevent_type_idonevents.triggersreads as two references to one thing.Decision
Keep both concepts. Rename the declared-kind columns to
declared_event_type. Notconnector_event_type, because the built-in kinds have no connector. Don't fold declared kinds intoevents.event_types: they have a different lifecycle (they come from a connector manifest, andschedule.tickhas no source).Change
Edit the baseline
internal/platform/pg/migrations/00003_events.sqlin place (no new migration file; the database is recreated):events.events.typebecomesdeclared_event_type. Update the partial indexevents_schedule_slot(WHERE source_id IS NULL AND declared_event_type = 'schedule.tick').events.triggers.event_typebecomesdeclared_event_type.events.groups.event_typebecomesdeclared_event_type.events.event_types.Go, in
modules/events:internal/store/store.go:Event.Type,Trigger.EventType, thetriggerColumnslist, the trigger upsert,Triggers(matchingdeclared_event_type = $3 OR declared_event_type = ''),Recent(thetypefilter), and thee.type = 'schedule.tick'case in the outcome query.internal/store/groups.goandinternal/store/drafting.go: theevents.groupsinsert, the open-groups query (its joint.event_type = g.event_type), and the event select.events.go,grouping.go,schedule.go,drafting.go,api.go(triggerInput.EventType,triggerView.EventType,proposedTrigger.EventType, thetypequery parameter on the events list,eventView.Type, and thebody.event_typeerror locations incheckEventType).modules/proposals/trigger.goandmodules/proposals/api.go: theEventTypefields carried from a group into a trigger proposal and its JSON (event_type).Rename the Go fields to
DeclaredEventTypeand the JSON fields and query parameter todeclared_event_type, so the API carries the same distinction. Then runtask openapi:generateand update the dashboard callers:ui/src/lib/api.ts,ui/src/events/trigger.ts,ui/src/events/TriggerList.vue,ui/src/workflows/use-workflow-list.ts,ui/src/proposals/ProposalPage.vue. Checkui/src/captures/state.tsandui/src/captures/event-types.ts: theirevent_typeis the capture view's event type id (modules/events/api_capture.go,captureView.EventType) and should becomeevent_type_idfor the same reason.Done when
event_typeortypeholds a declared kind; every one isdeclared_event_type.events.event_typesis referenced only throughevent_type_id, and its name is read fromevents.event_typeswhen shown.task checkpasses.Event types are referenced by name next to their IDto Rename declared event type columns to avoid confusion with event_typesLanded in
1c10378a4. Verified with task check and against a throwaway PostgreSQL 18 instance (baseline migrations 00001-00012, source + event type + trigger with declared_event_type and body.declared_event_type error location, events_schedule_slot partial unique index on schedule.tick, capture view event_type_id, and /api/events?declared_event_type filter).