Laravel по-русски

Русское сообщество разработки на PHP-фреймворке Laravel.

Ты не вошёл. Вход тут.

#1 Laravel 6/7/8/9/10/11 » Laravel 12 не накатывается миграция » Сегодня 10:24:10

fenix_63
Ответов: 0

Всем привет! Только недавно начал изучать Laravel. Пробую накатить миграцию, php artisan выдаёт ошибку:

Illuminate\Database\QueryException

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed:   
.  (Connection: mysql, Host: mysql, Port: 3306, Database: laravel_db, SQL: select exists (select 1
from information_schema.tables where table_schema = schema() and table_name = 'migrations' and table
_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as `exists`)

Команда:

php artisan migrate --path=\\database\\migrations\\2026_07_01_190012_create_posts_table.php

Запускал из под windows 11.

Содержимое самого файла миграции 2026_07_01_190012_create_posts_table.php:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('posts', function (Blueprint $table) {
			$table->bigInteger('id')->primary()->autoIncrement();
			$table->bigInteger('post_id');
			$table->bigInteger('user_id');
			$table->string('title');
			$table->text('content')->nullable(false);//NOT NULL
			$table->enum('status',['draft', 'published', 'archived'])->default('published');
			$table->integer('views_count')->default(0);
			$table->integer('likes_count')->default(0);
			$table->timestamp('created_at')->useCurrent();
			$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
			$table->index(['user_id'],'idx_user_id');
			$table->index(['created_at'],'idx_created_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('posts');
    }
};

Подскажите, что я делаю не так? Что подправить, чтоб миграция нормально накатилась? Пробовал также накатывать другие миграции - тоже самое. Но с получением данных по API проблем нет. Не понимаю почему ругается на подключение к БД.

Подвал раздела