簡體   English   中英

Laravel更新列鍵

[英]Laravel update column key

我正在嘗試通過遷移從complaint_number列表中刪除唯一鍵,因為我的應用程序正在生產中,無法解決...。

這就是我現在所擁有的:

public function up()
    {
        Schema::create('complaints', function(Blueprint $table)
        {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('complaint_number', 7)->unique();
            $table->string('address');
            $table->timestamps();
        });
    }

我假設遷移已經運行,所以您需要做的是創建一個新遷移,然后在其中刪除唯一索引。

php artisan migrate:make drop_complaint_number_unique_index

而對於up方法:

Schema::table('complaint', function(Blueprint $table) {
    $table->dropIndex('complaints_complaint_number_unique');
}

這是down方法(重新添加唯一索引):

Schema::table('complaint', function(Blueprint $table) {
    $table->unique(['complaint_number']);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM