【发布时间】:2020-02-17 19:23:52
【问题描述】:
我正在尝试迁移一个迁移文件中的特定行。
示例:
之前:
Schema::create('categories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('category_name');
$table->integer('parent_id')->nullable();
$table->timestamps();
});
之后:
Schema::create('categories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('category_name');
$table->string('img_url'); // ← new column
$table->integer('parent_id')->nullable();
$table->timestamps();
});
现在我只想迁移线路:$table->string('img_url');
有可能吗?
【问题讨论】:
-
这样不行。如果要向现有表添加列,请创建新迁移并使用
Schema::table()而不是Schema::create(),然后再次运行php artisan migrate。
标签: php laravel migration schema