Skip to content

feat(notif): index chan notifs on msg id#2799

Merged
seanaye merged 1 commit into
mainfrom
seanaye/feat/index-notif-chan-msg-id
Apr 23, 2026
Merged

feat(notif): index chan notifs on msg id#2799
seanaye merged 1 commit into
mainfrom
seanaye/feat/index-notif-chan-msg-id

Conversation

@seanaye
Copy link
Copy Markdown
Contributor

@seanaye seanaye commented Apr 23, 2026

Add index for chann notifs on msg id

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Optimized database performance through index improvements on notification data.

Walkthrough

Adds a PostgreSQL migration that creates a concurrent index on the notification table targeting the metadata->>'messageId' expression with a partial predicate filtering for event_item_type = 'channel', executed outside a transaction.

Changes

Cohort / File(s) Summary
Database Migration
rust/cloud-storage/macro_db_client/migrations/20260423120001_idx_notification_channel_message_id.sql
Introduces non-transactional SQL migration creating a partial concurrent index on notification(metadata->>'messageId') where event_item_type = 'channel'.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the conventional commits format (feat:) and is under 72 characters (40 chars), accurately describing the main change of adding an index on channel notifications for message ID lookup.
Description check ✅ Passed The description is concise and directly related to the changeset, indicating the intent to add an index for channel notifications on message ID, which aligns with the SQL migration file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seanaye seanaye marked this pull request as ready for review April 23, 2026 16:55
@seanaye seanaye requested a review from a team as a code owner April 23, 2026 16:56
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@rust/cloud-storage/macro_db_client/migrations/20260423120001_idx_notification_channel_message_id.sql`:
- Around line 1-5: The migration creates a concurrent index
notification_channel_message_id_idx on notification ((metadata->>'messageId'))
for event_item_type='channel' but lacks a rollback; add or document a reversible
step by providing the rollback SQL DROP INDEX CONCURRENTLY IF EXISTS
notification_channel_message_id_idx (either in a corresponding "down" migration
file or in the migration workflow notes) and ensure the migration metadata or
tooling references this rollback so the create step in the migration is
reversible.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 87d80c77-caf8-4266-bd59-cc3c84473456

📥 Commits

Reviewing files that changed from the base of the PR and between 9f11c63 and b5f4c8f.

📒 Files selected for processing (1)
  • rust/cloud-storage/macro_db_client/migrations/20260423120001_idx_notification_channel_message_id.sql

Comment on lines +1 to +5
-- no-transaction

CREATE INDEX CONCURRENTLY IF NOT EXISTS notification_channel_message_id_idx
ON notification ((metadata->>'messageId'))
WHERE event_item_type = 'channel';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add an explicit rollback path for this migration.

This change is safe forward, but there is no rollback strategy shown. Please add or document the rollback command (DROP INDEX CONCURRENTLY IF EXISTS notification_channel_message_id_idx;) in your migration workflow.

Suggested rollback SQL
+-- rollback
+DROP INDEX CONCURRENTLY IF EXISTS notification_channel_message_id_idx;

As per coding guidelines, “Confirm migrations are reversible or have a clear rollback strategy.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-- no-transaction
CREATE INDEX CONCURRENTLY IF NOT EXISTS notification_channel_message_id_idx
ON notification ((metadata->>'messageId'))
WHERE event_item_type = 'channel';
-- no-transaction
CREATE INDEX CONCURRENTLY IF NOT EXISTS notification_channel_message_id_idx
ON notification ((metadata->>'messageId'))
WHERE event_item_type = 'channel';
-- rollback
-- DROP INDEX CONCURRENTLY IF EXISTS notification_channel_message_id_idx;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rust/cloud-storage/macro_db_client/migrations/20260423120001_idx_notification_channel_message_id.sql`
around lines 1 - 5, The migration creates a concurrent index
notification_channel_message_id_idx on notification ((metadata->>'messageId'))
for event_item_type='channel' but lacks a rollback; add or document a reversible
step by providing the rollback SQL DROP INDEX CONCURRENTLY IF EXISTS
notification_channel_message_id_idx (either in a corresponding "down" migration
file or in the migration workflow notes) and ensure the migration metadata or
tooling references this rollback so the create step in the migration is
reversible.

@seanaye seanaye requested a review from gbirman April 23, 2026 16:58
@seanaye seanaye merged commit 4168b60 into main Apr 23, 2026
59 checks passed
@seanaye seanaye deleted the seanaye/feat/index-notif-chan-msg-id branch April 23, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants