Repository navigation
feat(db): add partitioning for the events table - #1818
Merged
github-actions[bot] merged 1 commit intoOct 17, 2026
Merged
github-actions[bot] merged 1 commit into
github-actions[bot] merged 1 commit into
Conversation
Convert the audit_events table to a monthly range-partitioned table on
created_at, with a partition management function, a CLI management script,
and comprehensive documentation.
Changes:
- Create db/migrations/013_partition_events_table.sql: renames existing
audit_events to audit_events_legacy, creates partitioned parent with
initial 4 monthly partitions + default partition, migrates data, creates
indexes on parent (auto-propagated to partitions), drops legacy table.
Includes create_audit_events_partition(year, month) SQL function.
- Create scripts/db-partition-manage.js: CLI tool for listing, creating,
and detaching partitions.
- Create docs/EVENTS_PARTITIONING.md: strategy, query compatibility,
management commands, cron automation, partition pruning, and rollback.
Acceptance criteria:
- [x] Partitioning applied — monthly RANGE partitions on created_at with
4 initial partitions + default catch-all
- [x] Queries unaffected — PostgreSQL routes queries transparently; all
existing indexes recreated on parent
- [x] Documented — docs/EVENTS_PARTITIONING.md covers strategy, management,
pruning verification, and rollback
|
@faith3310 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This branch was successfully deployed
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.
Summary
Resolves #1802
Convert the audit_events table to a monthly range-partitioned table on created_at, with a partition management function, a CLI management script, and comprehensive documentation.
Changes
db/migrations/013_partition_events_table.sql: renames existing table, creates partitioned parent with 4 initial monthly partitions + default partition, migrates data, creates indexes on parent, includes create_audit_events_partition() SQL functionscripts/db-partition-manage.js: CLI tool for listing, creating, and detaching partitionsdocs/EVENTS_PARTITIONING.md: strategy, query compatibility, management commands, cron automation, partition pruning, rollbackAcceptance Criteria