Add local mode: pull, plan, apply without a server deployment#22
Add local mode: pull, plan, apply without a server deployment#22
Conversation
There was a problem hiding this comment.
Pull request overview
Adds “zero-infrastructure” CLI workflows by introducing a schema bootstrap command (schemabot pull) and enabling schemabot plan to run directly against a target DB in-process (local plan mode) when schemabot.yaml contains a DSN.
Changes:
- Add
schemabot pullto extract live MySQL schema into per-table.sqlfiles plus a generatedschemabot.yaml. - Add local plan mode to
schemabot planusing an in-processLocalClientbacked by an in-memory storage implementation. - Add integration tests covering the pull + local-plan workflow.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/storage/memstore/memstore.go | New in-memory storage.Storage implementation for local plan mode. |
| pkg/cmd/main.go | Registers the new pull CLI command. |
| pkg/cmd/commands/pull.go | Implements schemabot pull (schema extraction + file generation). |
| pkg/cmd/commands/plan.go | Adds local plan execution path using LocalClient + memstore. |
| pkg/cmd/commands/common.go | Extends schemabot.yaml config with dsn for local mode. |
| integration/pull_plan_integration_test.go | Integration tests for pull + local plan behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
09ecfc7 to
2fb883b
Compare
470da36 to
6606bfe
Compare
fc9a871 to
89b053b
Compare
Introduces a local mode that lets users run schema changes against any MySQL database without deploying the SchemaBot server. A background daemon process starts automatically and uses the target database itself for storage, eliminating external dependencies. Key additions: - `schemabot pull` command to fetch current schemas from a database - `schemabot local` subcommand for daemon lifecycle management - Local MySQL detection via reserved 'local' profile - Background daemon with orphan process management - Integration tests for local mode and daemon lifecycle - Configuration docs covering profiles, local databases, and server setup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
89b053b to
7c51423
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Local mode: explicit --profile local, or database found in local config | ||
| if activeProfile == LocalProfile || (endpoint == "" && profile == "" && len(database) > 0 && database[0] != "") { | ||
| db := "" | ||
| if len(database) > 0 { | ||
| db = database[0] |
There was a problem hiding this comment.
The local-mode condition (endpoint=="" && profile=="" && database provided) runs before resolving the configured default profile. This means if a user has default_profile: staging with a remote endpoint, but also has that database in ~/.schemabot/config.yaml under local, the CLI will still prefer local mode and ignore the default remote profile. To match the UX described, consider attempting local mode only when endpoint resolution (including default profile) yields an empty endpoint, or when the active profile is explicitly local.
- Use mysql.ParseDSN in stripDatabaseFromDSN for unix socket safety - Restrict findProcessOnPort to LISTEN state, handle multi-line lsof output - Derive checkLocalMySQL error messages from configured DSN, not hard-coded addr - Add RedactedStorageDSN for local status display - Check SCHEMABOT_PROFILE env var in resolveEndpoint for local mode detection - Return config load errors from tryLocalMode instead of swallowing - Track selected database name when database param is empty - Fix go install path in README (pkg/cmd, not module root) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds zero-infrastructure local mode — the full plan/apply lifecycle works with just the binary and a MySQL connection. No server deployment, no Docker, no AWS needed.
How it works: When no
--endpointor--profileis configured and the database is in~/.schemabot/config.yaml'slocalsection, the CLI auto-starts a backgroundschemabot servedaemon. Storage lives on the developer's local MySQL (localhost:3306/_schemabot), fully decoupled from the target database which can be anywhere (local, remote, PlanetScale).New commands:
schemabot pull --dsn <dsn> -e <env>— bootstraps a declarative schema directory from a live databaseschemabot local status/stop/reset— manage the background serverQuickstart:
Architecture:
schemabot serve) auto-starts on first command, persists between commandslocalhost:3306/_schemabot(auto-bootstrapped via EnsureSchema)schemabot local stopfinds processes by port if PID file is missing~/.schemabot/config.yamlextended withlocalsection for database connection config (supportsenv:secret refs)