【问题标题】:how to add a new column between 2 columns in laravel如何在laravel的2列之间添加一个新列
【发布时间】:2019-03-13 05:37:15
【问题描述】:

迁移文件

 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();
        });
    }

隐藏栏后我想添加“隐私栏”

【问题讨论】:

标签: laravel phpmyadmin postman database-migration


【解决方案1】:

要么将其添加到迁移文件中,要么像这样创建另一个迁移:

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

【讨论】:

    猜你喜欢
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2018-06-28
    • 1970-01-01
    相关资源
    最近更新 更多