feat: Add SurrealDB driver for Magic - #50
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The current changes introduce a compile-time issue in scripting/collection.go (invalid reflect.Type.Fields() usage) and a Go version/toolchain inconsistency in the SurrealDB example module.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds first-party SurrealDB support to Magic by introducing a new SurrealDB service driver package, wiring up container lifecycle + instructions, and providing a runnable example app/tests that exercise the integration.
Changes:
- Introduce
pkg/databases/surrealdbdriver (container create/health/init, env helpers, and table clear/drop instructions). - Update core/runtime utilities for container reuse checks and script argument collection behavior.
- Add SurrealDB documentation + example project (schemas, app, scripts, integration tests).
File summaries
| File | Description |
|---|---|
| scripting/collection.go | Updates argument-to-struct field collection to skip magic:"ignore" fields. |
| release-please-config.json | Adjusts release-please behavior to open separate PRs. |
| README.md | Documents SurrealDB as a supported database. |
| pkg/databases/surrealdb/surrealdb.go | Adds SurrealDB driver core (config, env helpers, version gating). |
| pkg/databases/surrealdb/surrealdb_container.go | Implements container create/health/init and DB connection helper. |
| pkg/databases/surrealdb/surrealdb_instruct.go | Implements Magic instructions (clear/drop tables) for SurrealDB. |
| pkg/databases/surrealdb/surrealdb_test.go | Adds driver Load/Save roundtrip test. |
| pkg/databases/surrealdb/go.mod | Adds module definition for the SurrealDB driver package. |
| pkg/databases/surrealdb/go.sum | Adds dependency checksums for the SurrealDB driver package. |
| mrunner/services/containers.go | Adjusts container config reuse comparison to only compare Cmd when explicitly set. |
| mrunner/services/containers_diff_test.go | Extends tests to cover the new Cmd reuse comparison behavior. |
| examples/surrealdb/config.go | Adds example Magic config wiring SurrealDB driver + env vars + scripts. |
| examples/surrealdb/main.go | Adds example Fiber app exposing posts endpoints and signaling AppStarted(). |
| examples/surrealdb/main_test.go | Adds integration tests covering post creation + listing with SurrealDB. |
| examples/surrealdb/posts.go | Adds example data model + DB access helpers for posts. |
| examples/surrealdb/scripts.go | Adds example scripts for DB reset/clear/seed and endpoint calls. |
| examples/surrealdb/surreal.go | Adds SurrealDB connection + embedded migration runner for the example. |
| examples/surrealdb/schemas/1_posts.surql | Adds initial SurrealQL schema migration for posts. |
| examples/surrealdb/go.mod | Adds a standalone module for the SurrealDB example. |
| examples/surrealdb/go.sum | Adds dependency checksums for the SurrealDB example. |
Review details
Suppressed comments (1)
examples/surrealdb/scripts.go:80
- Same as
ClearDatabases: this returnserrorbut callslog.Fatallnon failure, which exits the process instead of letting the caller handle the error.
if err := runner.RunInstruction(mconfig.InstructionDropTables); err != nil {
log.Fatalln("Couldn't reset database tables:", err)
}
log.Println("Database reset completed successfully!")
- Files reviewed: 18/20 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Sep 8, 2026
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.
No description provided.