1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tarantool\Mapper\Migrations; |
4
|
|
|
|
5
|
|
|
use Tarantool\Mapper\Contracts; |
6
|
|
|
|
7
|
|
|
class Bootstrap implements Contracts\Migration |
8
|
|
|
{ |
9
|
64 |
|
public function migrate(Contracts\Manager $manager) |
10
|
|
|
{ |
11
|
64 |
|
$client = $manager->getClient(); |
|
|
|
|
12
|
64 |
|
if ($manager->getSchema()->hasSpace('sequence')) { |
13
|
|
|
return true; |
14
|
|
|
} |
15
|
|
|
|
16
|
64 |
|
$schema = $manager->getSchema(); |
17
|
|
|
|
18
|
64 |
|
$schema->createSpace('sequence'); |
19
|
64 |
|
$schema->createIndex('sequence', 'id', ['parts' => [1, 'UNSIGNED']]); |
20
|
|
|
$schema->createIndex('sequence', 'space', ['parts' => [2, 'UNSIGNED']]); |
21
|
|
|
|
22
|
|
|
$schema->createSpace('property'); |
23
|
|
|
$schema->createIndex('property', 'id', ['parts' => [1, 'UNSIGNED']]); |
24
|
|
|
$schema->createIndex('property', 'space', ['parts' => [2, 'UNSIGNED'], 'unique' => false]); |
25
|
|
|
$schema->createIndex('property', 'index_space', ['parts' => [3, 'UNSIGNED', 2, 'UNSIGNED']]); |
26
|
|
|
$schema->createIndex('property', 'type', ['parts' => [5, 'STR'], 'unique' => false]); |
27
|
|
|
|
28
|
|
|
$client = $manager->getClient(); |
29
|
|
|
|
30
|
|
|
$sequenceSpaceId = $schema->getSpaceId('sequence'); |
31
|
|
|
$propertySpaceId = $schema->getSpaceId('property'); |
32
|
|
|
|
33
|
|
|
$property = $client->getSpace('property'); |
34
|
|
|
$property->insert([1, $sequenceSpaceId, 0, 'id', 'integer']); |
35
|
|
|
$property->insert([2, $sequenceSpaceId, 1, 'space', 'integer']); |
36
|
|
|
$property->insert([3, $sequenceSpaceId, 2, 'value', 'integer']); |
37
|
|
|
$property->insert([4, $propertySpaceId, 0, 'id', 'integer']); |
38
|
|
|
$property->insert([5, $propertySpaceId, 1, 'space', 'integer']); |
39
|
|
|
$property->insert([6, $propertySpaceId, 2, 'index', 'integer']); |
40
|
|
|
$property->insert([7, $propertySpaceId, 3, 'name', 'string']); |
41
|
|
|
$property->insert([8, $propertySpaceId, 4, 'type', 'string']); |
42
|
|
|
|
43
|
|
|
$sequence = $client->getSpace('sequence'); |
44
|
|
|
$sequence->insert([1, $sequenceSpaceId, 2]); |
45
|
|
|
$sequence->insert([2, $propertySpaceId, 8]); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.