Skip to content

sqldb: fix migration config consistency coverage#10726

Merged
Roasbeef merged 2 commits intolightningnetwork:masterfrom
ziggie1984:fix-migration-table
Apr 10, 2026
Merged

sqldb: fix migration config consistency coverage#10726
Roasbeef merged 2 commits intolightningnetwork:masterfrom
ziggie1984:fix-migration-table

Conversation

@ziggie1984
Copy link
Copy Markdown
Collaborator

Summary

  • register the migration 14 config entry so the main migration list matches the embedded SQL files
  • add the reverse migration file coverage check and harden the consistency test invariants
  • reject schema version regressions and require migration names to match embedded SQL filenames

Testing

  • GOCACHE=/tmp/go-build-cache go test -run 'TestMigrationConfigConsistency$' -count=1
  • GOCACHE=/tmp/go-build-cache go test -tags='test_native_sql' -run 'TestMigration(ConfigConsistency|FilesAllRegistered)$' -count=1

Add the 000014_payments_no_fail_reason_index migration to the
main migration configuration so the global migration list stays in
sync with the embedded SQL schema files.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 significantly enhances the robustness and consistency of the SQL database migration system. It ensures that the in-code migration configuration accurately reflects the embedded SQL migration files, prevents accidental schema version regressions, and enforces strict naming conventions, thereby improving the reliability of database schema evolution.

Highlights

  • Migration Configuration Alignment: Registered the '000014_payments_no_fail_reason_index' migration config entry to ensure the main migration list matches the embedded SQL files.
  • Enhanced Migration Consistency Checks: Introduced a new test ('TestMigrationFilesAllRegistered') to cover reverse migration file consistency and hardened existing consistency test invariants.
  • Schema Version and Naming Enforcement: Implemented checks to reject schema version regressions and enforce that migration names precisely match their corresponding embedded SQL filenames.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

Footnotes

  1. 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.

@ziggie1984 ziggie1984 self-assigned this Apr 9, 2026
@ziggie1984 ziggie1984 added the sql label Apr 9, 2026
@ziggie1984 ziggie1984 added this to v0.21 Apr 9, 2026
@ziggie1984 ziggie1984 added this to the v0.21.0 milestone Apr 9, 2026
@ziggie1984 ziggie1984 requested a review from yyforyongyu April 9, 2026 11:02
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a 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 introduces a new test, TestMigrationFilesAllRegistered, to ensure that all SQL migration files have corresponding entries in the Go migration configuration. It also enhances TestMigrationConfigConsistency by correcting the previous schema version calculation, enforcing monotonically increasing schema versions, and verifying that migration names in the configuration match their respective SQL file names. Furthermore, an existing migration entry is renamed, and a new migration for payments is added. There is no feedback to provide on the review comments as none were provided.

@ziggie1984 ziggie1984 moved this to In review in v0.21 Apr 9, 2026
@saubyk saubyk requested a review from bhandras April 9, 2026 14:17
Strengthen migration consistency coverage by checking the reverse
mapping from embedded SQL files to migrationConfig entries, deriving
previous schema state from slice order instead of Version, rejecting
schema version regressions, and asserting migration names match the
embedded SQL file stems.

Also fix the graph v2 migration config name to match the embedded
migration filename.
@ziggie1984 ziggie1984 force-pushed the fix-migration-table branch from 5c25e09 to bd7e950 Compare April 9, 2026 20:09
@github-actions github-actions bot added the severity-critical Requires expert review - security/consensus critical label Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Severity: CRITICAL

Automated classification | 1 file (non-test) | 7 lines changed

CRITICAL (1 file)
  • sqldb/migrations.go - Database migration file in sqldb/; per classification rules, all sqldb/ migration files are unconditionally CRITICAL
Low (2 files - excluded from scoring)
  • sqldb/migrations_dev_test.go - Test file (excluded)
  • sqldb/migrations_test.go - Test file (excluded)

Analysis

This PR touches sqldb/migrations.go, which falls under the sqldb/* database migration category. Per the classification rules, database migrations (channeldb/migration*, sqldb/, wtdb/) are always CRITICAL regardless of the size or complexity of the change.

The change is small (6 additions, 1 deletion in the non-test file) and is accompanied by new migration tests, which is good practice. However, database migrations carry inherent risk - a faulty migration can corrupt channel state or render a node unable to start. This warrants expert review to ensure:

  • Migration logic is correct and idempotent
  • Any schema changes are backward-compatible or properly versioned
  • The migration is covered by the new tests added in this PR

To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM 🧰

Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🐔

@Roasbeef Roasbeef merged commit 80572fe into lightningnetwork:master Apr 10, 2026
41 of 46 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in v0.21 Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog severity-critical Requires expert review - security/consensus critical sql

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants