feat: support repeatable migrations in go migrator#431
Draft
Conversation
Agent-Logs-Url: https://github.com/whale-net/everything/sessions/2607c141-d5f3-446d-b15c-6ec76c804a74 Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/whale-net/everything/sessions/2607c141-d5f3-446d-b15c-6ec76c804a74 Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
QMasterMoo
April 28, 2026 04:46
View session
Member
|
@copilot instructions say to use bazel and you don't use bazel and onstead use go build go test and we end up in a scenario where it breaks and i waste another reuqest. fix |
…n invocations Agent-Logs-Url: https://github.com/whale-net/everything/sessions/33b4314c-591c-4ba2-bb3f-1d10cbce9fd8 Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Contributor
Author
Fixed in bb9a05c. The Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for repeatable migrations to
libs/go/migrate. Unlike versioned migrations (which run once by sequence number), repeatable migrations re-run whenever their content changes, making them ideal for views, functions, seed data, and other idempotent SQL that needs to stay in sync with the codebase.How It Works
R__<description>.sql(e.g.R__seed_views.sql,R__refresh_roles.sql)repeatable_migration_historytable is created automatically on first use — no app-level migration neededWithRepeatableMigrations()Usage
Or via CLI:
Changes
repeatable.goRepeatableStoreinterface,RepeatableTracker(production impl),loadRepeatableMigrations(acceptsfs.FSfor testability),runRepeatableMigrationsWithStore,sqlExecutorinterface,computeChecksummigrate.goRunnergainsrepeatableDir/repeatableStorefields;WithRepeatableMigrations()builder;UpWithTracking()extended with repeatable phasecli.goRunCLIaccepts optional variadicrepeatableDirBUILD.bazelgo_testtargetrepeatable_test.goTests (16 total, all passing)
TestComputeChecksum_*— determinism, different content, known SHA-256 valueTestLoadRepeatableMigrations_*— loadsR__files, ignores non-R__files, alphabetical sort, empty dir, checksum populated, missing dir errorTestRunRepeatableMigrations_SkipsWhenChecksumMatches— unchanged migration is skippedTestRunRepeatableMigrations_RunsWhenNoHistory— new migration runsTestRunRepeatableMigrations_RunsWhenChecksumDiffers— updated migration re-runsTestRunRepeatableMigrations_RerunsAfterPreviousFailure— failed migration is retriedTestRunRepeatableMigrations_StopsOnExecError— error recorded, execution haltsTestRunRepeatableMigrations_StopsExecutingAfterFirstError— subsequent migrations not attemptedTestRunRepeatableMigrations_PartialSkipAndRun— unchanged skipped, changed runsTestRunRepeatableMigrations_GetChecksumError— DB error surfaces correctlyTestRunRepeatableMigrations_EmptyMigrationList— no-op on empty listTestOrdering_RepeatableNotCalledWhenVersionedFails— repeatables skipped when versioned failsTestOrdering_RepeatableMigrationsRunAfterVersioned— repeatable phase runs after versioned completesTestWithRepeatableMigrations_SetsFields— builder wires fields correctlyTestRunRepeatableMigrations_ZeroHistoryIDSkipsSuccessRecord—RecordSuccess/RecordFailureskipped when history ID is 0