Repository navigation
Range-partition a document table by a non-tenant date column (#4779) - #4780
Merged
Merged
Conversation
…lumn The public entry point for this already existed — DocumentMappingExpression<T>.PartitionOn range-partitions a document table on a duplicated, caller-chosen member — but the date-keyed time-series retention scenario was unusable because Weasel reported a spurious destructive partition rebuild on every migration for timestamptz/quoted bounds. - Consume Weasel.Postgresql 9.3.0 (weasel#318), which compares partition bounds by normalized instant instead of raw SQL literal, so date/integer ranges no longer drift. - Add Bug_4779 regression coverage: a MetricsSample table range-partitioned monthly on a duplicated DateTimeOffset, asserting a re-applied managed range diffs as None (the case that depended on the Weasel fix) plus the externally-managed (pg_partman) variant. - Document the time-based retention pattern in storage.md. Closes #4779
This was referenced Jun 26, 2026
This was referenced Jul 6, 2026
This was referenced Jul 13, 2026
This was referenced Aug 3, 2026
This was referenced Aug 10, 2026
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4779.
Summary
The public API the issue asks for already exists:
DocumentMappingExpression<T>.PartitionOn(member, cfg)range-partitions a document table on a duplicated, caller-chosen member (not justtenant_id). What was missing was a working date-keyed path — the classic time-series retention pattern — because the underlying Weasel partition-bound comparison drifted fortimestamptz/quoted literals and reported a spurious, destructive partition rebuild on every migration.That root cause was fixed in Weasel (JasperFx/weasel#318, shipped in 9.3.0): partition bounds are now compared by normalized instant rather than raw SQL literal, so date (and integer) ranges stay stable across deployments and time zones.
Changes
Directory.Packages.props).src/CoreTests/Partitioning/Bug_4779_partition_document_by_date.cs:marten_managed_monthly_range_partitioning_is_idempotent— aMetricsSampletable range-partitioned monthly on a duplicatedDateTimeOffset, asserting a re-applied managed range diffs asSchemaPatchDifference.None(the case that depended on the Weasel fix) and that data survives.externally_managed_range_partitioning_by_date— theByExternallyManagedRangePartitions()(pg_partman / scheduler) variant the issue calls "the most useful first cut".docs/documents/storage.md(with snippets), pluspartmanadded to the cSpell dictionary.Verification
Against the published Weasel 9.3.0:
Bug_4779(2/2) green, and the fullCoreTestspartitioning sweep (35/35) green. The managed-idempotency test was confirmed to fail against pre-fix Weasel.Notes
PartitionOnusable for non-tenant date partitioning.ListPartitionhas the same latent integer-quote drift in Weasel; left for a separate follow-up (range was the reported need).