Skip to content

Add IEventStoreOptions.IgnoreIndex(name)#4342

Merged
jeremydmiller merged 3 commits into
JasperFx:masterfrom
zidad:feature/event-store-ignore-index
May 8, 2026
Merged

Add IEventStoreOptions.IgnoreIndex(name)#4342
jeremydmiller merged 3 commits into
JasperFx:masterfrom
zidad:feature/event-store-ignore-index

Conversation

@zidad

@zidad zidad commented May 7, 2026

Copy link
Copy Markdown
Contributor

Closes #4341.

What

Adds IEventStoreOptions.IgnoreIndex(string indexName), mirroring the existing DocumentMapping.IgnoreIndex(string indexName) for document tables. The ignore list is consulted by all three event-store tables (mt_events, mt_streams, mt_event_progression) so a single IgnoreIndex("foo") covers any of them.

Why

If you add an index on a Marten-managed event-store table outside Marten's own schema (e.g. a custom IFeatureSchema declaring CREATE INDEX ... ON mt_events USING GIN (headers jsonb_path_ops)), the schema diff sees an unmanaged index on a managed table and drops it on the next ApplyAllDatabaseChangesOnStartup(). The same gap was already solved for documents — this PR brings the event-store side to parity.

Usage

services.AddMarten(opts =>
{
    opts.Events.IgnoreIndex("mt_events_headers_gin_idx");
    opts.Events.IgnoreIndex("mt_events_data_gin_idx");
    opts.Storage.Add<EventQueryIndexFeature>();
});

Changes

  • IEventStoreOptions: new IgnoreIndex(string) method + IReadOnlyList<string> IgnoredIndexes { get; }.
  • IReadOnlyEventStoreOptions: same IgnoredIndexes property.
  • EventGraph: backing list + idempotent add + null/whitespace guard.
  • EventsTable, StreamsTable, EventProgressionTable: copy events.IgnoredIndexes onto the Weasel base Table.IgnoredIndexes (mirrors DocumentTable.cs:25-26).
  • New tests under src/EventSourcingTests/ignoring_indexes_on_event_store_tables.cs (7 tests, all passing on net8/9/10 — no DB required).
  • Doc snippet + section in docs/events/configuration.md.

Opened as draft per the discussion in #4341 — happy to adjust scope or naming.

zidad added 3 commits May 7, 2026 17:21
Mirrors DocumentMapping.IgnoreIndex for the event-store tables. The new
ignore list is consulted by EventsTable, StreamsTable, and
EventProgressionTable so external mechanisms (e.g. a custom
IFeatureSchema declaring a GIN index on mt_events.headers) can register
indexes Marten's schema sync should leave alone.
@zidad zidad marked this pull request as ready for review May 8, 2026 07:45
@jeremydmiller jeremydmiller merged commit eeea7b6 into JasperFx:master May 8, 2026
6 checks passed
This was referenced May 11, 2026
@zidad zidad deleted the feature/event-store-ignore-index branch May 21, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IEventStoreOptions.IgnoreIndex(name) to mirror document table support

2 participants