如何在 laravel 中的第一列之前添加新列?

How to add new column before first column in laravel?

我需要首​​先使用 laravel 迁移在 Sql 中添加一列。我可以使用 after:

在任何地方添加新列
  Schema::table('tasks', function (Blueprint $table) {
        if (Schema::hasColumn('tasks', 'assigned_to_id') == false) {
                $table->integer('assigned_to_id')->after('status');
        }
  });

Table 有以下字段: project_id , module_id

我需要在 project_id 之前添加列 'id'。 如何做到这一点? 提前致谢!

您可以使用 $table->integer('id')->first() 添加 id 作为第一列