Schema migrations in SurrealDB: A local dev workflow
Blog post from SurrealDB
SurrealKit, a CLI tool developed by the SurrealDB team, streamlines the local development workflow by managing schema migrations through .surql files, ensuring that the database remains in sync with code changes. It offers two main modes: Sync, for fast and declarative updates in local environments, and Rollout, for controlled migrations in shared or production databases. The tool integrates with the Rust package manager Cargo and uses environment variables for database connections. Users can easily initiate a development environment, track schema changes, and apply them using commands like `surrealkit sync` and `surrealkit sync --watch`. For shared environments, SurrealKit provides a structured rollout process that includes planning, executing, and, if necessary, rolling back migrations. The tool also supports seeding databases with test data and features a declarative testing framework for validating SQL assertions, permission rules, and API endpoints, making it suitable for CI/CD integration. Overall, SurrealKit enhances productivity by automating schema management and ensuring consistency across development and production environments.