New field laravel existing table to add table fields

Copyright: the voice of experience, I do not know whether the change package spicy bar, and the other, please indicate the source. https://blog.csdn.net/zhezhebie/article/details/90676012

After we create the migration, find the need to add a few fields, the way official website is to add a package:
Doctrine / DBAL
official website Reference:
https://laravel.com/docs/5.5/migrations#modifying-columns

Here I found another way, but apply only to add fields.
** Schema :: create instead Schema :: table **, and then comment out the other already existing fields, as shown below, I only need to add remark_date field based on the original:

    public function up() {
        Schema::table('memoranda', function (Blueprint $table) {
            //$table->bigIncrements('id');
            //$table->unsignedInteger('user_id')->comment('用户ID');
            //$table->string('content', 255)->defalut('')->comment('备忘内容');
            $table->date('remark_date')->nullable()->comment('备忘时间');
            //$table->unsignedTinyInteger('status')->default(1)->comment('1正常,2禁用,3删除');
            //$table->timestamps();
        });
    }

After he put migrationsb table inside the migrate record deleted, or laravel will migrate discovery has been, it will not change.

php artisan migrate

It can be.

Note: This method is only suitable for new fields, modify, and delete is not enough.

Guess you like

Origin blog.csdn.net/zhezhebie/article/details/90676012