skip to Main Content

laravel 10 showing error Excetption IlluminateDatabaseQueryException

Respected all,

I am using the laravel 10 and i am doing to add a new coloum in the table students using these stedps in terminal command use

Step 1:- php artisan make:migration update_student_table –table=students

Step 2:- in the 2023_08_17_055949_update_student_table.php file add the code

https://prnt.sc/fdGTj1t_3iIJ

Step 3:- php artisan migrate run this command

Step 4:- in the terminal having the Error.

enter image description here

I try to add the new colum in the table but showing the error

excetion

enter image description here

2

Answers


  1. Use below code

    Schema::table('students', function (Blueprint $table) {
        $table->string('city', 30)->after('id'); // change after column
    });
    
    Login or Signup to reply.
  2. If you look at your 2nd image, when you ran

    php artisan migrate
    

    Then create_students_table migration ran first as the students’ table already exists which throws an exception.

    This happens if somehow create_student_table didn’t ran before or entry is deleted from migrations table of your database.

    Alternatively for specific migration you can try.

    php artisan migrate --path=/database/migrations/your_table.
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search