Can’t do PHP Artisan Migrate with SQLSTATE [42000]

  laravel, laravel-8, migration, php

I just want to PHP Artisan Migrate, I’m just completed my table on migration but have error

Migrating: 2021_09_15_021011_create_dso

   IlluminateDatabaseQueryException

  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 'created_date) null, `updated_at` timestamp(created_date) null, `modified_by` ...' at line 1 (SQL: create table `dso` (`id` int unsigned not null auto_increment primary key, `id_dso` bigint unsigned not null auto_increment primary key, `id_rso` bigint unsigned not null auto_increment primary key, `id_focus` bigint unsigned not null auto_increment primary key, `id_wilayah` bigint unsigned not null auto_increment primary key, `id_grup_wilayah` bigint unsigned not null auto_increment primary key, `nama_dso` varchar(255) not null, `created_by` varchar(255) not null, `created_at` timestamp(created_date) null, `updated_at` timestamp(created_date) null, `modified_by` varchar(255) not null, `created_at` timestamp(modified_date) null, `updated_at` timestamp(modified_date) null, `status` tinyint(1) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at D:XAMPPhtdocslaravel_salesvendorlaravelframeworksrcIlluminateDatabaseConnection.php:692
    688▕         // If an exception occurs when attempting to run a query, we'll format the error
    689▕         // message to include the bindings with SQL, which will make this exception a
    690▕         // lot more helpful to the developer instead of just the database's errors.
    691▕         catch (Exception $e) {
  ➜ 692▕             throw new QueryException(
    693▕                 $query, $this->prepareBindings($bindings), $e
    694▕             );
    695▕         }
    696▕     }

I’m check my completion there is no error or any miss spelling

public function up()
{
    Schema::create('dso', function (Blueprint $table) {
        $table->increments('id');
        $table->bigIncrements('id_dso')->unique();
        $table->id('id_rso');
        $table->id('id_focus');
        $table->id('id_wilayah');
        $table->id('id_grup_wilayah');
        $table->string('nama_dso');
        $table->string('created_by');
        $table->timestamps('created_date',$precision = 0);
        $table->string('modified_by');
        $table->timestamps('modified_date',$precision = 0);
        $table->boolean('status');
        $table->timestamps();
    });
}

I’m not add nullable because all column have to fill
I’m using laravel 8.6 and on windows with XAMPP and mariaDB

Source: Laravel

Leave a Reply