Skip to content

fix: add account_advisory (advisory_id) index - #2312

Merged
MichaelMraka merged 1 commit into
RedHatInsights:masterfrom
MichaelMraka:pr1
Aug 21, 2026
Merged

fix: add account_advisory (advisory_id) index#2312
MichaelMraka merged 1 commit into
RedHatInsights:masterfrom
MichaelMraka:pr1

Conversation

@MichaelMraka

@MichaelMraka MichaelMraka commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

to improve clean_unused_data job performance

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Improve account advisory data cleanup performance by indexing advisory IDs.

Bug Fixes:

  • Improve clean_unused_data job performance by adding an index for account advisory lookups by advisory ID.

Chores:

  • Update the database schema migration version and add reversible index migration scripts.

to improve clean_unused_data job performance
@MichaelMraka
MichaelMraka requested a review from a team as a code owner August 20, 2026 14:54
@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds an index on account_advisory.advisory_id, wires it into the schema creation script, and introduces migration scripts to create and drop the index, bumping the schema version accordingly.

File-Level Changes

Change Details Files
Introduce migration scripts to create and drop the advisory_id index on account_advisory and bump the schema version.
  • Add an up migration that creates an index on advisory_id for the account_advisory table.
  • Add a down migration that drops the advisory_id index if it exists.
  • Update the schema_migrations seed entry to version 166 to reflect the new migration.
database_admin/migrations/166_account_advisory_idx.up.sql
database_admin/migrations/166_account_advisory_idx.down.sql
database_admin/schema/create_schema.sql
Ensure the advisory_id index exists when creating the schema from scratch.
  • Add CREATE INDEX statement for advisory_id on account_advisory to the schema creation script alongside existing indexes.
database_admin/schema/create_schema.sql

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • If the account_advisory table is large and migrations run on a live system, consider using CREATE INDEX CONCURRENTLY in the up migration to avoid long locks and downtime during index creation.
  • For consistency and clarity, you may want to give the new index an explicit name in the up migration (e.g. CREATE INDEX account_advisory_advisory_id_idx ON account_advisory (advisory_id);) rather than relying on the default generated name.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If the `account_advisory` table is large and migrations run on a live system, consider using `CREATE INDEX CONCURRENTLY` in the up migration to avoid long locks and downtime during index creation.
- For consistency and clarity, you may want to give the new index an explicit name in the up migration (e.g. `CREATE INDEX account_advisory_advisory_id_idx ON account_advisory (advisory_id);`) rather than relying on the default generated name.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.83%. Comparing base (d10dbcc) to head (60072be).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2312   +/-   ##
=======================================
  Coverage   58.82%   58.83%           
=======================================
  Files         150      150           
  Lines        9604     9605    +1     
=======================================
+ Hits         5650     5651    +1     
  Misses       3360     3360           
  Partials      594      594           
Flag Coverage Δ
unittests 58.83% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelMraka
MichaelMraka merged commit 8ec0087 into RedHatInsights:master Aug 21, 2026
8 checks passed
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.

3 participants