Completed
Push — 1.10 ( 3f8f95...f007bc )
by
unknown
09:16
created

UpdateIndexes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A up() 0 18 3
1
<?php
2
3
namespace OroCRM\Bundle\SalesBundle\Migrations\Schema\v1_25_8;
4
5
use Doctrine\DBAL\Schema\Schema;
6
7
use Oro\Bundle\MigrationBundle\Migration\Migration;
8
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
9
10
class UpdateIndexes implements Migration
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function up(Schema $schema, QueryBag $queries)
16
    {
17
        $table = $schema->getTable('orocrm_sales_opportunity');
18
        $indexName    = 'opportunities_by_status_idx';
19
        $indexColumns = [
20
            'organization_id',
21
            'status_id',
22
            'close_revenue',
23
            'budget_amount',
24
            'created_at'
25
        ];
26
        if ($table->hasIndex($indexName) && $table->getIndex($indexName)->getColumns() !== $indexColumns) {
27
            $table->dropIndex($indexName);
28
            $table->addIndex($indexColumns, $indexName);
29
        } else {
30
            $table->addIndex($indexColumns, $indexName);
31
        }
32
    }
33
}
34