如何在laravel的2列之间添加新列

时间:2018-10-08 14:08:48

标签: laravel phpmyadmin postman database-migration

  

迁移文件

 public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->longText('content');
            $table->string('short_description');
            $table->unsignedInteger('media_id')->nullable();
            $table->foreign('media_id')->references('id')->on('medias');
            $table->unsignedInteger('creator_id');
            $table->foreign('creator_id')->references('id')->on('users');
            $table->boolean('hide')->default(0);
            $table->timestamps();
        });
    }
  

在隐藏列之后,我想添加“隐私列”

1 个答案:

答案 0 :(得分:2)

要么将其添加到迁移文件中,要么创建另一个迁移,如下所示:

 Schema::table('posts', function (Blueprint $table) {
       $table->string('privacy')->after('hide');
    });