Эх сурвалжийг харах

为Orders表的code字段添加唯一约束

ajun 5 жил өмнө
parent
commit
4b5060fa3c

+ 32 - 0
database/migrations/2021_01_20_165051_add_orders_unique_to_column_code.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddOrdersUniqueToColumnCode extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->unique('code','order_code_unique');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->dropUnique('order_code_unique');
+        });
+    }
+}