如何从 Laravel 中的现有模型或现有迁移模型创建迁移文件?
最佳答案
要为现有模型创建表,您只需运行以下命令,
php artisan make:migration table_name
然后,转到
database -> migration -> date_with-table_name
内
up()
, 键入您要添加的表名和字段,如下所示;Schema::create('table_name', function (Blueprint $table) {
$table->increments('id');
$table->string('field_2');
$table->string('field_3');
$table->string('field_4');
$table->date('field_5');
$table->string('field_6');
$table->timestamps();
});
read more here.
关于Laravel 从现有模型生成迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47649813/