DoctrineMigration::preDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Doctrine\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * This is the base class for all App Migrations.
12
 * It ensures that the Migrations are executed against the proper database and skipped for all others.
13
 */
14
abstract class DoctrineMigration extends AbstractMigration
15
{
16
    public function preUp(Schema $schema): void
17
    {
18
        $parameters = $this->connection->getParams();
19
        $this->skipIf($parameters['dbname'] != $this->getDbName(),
20
            "This is the other DB\'s migration, pass a correct --em parameter");
21
    }
22
23
    public function preDown(Schema $schema): void
24
    {
25
        $parameters = $this->connection->getParams();
26
        $this->skipIf($parameters['dbname'] != $this->getDbName(),
27
            "This is the other DB\'s migration, pass a correct --em parameter");
28
    }
29
30
    protected abstract function getDbName(): string;
31
}