Home > other >  Laravel Migration Failed After The First File/Run(except file for creating users and password_reset
Laravel Migration Failed After The First File/Run(except file for creating users and password_reset

Time:07-25

I tried making database using Laravel Migration, it works only in first file and run... after that, I don't know what it caused to fail. I made date, head, and many more for the database, date successfully implemented but head fail even after I remove date migration file and using limiter on interger didn't give any effect. Error Screenshot

enter image description here

.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mono
DB_USERNAME=root
DB_PASSWORD=

Localhost

enter image description here

create_head_table.php

   <?php
    
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;
    
    class CreateHeadTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('head', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('head', 50);
                $table->interger('tgl', 50);
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::dropIfExists('head');
        }
    }

CodePudding user response:

You have an spelling mistake in here $table->interger('tgl', 50);. It will be integer not interger.

CodePudding user response:

Pay attention to your "create_head_table.php" migration file. As of your image the error occurs on line 19 and so why? In the up function:

public function up()
{
    Schema::create('head', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('head', 50);
        $table->interger('tgl', 50);//$table->integer('tgl'); or $table->string('tgl', 50);
    });
}

Is the last field of table integer or string? If it is string so plz correct it but if it is integer your syntax is wrong. The second parameter in integer is autoincrement not length!!

Refer Here for more information.

  • Related