CreateInventoryStocksTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 24
rs 9.7
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateInventoryStocksTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('inventory_stocks', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->unsignedBigInteger('warehouse_id');
19
            $table->unsignedBigInteger('product_sku_id');
20
            $table->integer('quantity')->default(0);
21
22
            $table->string('aisle')->nullable();
23
            $table->string('row')->nullable();
24
25
            $table->timestamps();
26
27
            $table->foreign('product_sku_id')
28
                ->references('id')
29
                ->on('product_skus')
30
                ->onDelete('cascade');
31
32
            $table->foreign('warehouse_id')
33
                ->references('id')
34
                ->on('warehouses')
35
                ->onDelete('cascade');
36
37
            $table->unique(['product_sku_id', 'warehouse_id'], 'product_warehouse_key');
38
        });
39
    }
40
41
    /**
42
     * Reverse the migrations.
43
     *
44
     * @return void
45
     */
46
    public function down()
47
    {
48
        Schema::dropIfExists('inventory_stocks');
49
    }
50
}
51