Passed
Push — master ( 87ec12...ed978d )
by Aleksandr
14:32
created

AttributePropMigration::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Database\Migrations;
11
12
use Doctrine\DBAL\Schema\Schema;
13
use Doctrine\DBAL\Types\Types;
14
use Doctrine\Migrations\AbstractMigration;
15
use Drobotik\Eav\Enum\_ATTR_PROP;
16
17
final class AttributePropMigration extends AbstractMigration
18
{
19
    public function getDescription(): string
20
    {
21
        return 'Attribute properties table';
22
    }
23
24
    public function up(Schema $schema): void
25
    {
26
        $table = $schema->createTable(_ATTR_PROP::table());
27
        $table->addColumn(_ATTR_PROP::KEY->column(), Types::INTEGER , ['Autoincrement' => true, 'unsigned' => true]);
28
        $table->addColumn(_ATTR_PROP::ATTRIBUTE_KEY->column(), Types::INTEGER);
29
        $table->addColumn(_ATTR_PROP::NAME->column(), Types::STRING);
30
        $table->addColumn(_ATTR_PROP::VALUE->column(), Types::STRING);
31
        $table->setPrimaryKey([_ATTR_PROP::KEY->column()]);
32
        $table->addIndex([_ATTR_PROP::ATTRIBUTE_KEY->column()]);
33
    }
34
35
    public function down(Schema $schema): void
36
    {
37
        $schema->dropTable(_ATTR_PROP::table());
38
    }
39
}
40