CreateSofaRevisionsTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A up() 0 18 1
A down() 0 4 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class CreateSofaRevisionsTable extends Migration
7
{
8
    /**
9
     * Revisions table.
10
     *
11
     * @var string
12
     */
13
    protected $table;
14
15
    public function __construct()
16
    {
17
        $this->table = Config::get('sofa_revisionable.table', 'revisions');
18
    }
19
20
    /**
21
     * Run the migrations.
22
     *
23
     * @return void
24
     */
25
    public function up()
26
    {
27
        Schema::create($this->table, function (Blueprint $table) {
28
            $table->increments('id');
29
            $table->string('action', 255);
30
            $table->string('table_name', 255);
31
            $table->integer('row_id')->unsigned();
32
            $table->binary('old')->nullable();
33
            $table->binary('new')->nullable();
34
            $table->string('user', 255)->nullable();
35
            $table->string('ip')->nullable();
36
            $table->string('ip_forwarded')->nullable();
37
            $table->timestamp('created_at');
38
39
            $table->index('action');
40
            $table->index(['table_name', 'row_id']);
41
        });
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