Skip to content

Conversation

@ViktorT-11
Copy link
Contributor

Previously, SQL migrations and code migrations have been designed to be a single migration version, where the SQL migration was run first, followed by a post step migration callback that executed the code migration.

Due to a re-definition of the migration design, which separates SQL and code migrations, we need to update tapd to become compatible with the new migration design before updating to the new design.

This PR therefore separates the code migrations from migration 33 & 37, into separate migration files, and adds those two new migrations to the tapdb/sqlc/migrations directory.

Additionally, since users that have already run the code migrations during migration 33 & 37 will have those migrations re-executed once more after updating to this PR, we test that re-execution of those code migrations will be a no-op for those users, and won't add or change any data in the database.

@ViktorT-11 ViktorT-11 changed the title tapd+sqlc: separate SQL migrations from code migs tapd+sqlc: separate SQL migrations from code migrations Nov 21, 2025
@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 implements a significant refactoring of the migration system within tapd to align with a new design philosophy that mandates a clear separation between SQL schema changes and application-level code migrations. By extracting existing code migrations from their original combined SQL/code versions (33 and 37) into new, standalone migration files (48 and 49), the system gains greater modularity and clarity. A key focus of this change is ensuring that this transition is seamless for existing users, with robust testing confirming that the re-execution of these now-separated code migrations will not introduce any unintended side effects or data modifications.

Highlights

  • Migration Separation: SQL and code migrations are now distinctly separated, moving away from a combined version design.
  • Code Migration Re-versioning: Code migrations originally part of versions 33 and 37 have been extracted into new, dedicated migration files (versions 48 and 49).
  • Idempotency Testing: New tests ensure that re-executing these separated code migrations (48 and 49) is a no-op for users who have already run the original combined migrations, preventing data duplication or corruption.
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.

@ViktorT-11
Copy link
Contributor Author

Will address any failing CI checks on Monday.

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 effectively separates SQL migrations from code migrations for versions 33 and 37 by moving the code migration logic to new, dedicated migration versions 48 and 49. This is a solid architectural improvement that enhances the clarity and maintainability of the migration process.

The new tests, TestMigration48ScriptKeyTypeReplay and TestMigration49BurnReplay, are well-designed and crucial for ensuring backward compatibility. They correctly simulate the upgrade path for existing users and verify that re-running the code migrations is idempotent, which is essential for a safe transition.

However, there is one critical issue: the LatestMigrationVersion constant in tapdb/migrations.go has not been updated to 49. The comment for this constant explicitly states that it must be updated when new migrations are added. Failing to do so can compromise the database downgrade protection mechanism. Please ensure this constant is updated to reflect the new latest migration version.

@coveralls
Copy link

coveralls commented Nov 21, 2025

Pull Request Test Coverage Report for Build 19599245137

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 116 unchanged lines in 20 files lost coverage.
  • Overall coverage decreased (-0.05%) to 56.532%

Files with Coverage Reduction New Missed Lines %
fn/iter.go 2 62.07%
tapdb/assets_store.go 2 79.61%
tapgarden/custodian.go 2 76.83%
universe_rpc_diff.go 2 76.0%
universe/syncer.go 2 84.22%
asset/mock.go 3 73.21%
universe/archive.go 3 80.59%
asset/asset.go 4 80.13%
tapdb/mssmt.go 4 89.55%
tapgarden/caretaker.go 4 76.97%
Totals Coverage Status
Change from base Build 19570339755: -0.05%
Covered Lines: 64307
Relevant Lines: 113753

💛 - Coveralls

Previously, SQL migrations and code migrations have been designed to be
a single migration version, where the SQL migration was run first,
followed by a post step migration callback that executed the code
migration.

Due to a re-definition of the migration design, which separates SQL and
code migrations, we need to update tapd to become compatible with the
new migration design before updating to the new design.

This commit therefore separates the code migrations from migration `33`
& `37`, into separate migration files, and adds those two new migrations
to the `tapdb/sqlc/migrations` directory.

Additionally, since users that have already run the code migrations
during migration `33` & `37` will have those migrations re-executed once
more after updating to this PR, we test that re-execution of those
code migrations will be a no-op for those users, and won't add or change
any data in the database.
@ViktorT-11 ViktorT-11 force-pushed the 2025-11-separate-code-migrations branch from 0346e31 to 18e9478 Compare November 22, 2025 18:03
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.

2 participants