JobQueue   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 45
ccs 36
cts 36
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A migrate() 0 40 1
1
<?php
2
3
namespace Basis\Migration;
4
5
use Tarantool\Mapper\Migration;
6
use Tarantool\Mapper\Mapper;
7
use Tarantool\Mapper\Plugin\Sequence;
8
9
class JobQueue implements Migration
10
{
11
    public $created_at = '2019-12-13 19:26:34';
12
13 56
    public function migrate(Mapper $mapper)
14
    {
15 56
        $mapper->getSchema()
16 56
            ->createSpace('job_context')
17 56
            ->addProperty('id', 'integer')
18 56
            ->addProperty('hash', 'string')
19 56
            ->addProperty('context', '*')
20 56
            ->addIndex(['id'])
21 56
            ->addIndex(['hash']);
22
23 56
        $mapper->getSchema()
24 56
            ->createSpace('job_queue')
25 56
            ->addProperty('id', 'integer')
26 56
            ->addProperty('status', 'string')
27 56
            ->addProperty('hash', 'string')
28 56
            ->addProperty('context', 'integer', [ 'is_nullable' => false, 'reference' => 'job_context' ])
29 56
            ->addProperty('service', 'string', [ 'is_nullable' => false ])
30 56
            ->addProperty('job', 'string', [ 'is_nullable' => false ])
31 56
            ->addProperty('params', '*', [ 'is_nullable' => false ])
32 56
            ->addProperty('recipient', 'string', [ 'is_nullable' => true ])
33 56
            ->addIndex(['id'])
34 56
            ->addIndex(['hash', 'status', 'id'])
35 56
            ->addIndex(['status', 'id']);
36
37 56
        $mapper->getSchema()
38 56
            ->createSpace('job_result')
39 56
            ->addProperty('id', 'integer')
40 56
            ->addProperty('service', 'string')
41 56
            ->addProperty('hash', 'string')
42 56
            ->addProperty('data', 'map', [ 'is_nullable' => false ])
43 56
            ->addProperty('expire', 'integer')
44 56
            ->addIndex(['id'])
45 56
            ->addIndex(['service', 'hash'])
46 56
            ->addIndex(['expire', 'id']);
47
48 56
        $sequence = $mapper->getPlugin(Sequence::class);
49 56
        $schema = $mapper->getSchema();
50 56
        $sequence->initializeSequence($schema->getSpace('job_queue'));
51 56
        $sequence->initializeSequence($schema->getSpace('job_result'));
52 56
    }
53
}
54