- What Laravel versions does spatie/laravel-binary-uuid support?
- The package is designed for Laravel 5.x and is not compatible with Laravel 6+ or newer versions. Since it’s unmaintained, it may break with future Laravel updates. Always test thoroughly before use.
- How do I migrate an existing Laravel app using string UUIDs to binary UUIDs?
- You’ll need to add a new binary column, backfill data, and update models to use the `HasBinaryUuid` trait. The README suggests a phased approach: add the binary column alongside the existing UUID, migrate data, then drop the old column. Downtime may be required for large tables.
- Will this package work with PostgreSQL?
- No, this package is optimized for MySQL and SQLite only. PostgreSQL natively supports binary UUIDs, so you wouldn’t gain the same performance benefits. If you’re using PostgreSQL, consider alternatives like `ramsey/uuid` or native binary storage.
- Are there performance benchmarks available to justify the migration?
- Yes, the package includes built-in benchmarks to compare query performance between string and binary UUIDs. Run them locally to measure improvements for your specific workload, as gains depend on table size, query patterns, and database configuration.
- How does this package handle UUID generation and validation?
- The package integrates with Laravel’s Eloquent to generate UUIDs (defaulting to UUIDv4) and automatically encodes them into binary format. Validation remains unchanged—you can still use Laravel’s built-in UUID validation rules or custom logic as needed.
- Can I use binary UUIDs with Laravel Scout for full-text search?
- No, binary UUIDs won’t work directly with Laravel Scout, which expects string-based primary keys. You’d need to expose the UUID as a string in your API or use a workaround like a separate `searchable_as` column with the string UUID.
- What are the risks of using an unmaintained package in production?
- Risks include compatibility issues with future Laravel or database updates, lack of security patches, and no support for bug fixes. If you proceed, plan for a migration path to a maintained alternative (e.g., `michaeldyrynda/laravel-efficient-uuid`) within 12–24 months.
- How do I query models by UUID if the primary key is stored as binary?
- The package provides Eloquent scopes like `whereUuid()` to query by UUID strings seamlessly. Under the hood, it converts the string to binary for the query. You can also use the `find()` method with a UUID string, and it will work as expected.
- Will this break existing foreign key relationships or indexes?
- Yes, if other tables reference the UUID as a string, you’ll need to update those foreign keys to use the binary format or add a separate string column for compatibility. Always audit your schema before migrating to avoid breaking references.
- Are there alternatives to spatie/laravel-binary-uuid that are actively maintained?
- Yes, consider `michaeldyrynda/laravel-efficient-uuid` or `michaeldyrynda/laravel-model-uuid`, both of which offer similar performance benefits with active maintenance. Evaluate their features (e.g., PostgreSQL support, Laravel version compatibility) before switching.