singlestoredb-laravel-driver
singlestoredb-laravel-driver copied to clipboard
Using unique in database migrations
Hey there,
making my way through building an app based on SingleStore and noticed now, that when the migrations use ->unique() it by default does not work, since it does not include all keys defined by the shard key.
You can replicate this issue by using a fresh laravel install and running the migration.
Example from the create_failed_jobs_table:
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
Error:

Should this be solved automatically within this Adapter, so it would make the unique keys including the shard key so people using this adapter does not have to edit the default create table migrations?
I can just remove the ->unique() and make the keys myself, but everyone would have to do so by default, which is extra overhead.
Hey @CodeSkills, thanks for opening the issue! It's a good question. In the SingleStore quickstart blog I do mention that you have to modify these default migrations. It may be worth mentioning that in this repo. I'm not sure I like automatically including stuff in the shard key without the user's explicit intent, as that's a pretty big decision to make on their behalf. How does that sound?
Completely understand what you mean. I opened the issue for the reason that what laravel has by default, most packages by default will use that in their migrations and will have to published and edited. But I mean I guess it will be necessary either ways since there are more differences.
I am adding notes on this to the README.