String data, right truncated: 1406 Data too long for column
RyaiStudio opened this issue · 1 comments
RyaiStudio commented
I'm having trouble on migration using the following documentation
https://medium.com/@steveazz/setting-up-uuids-in-laravel-5-552412db2088
on migration table
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->uuid('api_token'); ....
Error:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column
'api_token' at row 1 (SQL: insert into `users` (`name`, `email`, `password`,
`api_token`, `id`, `updated_at`, `created_at`) values (ryai, ryanpagaduan23@g
mail.com, $2y$10$dc2KEaRkO19R.Thub8I11./AXezb3qoCyqumuGMfbSMhwF70YHCIe, 8560b
59ebbfc01d882175c39ce860480a06b4c6a6aa56382032e4a8c2c8a, a3674340-2de9-11e9-a
087-c93c351f4ba4, 2019-02-11 10:41:50, 2019-02-11 10:41:50))
webpatser commented
The uuid field type uses the binary option. You are passing the string representation.
So two options
$table->char('api_token', 36);
or
when inserting the uuid insert the binary variant instead of the string.