Reputation: 1
I have just updated to MySQL 8 and Laravel 8.12, and I use Laravel standard notification on my system. Before I upgraded my Mysql 5.7 to 8 (test environment), I had no problem with migration, but not its complaints.
SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. (SQL: create table
notifications
(id
char(36) not null,type
varchar(255) not null,notifiable_type
varchar(255) not null,notifiable_id
bigint unsigned not null,data
text not null,read_at
timestamp null,created_at
timestamp null,updated_at
timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
But in my migration, there is a primary key specified as it does from the notification standard migration.
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
How can I fix this error?
Upvotes: 0
Views: 1922
Reputation: 3
1-try $table->increments('id');
2-try php artisan migrate:rollback
3-try php artisan migrate:refresh
but be careful you will lost your data in your database
Upvotes: -1