1

I need to add a column at first in Sql using laravel migration. i can add new column at any place using after:

  Schema::table('tasks', function (Blueprint $table) {
        if (Schema::hasColumn('tasks', 'assigned_to_id') == false) {
                $table->integer('assigned_to_id')->after('status');
        }
  });

Table has following fields: project_id , module_id

I need to add column 'id' before project_id. How to achieve this? Thanks in advance!

Neha
  • 2,136
  • 5
  • 21
  • 50
  • Can you try and see if using [after()](https://laravel.com/docs/5.8/migrations) 2 times does the trick? – nice_dev Jun 27 '19 at 11:46

1 Answers1

5

You could use $table->integer('id')->first() to add id as the first column

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26