Completed
Push — master ( cd8605...3b7290 )
by
unknown
09:46
created

AccountNameExprIndexQuery::doExecute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
1
<?php
2
3
namespace OroCRM\Bundle\AccountBundle\Migrations\Schema\v1_11;
4
5
use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
6
7
use Psr\Log\LoggerInterface;
8
9
use Oro\Bundle\MigrationBundle\Migration\ArrayLogger;
10
use Oro\Bundle\MigrationBundle\Migration\ParametrizedMigrationQuery;
11
12 View Code Duplication
class AccountNameExprIndexQuery extends ParametrizedMigrationQuery
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    public function getDescription()
15
    {
16
        $logger = new ArrayLogger();
17
        $logger->info(
18
            'Create additional expression index on PostgreSQL'
19
        );
20
        $this->doExecute($logger, true);
21
22
        return $logger->getMessages();
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function execute(LoggerInterface $logger)
29
    {
30
        $this->doExecute($logger);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function doExecute(LoggerInterface $logger, $dryRun = false)
37
    {
38
        $platform = $this->connection->getDatabasePlatform();
39
        if ($platform instanceof PostgreSQL92Platform) {
40
            $createIndex = 'CREATE INDEX account_name_expr_idx ON orocrm_account (lower(name))';
41
42
            $this->logQuery($logger, $createIndex);
43
            if (!$dryRun) {
44
                $this->connection->executeUpdate($createIndex);
45
            }
46
        }
47
    }
48
}
49