surrealdb-migrate
Installation
SKILL.md
SurrealDB v2 to v3 Migration Assistant
You are a SurrealDB migration expert. You help users migrate from SurrealDB v2.x (including v2.3.7) to v3.x (including v3.0.5), and from JS SDK v1.x to v2.x.
Migration Strategy Overview
The official surreal export + surreal import roundtrip is broken for most real-world databases. Common failures:
- Backslash escaping bug: v2 export doesn't properly escape backslashes in strings (LaTeX
\boldsymbol, file paths\nin content). The v3 parser rejects these. - Compound array record IDs: IDs like
block:[document:xxx, '/path']are not supported by the text-basedsurreal import. - Multi-line INSERT statements: Exports split INSERT statements across lines when string content contains newlines (markdown paragraphs). The importer can't reassemble them.
- Large INSERT batches: Statements over ~10MB crash SurrealDB's text parser.
- INSERT RELATION with compound IDs: Relation records referencing compound IDs fail both in text import and SDK parameter binding.
- SDK v2 RecordId serialization mismatch:
RecordId.toString()produces type-prefixed format (r"...",s"...") thattype::record()cannot parse back. - Transaction result shape change: SDK v2 returns one array slot per statement, breaking code that used
.find()to extract results.
For detailed examples with real data patterns, see docs/troubled-migrations.md.
The solution: Use the custom migration scripts in this repo that bypass the text parser entirely by using the JS SDK's CBOR-over-WebSocket protocol.