Laravel 从迁移中迁移特定文件 [英] Laravel Migrate Specific File(s) from Migrations
问题描述
您好,请阅读 https://laravel.com/docs/5.4/migrations<中包含的所有文档/a>.
Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations.
有没有办法迁移某个迁移文件(仅迁移 1 个),因为现在每次有更改时我都会使用 php artisan migrate:refresh
并且所有字段都被重置.
Is there a way on how to migrate a certain migration file (1 migration only), cause right now every time there is a change I use php artisan migrate:refresh
and all fields are getting reset.
推荐答案
首先你应该为你的表创建一个 migration
文件,例如:
First you should create one migration
file for your table like:
public function up()
{
Schema::create('test', function (Blueprint $table) {
$table->increments('id');
$table->string('fname',255);
$table->string('lname',255);
$table->rememberToken();
$table->timestamps();
});
}
在 migrations 文件夹中创建 test 文件夹后,新创建的 migration 在 test 文件夹中移动/复制并运行在您的 终端/cmd 中使用以下命令,例如:
After create test folder in migrations folder then newly created migration moved/copied in test folder and run below command in your terminal/cmd like:
php artisan migrate --path=/database/migrations/test/
这篇关于Laravel 从迁移中迁移特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!