successdav
5 months ago

add unique $table->unique generates error

Posted 5 months ago by successdav
$table->unique(['user_id', 'subscriber_id', 'subscriber_type', 'active']);

The above code generate error when migrating the database; error:

SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'subscriptions_user_id_subscriber_id_subscriber_type_active_unique' is too long (SQL: alter table `subscriptions` add unique `subscriptions_user_id_subscriber_id_subscriber_type_active_unique`(`user_id`, `subscriber_id`, `subscriber_type`, `active`))

When I remove active from the array it runs without error

$table->unique(['user_id', 'subscriber_id', 'subscriber_type']);

Any Idea why it so? I really need the active to be included in the unique row

Please sign in or create an account to participate in this conversation.