Skip to content

feat(db): add partitioning for the events table - #1818

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
faith3310:fix/issue-1802-partition-events-table
Oct 17, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
faith3310:fix/issue-1802-partition-events-table

Conversation

@faith3310

Copy link
Copy Markdown
Contributor

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

  • Create 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 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, rollback

Acceptance Criteria

  • Partitioning applied — monthly RANGE partitions on created_at with 4 initial partitions + default catch-all
  • Queries unaffected — PostgreSQL routes queries transparently; all existing indexes recreated on parent
  • Documented — docs/EVENTS_PARTITIONING.md covers strategy, management, pruning, and rollback

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
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@github-actions
github-actions Bot merged commit f88c7a6 into Smartdevs17:main Oct 17, 2026
13 of 30 checks passed
@faith3310
faith3310 deployed to security-review October 17, 2026 11:05 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
security-review — 056dd109 Deployed Oct 17, 2026 by faith3310 via Security Dashboard #1368
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 partitioning for the events table

2 participants