CreateProductsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
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 CreateProductsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('products', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->unsignedBigInteger('category_id');
19
            $table->string('name');
20
            $table->string('slug')->unique();
21
            $table->mediumText('short_description')->nullable();
22
            $table->text('description')->nullable();
23
            $table->boolean('is_active');
24
            $table->timestamps();
25
26
            $table->foreign('category_id')
27
                    ->references('id')
28
                    ->on('product_categories')
29
                    ->onDelete('cascade');
30
        });
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     *
36
     * @return void
37
     */
38
    public function down()
39
    {
40
        Schema::dropIfExists('products');
41
    }
42
}
43