Completed
Pull Request — master (#287)
by Luc
04:52
created

SchemaConfigurator::configure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 42
rs 8.8571
cc 1
eloc 31
nc 1
nop 1
1
<?php
2
/**
3
 * @file
4
 */
5
6
namespace CultuurNet\UDB3\ReadModel\Index\Doctrine;
7
8
use CultuurNet\UDB3\Doctrine\DBAL\SchemaConfiguratorInterface;
9
use Doctrine\DBAL\Schema\AbstractSchemaManager;
10
use ValueObjects\StringLiteral\StringLiteral;
11
12
class SchemaConfigurator implements SchemaConfiguratorInterface
13
{
14
    /**
15
     * @var StringLiteral
16
     */
17
    protected $tableName;
18
19
    /**
20
     * @param StringLiteral $tableName
21
     */
22
    public function __construct(StringLiteral $tableName)
23
    {
24
        $this->tableName = $tableName;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function configure(AbstractSchemaManager $schemaManager)
31
    {
32
        $schema = $schemaManager->createSchema();
33
        $table = $schema->createTable($this->tableName->toNative());
34
35
        $table->addColumn(
36
            'entity_id',
37
            'guid',
38
            array('length' => 36, 'notnull' => true)
39
        );
40
        $table->addColumn(
41
            'entity_type',
42
            'string',
43
            array('length' => 36, 'notnull' => true)
44
        );
45
        $table->addColumn(
46
            'uid',
47
            'guid',
48
            array('length' => 36, 'notnull' => true)
49
        );
50
        $table->addColumn(
51
            'created',
52
            'text',
53
            array('length' => 36, 'notnull' => true)
54
        );
55
        $table->addColumn(
56
            'updated',
57
            'text',
58
            array('length' => 36, 'notnull' => true)
59
        );
60
        $table->addColumn(
61
            'owning_domain',
62
            'text',
63
            array('length' => 36, 'notnull' => true)
64
        );
65
        $table->addColumn(
66
            'entity_iri',
67
            'text'
68
        );
69
70
        $schemaManager->createTable($table);
71
    }
72
}
73