Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wjgvm's avatar
Level 1

not up schema "user" field uuid in laravel 11

When I generate a new user schema and include uuid() it gives me an error when I shade when I comment that line it runs perfectly, I reinstalled laravel twice and it gives me the same error I tried laravel 9 and it works perfectly I installed the webpatser/laravel-uuid package And something that can help me doesn't work either, is it the Laravel version?

Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('dni')->nullable(); $table->uuid('slug')->unique(); $table->string('names'); $table->timestamps(); });

$table->uuid('slug')->unique();

0 likes
5 replies
dualklip's avatar

Your code works well for me in a fresh Laravel installation using MariaDB. I don't tried with MySQL

wjgvm's avatar
Level 1

i use mariadb and test with mysql too, it doing print same error.! change database version and collation, nothing

I left it as string, it done

Snapey's avatar

it gives me an error

at least you get to know the error. Its a mystery for the rest of us

wjgvm's avatar
Level 1

this error by use

Illuminate\Database\QueryException

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null, email varchar(255) not null, email_verified_at timestamp null, ...' at line 1 (Connection: mariadb, SQL: create table users (id bigint unsigned not null auto_increment primary key, name varchar(255) not null, slug uuid not null, email varchar(255) not null, email_verified_at timestamp null, password varchar(255) not null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

at vendor\laravel\framework\src\Illuminate\Database\Connection.php:813 809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 810▕ ); 811▕ } 812▕ ➜ 813▕ throw new QueryException( 814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 815▕ ); 816▕ } 817▕ }

1 vendor\laravel\framework\src\Illuminate\Database\Connection.php:565 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null, email varchar(255) not null, email_verified_at timestamp null, ...' at line 1")

2 vendor\laravel\framework\src\Illuminate\Database\Connection.php:565 PDO::prepare("create table users (id bigint unsigned not null auto_increment primary key, name varchar(255) not null, slug uuid not null, email varchar(255) not null, email_verified_at timestamp null, password varchar(255) not null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")

Snapey's avatar

MariaDB introduced the UUID data type in version 10.7. The first long-term support (LTS) version to include it is 10.11, which was declared stable in February 2023.

What version do you have?

1 like

Please or to participate in this conversation.