2

I'm currently working with Laravel and came across a strange issue, though I could not find any answer to it.

When I install Laravel (Jetstream) on Docker with NGINX (Latest), PHP-FPM (PHP 8) and MariaDB 10.5, everything works as expected and I can run all migrations.

As soon as I switch to MariaDB 10.6 I get

SQLSTATE[HY000] [2002] Connection refused (SQL: alter table `team_invitations` add unique `team_invitations_team_id_email_unique`(`team_id`, `email`))

Strangely all table creations work as expected.

This is the migration part where it comes from:

Schema::create('team_invitations', function (Blueprint $table) {
    $table->id();
    $table->foreignId('team_id')->constrained()->cascadeOnDelete();
    $table->string('email');
    $table->string('role')->nullable();
    $table->timestamps();

    $table->unique(['team_id', 'email']);
});

Does anyone have an idea where this comes from/what the solution could be?

The stack trace shows me correct network / database settings.

Also running the query manually works as expected.

  • Check these following answers I think it will help in your case (https://stackoverflow.com/a/35417112/7902645) (https://stackoverflow.com/a/29400976/7902645) – Shahid Rasheed Sep 28 '21 at 06:41
  • Make sure DB user has required privileges to perform this action – mwafi Sep 28 '21 at 16:03
  • I had this same issue today - alter table commands in migrations would result in exact same error you posted. I was not able to find any real solution or documentation related to this error, so I eventually edited my docker-compose.yml file to use mysql:latest instead of mariadb:10.6. Let me know if you found a working solution. – mstephenson Mar 01 '23 at 02:46

0 Answers0