Repository navigation
feat: Apply migrations directly via cli (no server start) - #5028
Merged
Merged
Conversation
nielsenko
force-pushed
the
exp-cli-migrations
branch
3 times, most recently
from
May 3, 2026 08:17
1d5d21a to
37e2bd9
Compare
…w SQL Drops the abstract loadInstalledVersions/loadInstalledRepairMigration methods that previously required the server-package's generated DatabaseMigrationVersion model. The version table schema (serverpod_migrations: id, module, version, timestamp) is stable so querying it via raw SQL is safe and unlocks running migrations from contexts that don't have access to the generated server runtime (e.g. the serverpod CLI driving migrations out-of-pod). ServerMigrationManager keeps its constructor for source compat but loses the now-unused overrides.
…button Adds a CLI-side migration runner that connects to the project's database using the same config + passwords the pod uses, then runs MigrationManager.migrateToLatest against it - no pod restart, no generated server runtime needed. - lib/src/migrations/cli_migration_runner.dart: helper that builds a PoolManager from ServerpodConfig.load and constructs a tiny DatabaseSession + SerializationManagerServer stub for migration use. - lib/src/commands/migrate.dart: 'serverpod migrate' subcommand. - start.dart's WatchSession now wires applyMigrationsAction to the helper. The TUI 'Apply Migration' button runs migrations in-place; the pod stays running and hot reload covers any model code changes. - The legacy pod-restart path is preserved as a fallback for sessions that don't supply applyMigrationsAction (--no-fes, anything else that wants the old behaviour).
nielsenko
force-pushed
the
exp-cli-migrations
branch
from
May 3, 2026 08:31
37e2bd9 to
a0a7291
Compare
nielsenko
marked this pull request as ready for review
May 4, 2026 10:11
marcelomendoncasoares
requested changes
May 4, 2026
marcelomendoncasoares
left a comment
Collaborator
There was a problem hiding this comment.
Few suggestions for improvement. On the integrity check, we can spin to fix as a follow-up, as discussed.
- Make applyMigrationsAction required on WatchSession. - Drop _applyMigrationByRestart and the extraArgs hook on ServerProcessFactory. - Update applyingMigration enum + applyMigration dartdoc.
Route ops through _chain() that hands failure to the caller while the queue stays runnable.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR allows migrations to be applied by cli without restarting pod. This plays well together with the
VmServiceProxy(from #5022) as it avoids detaching any potential debugger when applying migration from TUI (or if an agent does it via the MCP).Also fixes a long standing request.
Fixes: #3119