Code Duplication    Length = 37-37 lines in 2 locations

src/OroCRM/Bundle/AccountBundle/Migrations/Schema/v1_11/AccountNameExprIndexQuery.php 1 location

@@ 12-48 (lines=37) @@
9
use Oro\Bundle\MigrationBundle\Migration\ArrayLogger;
10
use Oro\Bundle\MigrationBundle\Migration\ParametrizedMigrationQuery;
11
12
class AccountNameExprIndexQuery extends ParametrizedMigrationQuery
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

src/OroCRM/Bundle/ChannelBundle/Migrations/Schema/v1_5/UpdateChannelJsonArrayQuery.php 1 location

@@ 12-48 (lines=37) @@
9
use Oro\Bundle\MigrationBundle\Migration\ArrayLogger;
10
use Oro\Bundle\MigrationBundle\Migration\ParametrizedMigrationQuery;
11
12
class UpdateChannelJsonArrayQuery extends ParametrizedMigrationQuery
13
{
14
    public function getDescription()
15
    {
16
        $logger = new ArrayLogger();
17
        $logger->info(
18
            'Convert a column with "json_array(text)" type to "json_array" type on PostgreSQL >= 9.2 and Doctrine 2.5'
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
            $updateSql = 'ALTER TABLE orocrm_channel ALTER COLUMN data TYPE JSON USING data::JSON';
41
42
            $this->logQuery($logger, $updateSql);
43
            if (!$dryRun) {
44
                $this->connection->executeUpdate($updateSql);
45
            }
46
        }
47
    }
48
}
49