dpp66953 2014-11-27 17:49
浏览 119
已采纳

Laravel更新列密钥

I am trying to remove the unique key from complaint_number column with migration because my app is on production and can't figure it up....

this is what I have right now:

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();
        });
    }
  • 写回答

1条回答 默认 最新

  • dousou3027 2014-11-27 19:47
    关注

    I assume that migration have already been run, so what you need to do is to create a new migration and in that drop the unique index.

    php artisan migrate:make drop_complaint_number_unique_index
    

    And this for the up method:

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

    And this for the down method (re-add the unique index):

    Schema::table('complaint', function(Blueprint $table) {
        $table->unique(['complaint_number']);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误