Skip to content

feat: Add SurrealDB driver for Magic - #50

Merged
Unbreathable merged 5 commits into
mainfrom
feat/surrealdb
Sep 8, 2026
Merged

Unbreathable merged 5 commits into
mainfrom
feat/surrealdb

Conversation

@Unbreathable

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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/surrealdb driver (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 returns error but calls log.Fatalln on 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.

Comment thread scripting/collection.go
Comment thread examples/surrealdb/go.mod
Comment thread examples/surrealdb/scripts.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Unbreathable
Unbreathable merged commit c5f30f6 into main Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants