Skip to content

Conversation

@ViktorT-11
Copy link
Contributor

Based on #1881

Bump the migrate dependency to use the latest version of the ll-fork branch.

This main changes of this new version are:

  • SQL migrations & Programmatic migrations now need to be separated into different migration versions.
  • Programmatic migrations can now be configured to be re-run on the next startup if they error. This is done by setting the ResetVersionOnError flag to true for the specific Programmatic migration.

See lightninglabs/migrate#3 for more details.

@gemini-code-assist
Copy link

Summary of Changes

Hello @ViktorT-11, 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 upgrades the project's database migration system by integrating the latest version of the migrate dependency. The core changes revolve around enforcing a clear separation between SQL and programmatic migrations, allowing for more robust and flexible migration strategies. This includes the ability to configure programmatic migrations to automatically retry upon failure. The update involves comprehensive refactoring of migration-related code, introducing new migration files, and enhancing testing to ensure the stability and reliability of the updated migration process across different database backends.

Highlights

  • Dependency Update: The migrate dependency has been updated to its latest version from the ll-fork branch, bringing new features and changes to migration handling.
  • Migration Separation: SQL and programmatic (Go-based) migrations now require separate version numbers, a key change introduced by the updated migrate dependency.
  • Programmatic Migration Enhancements: Programmatic migrations can now be configured to automatically re-run on the next startup if they previously encountered an error, using the ResetVersionOnError flag.
  • API Refactoring: The internal API for handling programmatic migrations has been refactored, renaming PostStepCallback to ProgrammaticMigrEntry and updating related functions and types to align with the new dependency's interface.
  • Migration Script Updates: New placeholder SQL migration files (000050_script_key_type_code_migration.up.sql, 000051_insert_asset_burns_code_migration.up.sql) have been added to accommodate the separation of SQL and programmatic migrations.
  • Migration Test Improvements: New tests have been introduced to ensure the idempotency and correct behavior of programmatic migrations when replayed, specifically for script key type detection and asset burn insertion.
  • Migration Script Validation: The check-migration-numbering.sh script has been enhanced to correctly identify SQL migrations and only enforce the presence of .down.sql files for them, acknowledging the new programmatic migration type.
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.

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

  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.

Copy link

@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 updates the migrate dependency to a newer forked version, which introduces a separation between SQL and programmatic migrations. The changes refactor the existing 'post-migration checks' into first-class 'programmatic migrations', moving them to new, dedicated migration versions (50 and 51). The implementation includes robust testing for the new migration logic, including replay protection for users who have already run the previous migrations. The changes are logical and well-executed. I have a couple of minor suggestions to improve code clarity and maintainability.

@coveralls
Copy link

coveralls commented Dec 11, 2025

Pull Request Test Coverage Report for Build 20794343742

Details

  • 53 of 53 (100.0%) changed or added relevant lines in 4 files are covered.
  • 76 unchanged lines in 16 files lost coverage.
  • Overall coverage increased (+0.009%) to 57.011%

Files with Coverage Reduction New Missed Lines %
tapchannel/aux_leaf_signer.go 2 43.18%
tapdb/addrs.go 2 76.56%
tapdb/sqlc/transfers.sql.go 2 83.33%
tapdb/universe.go 2 81.73%
asset/mock.go 3 73.21%
itest/assertions.go 3 87.42%
proof/verifier.go 3 85.57%
tapdb/interfaces.go 3 80.0%
asset/asset.go 4 80.86%
itest/multisig.go 6 97.52%
Totals Coverage Status
Change from base Build 20783469456: 0.009%
Covered Lines: 65581
Relevant Lines: 115033

💛 - Coveralls

@ViktorT-11 ViktorT-11 force-pushed the 2025-12-use-new-migrate-dep branch from be079b5 to eb54644 Compare December 12, 2025 00:22
@lightninglabs-deploy
Copy link

@ViktorT-11, remember to re-request review from reviewers when ready

The TestMigration50ScriptKeyTypeReplay test previously executed both a
SQL migration and a programmatic migration at the same migration
version. With the new version of the `migrate` dependency, this dual
execution is no longer supported.

In preparation for updating `tapd` to use the new migrate dependency,
this commit therefore updates the test to instead manually apply the
programmatic migration to the db, after the SQL migration has been
successfully executed. This therefore replicates the previous behavior
of executing the both the SQL and programmatic migrations at the same
migration version.
The TestMigration51BurnReplay test previously executed both a SQL
migration and a programmatic migration at the same migration version.
With the new version of the `migrate` dependency, this dual execution is
no longer supported.

In preparation for updating `tapd` to use the new migrate dependency,
this commit therefore updates the test to instead manually apply the
programmatic migration to the db, after the SQL migration has been
successfully executed. This therefore replicates the previous behavior
of executing the both the SQL and programmatic migrations at the same
migration version.
The TestDirtySqliteVersion test previously relied on executing both a
SQL migration and a programmatic migration at the same migration version
for migration version 2 & the latest migration version.
With the new version of the `migrate` dependency, this dual execution is
no longer supported.

In preparation for updating `tapd` to use the new migrate dependency,
this commit therefore updates the test instead override the already
existing programmatic migrations for version 50 & 51, and instead change
their functionality to error when being executed, to trigger setting the
database into a dirty state.
Bump the migrate dependency to use the latest version of the `ll-fork`
branch.

This main changes of this new version are:
* SQL migrations & Programmatic migrations now need to be separated into
  different migration versions.
* Programmatic migrations can now be configured to be re-run on the next
  startup if they error. This is done by setting the
  `ResetVersionOnError` flag to `true` for the specific Programmatic
  migration.

See lightninglabs/migrate#3 for more details.
@ViktorT-11 ViktorT-11 force-pushed the 2025-12-use-new-migrate-dep branch from 74c6bdf to 08cb17d Compare January 7, 2026 19:39
As the `litd` instance run in CI will use the latest `tapd`, and that
`tapd` version requires the new migrate dependency, we need to update
the `lit-setup` action to also replace migrate dependency, so that the
new version is used.

This can be removed once `litd` master has been updated to use the new
migrate dependency.
@ViktorT-11 ViktorT-11 force-pushed the 2025-12-use-new-migrate-dep branch from 08cb17d to ed4e33f Compare January 7, 2026 19:43
@ViktorT-11
Copy link
Contributor Author

This PR is now fully ready for review :)!

@ffranr & @jtobin, I lack the perms in this repo to request reviews from you, but would really appreciate if you could review this one whenever possible 🙏.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

4 participants