CreateMetaAttributesTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 17 1
A down() 0 4 1
1
<?php
2
3
namespace Sofa\Eloquence\Metable;
4
5
use Illuminate\Database\Schema\Blueprint;
6
use Illuminate\Database\Migrations\Migration;
7
8
/**
9
 * @codeCoverageIgnore
10
 */
11
class CreateMetaAttributesTable extends Migration
12
{
13
    /**
14
     * Meta attributes table name.
15
     *
16
     * @todo allow table name customization via config
17
     *
18
     * @var string
19
     */
20
    protected $table = 'meta_attributes';
21
22
    /**
23
     * Run the migrations.
24
     *
25
     * @return void
26
     */
27
    public function up()
28
    {
29
        \Schema::create($this->table, function (Blueprint $table) {
30
            $table->increments('meta_id');
31
            $table->string('meta_key');
32
            $table->longText('meta_value');
33
            $table->string('meta_type')->default('string');
34
            $table->morphs('metable');
35
36
            $table->index('meta_key');
37
        });
38
        
39
        // Laravel doesn't handle index length, so we need raw statement for this one
40
        \Schema::getConnection()->statement(
41
            'create index meta_attributes_index_value on  (meta_key, meta_value(20))'
42
        );
43
    }
44
45
    /**
46
     * Reverse the migrations.
47
     *
48
     * @return void
49
     */
50
    public function down()
51
    {
52
        \Schema::drop($this->table);
53
    }
54
}
55