Passed
Push — master ( fd21f2...66fc67 )
by Karel
08:29
created

AddCssJsColumnToPagesTable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 32
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 11 3
A down() 0 5 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class AddCssJsColumnToPagesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (! Schema::hasColumn('pages', 'css') ) {
17
            Schema::table('pages', function (Blueprint $table) {
18
                $table->longText('css')->nullable()->after('meta');
19
            });
20
        }
21
22
        if (! Schema::hasColumn('pages', 'js') ) {
23
            Schema::table('pages', function (Blueprint $table) {
24
                $table->longText('js')->nullable()->after('css');
25
            });
26
        }
27
    }
28
29
    /**
30
     * Reverse the migrations.
31
     *
32
     * @return void
33
     */
34
    public function down()
35
    {
36
        Schema::table('pages', function (Blueprint $table) {
37
            $table->dropColumn('js');
38
            $table->dropColumn('css');
39
        });
40
    }
41
}
42