瀏覽代碼

增加联合唯一索引

Zhouzhendong 4 年之前
父節點
當前提交
b71f5fd91a
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      database/migrations/2021_06_02_114506_change_storages_table.php

+ 2 - 1
database/migrations/2021_06_02_114506_change_storages_table.php

@@ -16,12 +16,13 @@ class ChangeStoragesTable extends Migration
         Schema::dropIfExists('storages');
         Schema::create('storages', function (Blueprint $table) {
             $table->id();
-            $table->bigInteger("station_id")->index()->comment("外键库位");
+            $table->bigInteger("station_id")->index()->nullable()->comment("外键库位");
             $table->bigInteger("material_box_id")->nullable()->index()->comment("外键料箱");
             $table->bigInteger("commodity_id")->nullable()->index()->comment("外键商品");
             $table->integer("amount")->default(0)->comment("数量");
             $table->tinyInteger("status")->default(0)->comment("状态");
             $table->timestamps();
+            $table->unique(["station_id","material_box_id","commodity_id"]);
         });
     }