【发布时间】:2019-11-09 09:51:57
【问题描述】:
我首先需要使用 laravel 迁移在 Sql 中添加一列。我可以在任何地方使用 after 添加新列:
Schema::table('tasks', function (Blueprint $table) {
if (Schema::hasColumn('tasks', 'assigned_to_id') == false) {
$table->integer('assigned_to_id')->after('status');
}
});
表格有以下字段: project_id , module_id
我需要在 project_id 之前添加列“id”。 如何做到这一点? 提前致谢!
【问题讨论】:
-
你能试试看使用after() 2 次是否有效?
标签: php laravel laravel-migrations