Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown data type: 'uuid' after Laravel 11 update #1317

Open
jamesautodude opened this issue Jul 28, 2024 · 4 comments
Open

Unknown data type: 'uuid' after Laravel 11 update #1317

jamesautodude opened this issue Jul 28, 2024 · 4 comments
Labels

Comments

@jamesautodude
Copy link

jamesautodude commented Jul 28, 2024

Describe the bug
Getting error of "unknown data type "uuid"

To Reproduce

  • Be on or upgrade to Laravel 11
  • Run: php artisan migrate in command line
  • Error will occur (at least in my case)

Expected behavior
Be able to run migrations without an error.

Versions (please complete the following information)

  • PHP: 8.1
  • Database: MariaDB
  • Laravel: 11
  • Package: 4.8

Exception
General error: 4161 Unknown data type: 'uuid' (Connection: mariadb, SQL: alter table activity_logaddbatch_uuiduuid null afterproperties)

Stack Trace

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▕     }

      +8 vendor frames 

  9   database/migrations/2024_07_28_054025_add_batch_uuid_column_to_activity_log_table.php:11
      Illuminate\Database\Schema\Builder::table("activity_log", Object(Closure))
      +37 vendor frames 

  47  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))
@SlimDeluxe
Copy link

It seems your MariaDB version is too old. UUID column type support has been added in 10.7.
So consider upgrading MariaDB to at least 10.11, which is the next currently supported version.

@amfischer
Copy link

I'm getting this same error, but we're running MySQL 8.0.30

@SlimDeluxe
Copy link

I don't use MySQL but it appears the UUID column data type is not supported at all in any version 🤷 They show using BINARY(16) as an equivalent.
I think this package should not use the uuid column type since it's not supported by all systems and Laravel does not seem to be using a fallback. As it seems there's no way it would work at all for an app that uses MySQL.

@amfischer
Copy link

@SlimDeluxe I think you're right. MySQL doesn't seem to natively support UUID data type.

What's strange is we noticed this issue on our staging server, but locally I'm using docker image mysql/mysql-server:8.0 and this error didn't occur. When I check my local db the column type is set to CHAR(36) so somehow it knew to do this? For now we've updated the uuid migration to be $table->char('batch_uuid', 36);

Based on the blog post you linked it seems BINARY(16) should be used instead to take advantage of the helper functions described. But it's not clear how we would use those in Laravel. I'm not sure if a custom cast class could leverage those functions 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants