fix(legacyimport): imported captures take the new event_type column's default

This commit is contained in:
sam committed 2026-09-24 14:26:18 +10:00
1 parent f279e3b9c0
commit d8d7c5a1f2
1 file changed
+8
@@ -23,6 +23,13 @@ var droppedColumns = map[string]bool{
"playbook_dispatches.id": true,
}
// newColumns are target columns added after the legacy stores, with no
// legacy value to carry. Imported rows take the column default: an imported
// capture has no event type, so it stays unidentified and never dispatches.
var newColumns = map[string]bool{
"captures.event_type": true,
}
// targetKeys override a table's legacy key where the target has no column
// for it.
var targetKeys = map[string][]string{
@@ -171,6 +178,7 @@ func plan(ctx context.Context, tx pgx.Tx, t legacyread.Table, problems *refusal)
problems.add("%s: no target table", t.Name)
}
targetNames := map[string]bool{}
cols = slices.DeleteFunc(cols, func(c column) bool { return newColumns[t.Name+"."+c.name] })
for i := range cols {
targetNames[cols[i].name] = true
cols[i].source = slices.Index(t.Columns, cols[i].name)