CreateInventoryStockMovementsTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 17
rs 9.8666
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 CreateInventoryStockMovementsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('inventory_stock_movements', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->unsignedBigInteger('stock_id');
19
            $table->integer('before')->default(0);
20
            $table->integer('after')->default(0);
21
            $table->decimal('cost', 8, 2)->default(0)->nullable();
22
            $table->string('reason')->nullable();
23
24
            
25
            $table->timestamps();
26
27
            $table->foreign('stock_id')
28
                ->references('id')
29
                ->on('inventory_stocks')
30
                ->onDelete('cascade');
31
        });
32
    }
33
34
    /**
35
     * Reverse the migrations.
36
     *
37
     * @return void
38
     */
39
    public function down()
40
    {
41
        Schema::dropIfExists('inventory_stock_movements');
42
    }
43
}
44