CreateEventStoreTable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A up() 0 15 1
A down() 0 4 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Support\Facades\Schema;
7
8
class CreateEventStoreTable extends Migration
9
{
10
    /**
11
     * @var string
12
     */
13
    private $eventStoreTableName;
14
15
    private $eventStoreConnection;
16
17
    public function __construct()
18
    {
19
        $this->eventStoreTableName = Config::get('broadway.event-store-table', 'event_store');
20
        $this->eventStoreConnection = Config::get('broadway.event-store.connection', 'default');
21
22
        if ($this->eventStoreConnection === 'default') {
23
            $this->eventStoreConnection = null;
24
        }
25
    }
26
27
    public function up()
28
    {
29
        Schema::connection($this->eventStoreConnection)->create($this->eventStoreTableName, function (Blueprint $table) {
30
            $table->increments('id');
31
32
            $table->char('uuid', 36);
33
            $table->integer('playhead')->unsigned();
34
            $table->text('metadata');
35
            $table->text('payload');
36
            $table->string('recorded_on', 32);
37
            $table->text('type');
38
39
            $table->unique(['uuid', 'playhead']);
40
        });
41
    }
42
43
    public function down()
44
    {
45
        Schema::drop($this->eventStoreTableName);
46
    }
47
}
48