singlestoredb/singlestoredb-laravel
Official SingleStoreDB driver for Laravel. Wraps Laravel’s MySQL support to work smoothly with SingleStore, adding Eloquent/migration features (columnstore/rowstore, shard/sort keys, sparse), JSON column support, and compatibility fixes.
Strengths:
Gaps:
ARRAY_AGG, JSON_TABLE) in the Query Builder, requiring raw SQL or custom macros.ORDER BY in UPDATE/DELETE is unsupported (workaround provided), which may limit complex bulk operations.shardKey or sortKey require Schema Builder usage; Eloquent models lack direct attribute-level configuration (e.g., @ShardKey).driver in config/database.php and updating migrations to use SingleStore-specific syntax.ORDER BY in UPDATE/DELETE or MySQL-specific functions (e.g., GROUP_CONCAT) may fail without adjustments.ENGINE=InnoDB) or unsupported data types (e.g., ENUM) require refactoring.true).JSON type vs. Laravel’s json casting).| Risk Area | Severity | Mitigation |
|---|---|---|
| Connection Stability | High | Test persistent connections under load; monitor idle connection limits. |
| Schema Migration Failures | Medium | Use singlestore:dump and singlestore:fresh for safe state resets. |
| Query Performance | Medium | Profile with EXPLAIN; leverage sortKey/shardKey for analytical workloads. |
| ORM Limitations | Low | Use raw SQL or Query Builder macros for unsupported features. |
| SSL/Network Issues | Medium | Pre-validate certificate paths for SingleStore Managed Service. |
UPDATE ... ORDER BY) that require workarounds?PDO fixes). Compatibility Notes:
truncate).PDO::ATTR_EMULATE_PREPARES = false to avoid PHP <8.1 bugs.pdo_mysql (required by SingleStoreDB driver).pdo_pgsql (for cross-database migrations) or redis (for connection pooling).SEMI_JOIN optimizations).| Phase | Tasks | Tools/Commands |
|---|---|---|
| Pre-Migration | 1. Audit queries for MySQL-specific syntax. | php artisan db:show |
2. Test connection with singlestore:dump (schema-only). |
php artisan singlestore:dump |
|
3. Update config/database.php to use singlestore driver. |
Manual config edit | |
| Schema Migration | 1. Convert migrations to use SingleStore-specific syntax (e.g., columnstore(), shardKey). |
Schema Builder methods |
2. Handle unsupported features (e.g., ENUM → VARCHAR). |
Manual SQL or custom macros | |
| Data Migration | 1. Migrate data using singlestore:fresh --seed (if starting fresh). |
php artisan migrate:fresh --seed |
2. For incremental migration, use DB::connection('mysql')->getSchemaBuilder() → SingleStore. |
Custom migration script | |
| Application Testing | 1. Test Eloquent models, Query Builder, and raw SQL. | PHPUnit + Pest |
2. Validate transactions, caching (e.g., cache:table driver). |
php artisan tinker |
|
| Go-Live | 1. Update DB_CONNECTION in .env. |
env('DB_CONNECTION', 'singlestore') |
| 2. Monitor connection pooling and query performance. | SingleStoreDB Cloud UI / Prometheus |
ORDER BY in bulk ops).cache:table driver).failed_jobs table).LOAD DATA INFILE: Use SingleStoreDB’s LOAD DATA or COPY commands.ENGINE=InnoDB: Omit or use rowstore().Schema::defaultStringLength(): SingleStoreDB uses utf8mb4 by default.SoftDeletes: Works, but deleted_at may benefit from a sortKey.LIMIT/OFFSET with ORDER BY: Use sortKey for pagination.singlestore:fresh for resets).How can I help you explore Laravel packages today?