feat: add journaled schema migration runner - #3
Merged
Merged
Conversation
ExperienceSchemaMigrator.MigrateAsync applies the package's embedded scripts through DbUp: journaled to agent_experience.schema_versions, one transaction per script, serialized across processes by a session advisory lock held on its own connection. Hosts call it explicitly; the store never migrates. Replaces the manual apply loop in the README and the test fixture, and closes the Story 2.1 epic criterion for documented migrations. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
ExperienceSchemaMigrator.MigrateAsync(NpgsqlDataSource, CancellationToken)toAgentExperience.Storage.Postgres, and returns the scripts it applied.agent_experience.schema_versions, so a rerun applies nothing. A database whose0001was applied by hand is journaled on the next run without losing rows.ExperienceStoreExceptionnaming it, with no SQL text or row data. Scripts applied before it stay applied.dbup-postgresql7.0.1 anddbup-core6.1.1, both exact, verified against Npgsql 10.0.3. The Abstractions and Core dependency-boundary tests now forbid DbUp too.This closes the Story 2.1 epic criterion for documented migrations, which was deferred when 2.1 was split, and unblocks Story 2.4.
Behaviour worth knowing (documented)
OperationCanceledExceptionand leaves no lock held.Command Timeouton the data source.CREATEon the database and on the schema. The store itself still only needsINSERTandSELECT.Deferred
Verifying that the runner emits nothing to the host's log sink. Logged in
deferred-work.md.Test plan
dotnet build --configuration Release: 0 warnings, 0 errorsdotnet test --configuration Release: 315 of 315 pass (52 store tests, up from 40). Locally withTESTCONTAINERS_RYUK_DISABLED=true.0001, concurrent runs blocked on the lock, failing script, cancellation. Two more cover a second script applying on top of a journaled one with$body$quoting intact, and the embedded scripts matchingScriptNames.🤖 Generated with Claude Code