@kaliboba

Почему не получается сделать миграцию в Laravel?

Не могу сделать миграцию, выдаёт ошибку:
2023_07_07_115719_create_products_table .............................................. 350ms FAIL

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 'date) null, `updated_at` timestamp(date) null, `name` varchar(255) not null, ...' at line 1 (Connection: mysql, SQL: create table `products` (`id` bigint unsigned not null auto_increment primary key, `created_at` timestamp(date) null, `updated_at` timestamp(date) null, `name` varchar(255) not null, `price` int not null, `des` text not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

1 vendor\laravel\framework\src\Illuminate\Database\Connection.php:574
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 'date) null, `updated_at` timestamp(date) null, `name` varchar(255) not null, ...' at line 1")

2 vendor\laravel\framework\src\Illuminate\Database\Connection.php:574
PDO::prepare()

файл миграции:
public function up(): void
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->timestamps('date');
            $table->string('name');
            $table->integer('price');
            $table->text('des');
        });
    }
  • Вопрос задан
  • 86 просмотров
Решения вопроса 1
i229194964
@i229194964
Веб разработчик
public function up(): void
{
    Schema::create('products', function (Blueprint $table) {
        $table->id();
        $table->timestamps(); // Без аргументов

        $table->string('name');
        $table->integer('price');
        $table->text('des');
    });
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы