Skip to content

Commit 84f640e

Browse files
vsorokayurio
authored andcommitted
BAP-13382: Unpredictable data sorting on Calls grid (#6791)
- Fix issues in ORDER BY modification and move it to AST walker - Fix indexes (add ID to the end)
1 parent 08e57aa commit 84f640e

File tree

22 files changed

+207
-31
lines changed

22 files changed

+207
-31
lines changed

src/OroCRM/Bundle/AccountBundle/Entity/Account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* @ORM\Entity()
24-
* @ORM\Table(name="orocrm_account", indexes={@ORM\Index(name="account_name_idx", columns={"name"})})
24+
* @ORM\Table(name="orocrm_account", indexes={@ORM\Index(name="account_name_idx", columns={"name", "id"})})
2525
* @ORM\HasLifecycleCallbacks()
2626
* @Oro\Loggable
2727
* @Config(

src/OroCRM/Bundle/AccountBundle/Migrations/Schema/OroCRMAccountBundleInstaller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function setAttachmentExtension(AttachmentExtension $attachmentExtension)
8080
*/
8181
public function getMigrationVersion()
8282
{
83-
return 'v1_11';
83+
return 'v1_11_1';
8484
}
8585

8686
/**
@@ -157,7 +157,7 @@ protected function createOrocrmAccountTable(Schema $schema, QueryBag $queries)
157157
$table->addIndex(['user_owner_id'], 'IDX_7166D3719EB185F9', []);
158158
$table->addIndex(['organization_id'], 'IDX_7166D37132C8A3DE', []);
159159
$table->addIndex(['default_contact_id'], 'IDX_7166D371AF827129', []);
160-
$table->addIndex(['name'], 'account_name_idx', []);
160+
$table->addIndex(['name', 'id'], 'account_name_idx', []);
161161

162162
$queries->addPostQuery(new AccountNameExprIndexQuery());
163163
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace OroCRM\Bundle\AccountBundle\Migrations\Schema\v1_11_1;
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_account');
18+
$indexName = 'account_name_idx';
19+
$indexColumns = ['name', 'id'];
20+
if ($table->hasIndex($indexName) && $table->getIndex($indexName)->getColumns() !== $indexColumns) {
21+
$table->dropIndex($indexName);
22+
$table->addIndex($indexColumns, $indexName);
23+
}
24+
}
25+
}

src/OroCRM/Bundle/CaseBundle/Entity/CaseEntity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
/**
2121
* @ORM\Entity
2222
* @ORM\Table(
23-
* name="orocrm_case"
23+
* name="orocrm_case",
24+
* indexes={@ORM\Index(name="case_reported_at_idx",columns={"reportedAt", "id"})}
2425
* )
2526
* @ORM\HasLifecycleCallbacks()
2627
* @Oro\Loggable

src/OroCRM/Bundle/CaseBundle/Migrations/Schema/OroCRMCaseBundleInstaller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class OroCRMCaseBundleInstaller implements
4242
*/
4343
public function getMigrationVersion()
4444
{
45-
return 'v1_9';
45+
return 'v1_10';
4646
}
4747

4848
/**
@@ -138,6 +138,7 @@ protected function createOrocrmCaseTable(Schema $schema)
138138
$table->addIndex(['related_account_id'], 'IDX_AB3BAC1E11A6570A', []);
139139
$table->addIndex(['source_name'], 'IDX_AB3BAC1E5FA9FB05', []);
140140
$table->addIndex(['priority_name'], 'IDX_AB3BAC1E965BD3DF', []);
141+
$table->addIndex(['reportedAt', 'id'], 'case_reported_at_idx', []);
141142
}
142143

143144
/**
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace OroCRM\Bundle\CaseBundle\Migrations\Schema\v1_10;
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_case');
18+
$indexName = 'case_reported_at_idx';
19+
$indexColumns = ['reportedAt', 'id'];
20+
if ($table->hasIndex($indexName)) {
21+
if ($table->getIndex($indexName)->getColumns() !== $indexColumns) {
22+
$table->dropIndex($indexName);
23+
$table->addIndex($indexColumns, $indexName);
24+
}
25+
} else {
26+
$table->addIndex($indexColumns, $indexName);
27+
}
28+
}
29+
}

src/OroCRM/Bundle/ContactBundle/Entity/Contact.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @ORM\Table(
3434
* name="orocrm_contact",
3535
* indexes={
36-
* @ORM\Index(name="contact_name_idx",columns={"last_name", "first_name"}),
36+
* @ORM\Index(name="contact_name_idx",columns={"last_name", "first_name", "id"}),
3737
* @ORM\Index(name="contact_updated_at_idx",columns={"updatedAt"}),
3838
* }
3939
* )

src/OroCRM/Bundle/ContactBundle/Migrations/Schema/OroCRMContactBundleInstaller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function setAttachmentExtension(AttachmentExtension $attachmentExtension)
7373
*/
7474
public function getMigrationVersion()
7575
{
76-
return 'v1_14';
76+
return 'v1_15';
7777
}
7878

7979
/**
@@ -151,7 +151,7 @@ protected function createOrocrmContactTable(Schema $schema)
151151
$table->addIndex(['reports_to_contact_id'], 'IDX_403263EDF27EBC1E', []);
152152
$table->addIndex(['created_by_user_id'], 'IDX_403263ED7D182D95', []);
153153
$table->addIndex(['updated_by_user_id'], 'IDX_403263ED2793CC5E', []);
154-
$table->addIndex(['last_name', 'first_name'], 'contact_name_idx', []);
154+
$table->addIndex(['last_name', 'first_name', 'id'], 'contact_name_idx', []);
155155
$table->addIndex(['updatedAt'], 'contact_updated_at_idx', []);
156156
}
157157

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace OroCRM\Bundle\ContactBundle\Migrations\Schema\v1_15;
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_contact');
18+
$indexName = 'contact_name_idx';
19+
$indexColumns = ['last_name', 'first_name', 'id'];
20+
if ($table->hasIndex($indexName) && $table->getIndex($indexName)->getColumns() !== $indexColumns) {
21+
$table->dropIndex($indexName);
22+
$table->addIndex($indexColumns, $indexName);
23+
}
24+
}
25+
}

src/OroCRM/Bundle/ContactUsBundle/Entity/ContactRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @ORM\Entity
2323
* @ORM\Table(
2424
* name="orocrm_contactus_request",
25-
* indexes={@ORM\Index(name="request_create_idx",columns={"created_at"})}
25+
* indexes={@ORM\Index(name="request_create_idx",columns={"created_at", "id"})}
2626
* )
2727
*
2828
* @Config(

0 commit comments

Comments
 (0)