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
|
52 |
|
public function migrate(Mapper $mapper) |
14
|
|
|
{ |
15
|
52 |
|
$mapper->getSchema() |
16
|
52 |
|
->createSpace('job_context') |
17
|
52 |
|
->addProperty('id', 'integer') |
18
|
52 |
|
->addProperty('hash', 'string') |
19
|
52 |
|
->addProperty('context', '*') |
20
|
52 |
|
->addIndex(['id']) |
21
|
52 |
|
->addIndex(['hash']); |
22
|
|
|
|
23
|
52 |
|
$mapper->getSchema() |
24
|
52 |
|
->createSpace('job_queue') |
25
|
52 |
|
->addProperty('id', 'integer') |
26
|
52 |
|
->addProperty('status', 'string') |
27
|
52 |
|
->addProperty('hash', 'string') |
28
|
52 |
|
->addProperty('context', 'integer', [ 'is_nullable' => false ]) |
29
|
52 |
|
->addProperty('service', 'string', [ 'is_nullable' => false ]) |
30
|
52 |
|
->addProperty('job', 'string', [ 'is_nullable' => false ]) |
31
|
52 |
|
->addProperty('params', '*', [ 'is_nullable' => false ]) |
32
|
52 |
|
->addProperty('recipient', 'string', [ 'is_nullable' => true ]) |
33
|
52 |
|
->addIndex(['id']) |
34
|
52 |
|
->addIndex(['hash', 'status']) |
35
|
52 |
|
->addIndex(['status', 'id']); |
36
|
|
|
|
37
|
52 |
|
$mapper->getSchema() |
38
|
52 |
|
->createSpace('job_result') |
39
|
52 |
|
->addProperty('id', 'integer') |
40
|
52 |
|
->addProperty('service', 'string') |
41
|
52 |
|
->addProperty('hash', 'string') |
42
|
52 |
|
->addProperty('data', 'map', [ 'is_nullable' => false ]) |
43
|
52 |
|
->addProperty('expire', 'integer') |
44
|
52 |
|
->addIndex(['id']) |
45
|
52 |
|
->addIndex(['service', 'hash']) |
46
|
52 |
|
->addIndex(['expire', 'id']); |
47
|
|
|
|
48
|
52 |
|
$sequence = $mapper->getPlugin(Sequence::class); |
49
|
52 |
|
$schema = $mapper->getSchema(); |
50
|
52 |
|
$sequence->initializeSequence($schema->getSpace('job_queue')); |
51
|
52 |
|
$sequence->initializeSequence($schema->getSpace('job_result')); |
52
|
52 |
|
} |
53
|
|
|
} |
54
|
|
|
|