Laravel 从迁移中迁移特定文件 [英] Laravel Migrate Specific File(s) from Migrations

查看:27
本文介绍了Laravel 从迁移中迁移特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,请阅读 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 文件夹后,新创建的 migrationtest 文件夹中移动/复制并运行在您的 终端/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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆