- How do I install the SingleStoreDB Laravel driver?
- Run `composer require singlestoredb/singlestoredb-laravel` and update your `config/database.php` to use the `singlestoredb` connection. Replace MySQL credentials with your SingleStoreDB host, port, username, and password. Ensure PHP 8.1+ is used for PDO compatibility.
- Does this driver support Laravel 9 or 10?
- The driver is tested for Laravel 8+ and works with Laravel 9/10, but some newer query builder features (e.g., `truncate`) may require adjustments. Check the GitHub issues for updates on compatibility with the latest Laravel releases.
- Can I use Eloquent with SingleStoreDB’s columnstore tables?
- Yes, the driver extends Eloquent to support columnstore tables via migrations. Use `singlestoredb:columnstore` in your schema definitions. Eloquent models work as usual, but complex operations like `ORDER BY` in `UPDATE/DELETE` require raw SQL or Query Builder macros.
- How do I configure shard keys or sort keys in migrations?
- Use the Schema Builder’s `shardKey()` and `sortKey()` methods in your migrations. For example: `$table->shardKey('user_id');` or `$table->sortKey('timestamp');`. These keys optimize data distribution and query performance in SingleStoreDB.
- Will my existing Laravel queries break when switching to SingleStoreDB?
- Most queries will work, but MySQL-specific features (e.g., `GROUP_CONCAT`, `ORDER BY` in `UPDATE/DELETE`) may fail. Test thoroughly, and use raw SQL or Query Builder macros for unsupported syntax. The driver provides workarounds for common issues.
- Does this driver support JSON columns in Eloquent?
- Yes, SingleStoreDB’s JSON columns are fully supported. Laravel’s built-in JSON casting works out of the box. Access JSON data in Eloquent models like any other attribute, e.g., `$user->profile->name`.
- How do I enable persistent connections for better performance?
- Persistent connections are enabled by default in the driver. For SingleStore Managed Service, ensure SSL is configured in `config/database.php` with the correct certificate paths. Monitor connection limits under high load to avoid timeouts.
- Are there alternatives to this driver for Laravel + SingleStoreDB?
- This is the official SingleStoreDB driver for Laravel, offering deep integration with Eloquent and migrations. Alternatives include raw PDO connections or third-party packages, but they lack native support for SingleStoreDB-specific features like columnstore tables or sharding.
- How do I handle sparse columns or tables in Laravel migrations?
- Use the Schema Builder’s `sparse()` method for columns or tables. For example: `$table->sparse()->string('metadata');` or `$table->sparseTable();`. Sparse columns save storage by excluding NULL values, ideal for analytical workloads.
- What testing considerations are there for SingleStoreDB in Laravel?
- Test transaction isolation (SingleStoreDB uses MVCC but differs from MySQL), connection pooling (persistent connections default to true), and JSON/array handling. Use `singlestoredb:dump` and `singlestoredb:fresh` for safe state resets in CI environments.