-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add missing invoice index for native sql #10155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing invoice index for native sql #10155
Conversation
ziggie1984
commented
Aug 13, 2025
- sqldb: add missing invoice index for native sql
- docs: add release-notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ziggie1984, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new SQL index on the settled_at column of the invoices table to enhance query performance for settled invoices. It also includes an update to the release notes to document this database improvement.
Highlights
- Database Performance Improvement: A new SQL index (invoices_settled_at_idx) has been added to the invoices table on the settled_at column. This is intended to significantly speed up queries involving settled invoices.
- Migration Script Updates: New migration files (000008_invoice_add_settled_index.up.sql and .down.sql) were added to manage the creation and deletion of the new index. Existing migration 000001_invoices.down.sql was also updated to reflect index management changes.
- Documentation: The docs/release-notes/release-notes-0.20.0.md file has been updated to inform users about the addition of this new SQL index.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a missing database index on the settled_at
column of the invoices
table to improve query performance. This is achieved by adding a new migration file for existing databases and updating the initial down
migration. A release note for this change is also included. The changes are logical, but I've found a critical issue in the new down
migration file where a typo in the index name would prevent the migration from being rolled back correctly.
56160c8
to
3ed910b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! just need to please first squash in the fixup commit
b48c8d4
to
61c0fec
Compare
Ohh actually this PR forgot to use this new schema and update the DB, so I put this new schema in the dev migration table so that nothing has to be changed for the graph stuff. |
@gemini-code-assist why did you not notice that I forgot using the new migration file in the migration table ? |
Hi @ziggie1984, Thank you for your question. My review is based on the code changes present in the pull request at the time of the review. Looking at the provided patches, the --- a/sqldb/migrations_dev.go
+++ b/sqldb/migrations_dev.go
@@ -17,4 +17,9 @@ var migrationAdditions = []MigrationConfig{
// schema. This is optional and can be disabled by the
// user if necessary.
},
+ {
+ Name: "000008_invoice_add_settled_index",
+ Version: 10,
+ SchemaVersion: 8,
+ },
} Therefore, this particular change was part of the pull request I reviewed. If there was an earlier version of the PR where this was missing, my review would not have been able to comment on that prior state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
beacf8e
to
98897fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ziggie1984 -you'll also need to update it here:
// graphSQLMigration is the version number for the graph migration
// that migrates the KV graph to the native SQL schema.
const graphSQLMigration = 9
98897fb
to
1210a56
Compare
I added a schema_update doc, pretty hard to write a test on the current version with all the build tags, so I think this doc will help also the AI to make sure schema updates are done properly. This should be obsolete as soon as |
@gemini-code-assist can you verifiy based on the schema update document whether this PR is correct |
Hi @ziggie1984, Thank you for adding the Specifically:
This new documentation is a valuable addition and will certainly help ensure future schema updates are done properly. |
095bffa
to
0157099
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! one commit message is just outdated now
graphExecutor, opts..., | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message is incorrect!
@@ -0,0 +1,224 @@ | |||
# SQL Schema Updates in LND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice docs 🙏 hopefully much of this complexity will be reduced once we switch to sqldbv2
We put this new schema update into the main line and change the versions of the schema updates which are currently only available in dev builds. The schemas need to be chronological therefore we also need to rename the file numbers.
0157099
to
35e9979
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Really nice doc!