Skip to content

Commit

Permalink
BAP-14388: Add complex index to data audit table (#9103)
Browse files Browse the repository at this point in the history
  • Loading branch information
x86demon authored and bemzaslava committed Mar 29, 2017
1 parent 4730cbf commit 3ca299d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Oro/Bundle/DataAuditBundle/Entity/AbstractAudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* indexes={
* @ORM\Index(name="idx_oro_audit_logged_at", columns={"logged_at"}),
* @ORM\Index(name="idx_oro_audit_type", columns={"type"}),
* @ORM\Index(name="idx_oro_audit_object_class", columns={"object_class"})
* @ORM\Index(name="idx_oro_audit_object_class", columns={"object_class"}),
* @ORM\Index(name="idx_oro_audit_obj_by_type", columns={"object_id", "object_class", "type"})
* },
* uniqueConstraints={
* @ORM\UniqueConstraint(name="idx_oro_audit_version", columns={"object_id", "object_class", "version"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OroDataAuditBundleInstaller implements Installation
*/
public function getMigrationVersion()
{
return 'v2_0';
return 'v2_0_1';
}

/**
Expand Down Expand Up @@ -62,6 +62,7 @@ private function createAudit(Schema $schema)

$auditTable->addIndex(['logged_at'], 'idx_oro_audit_logged_at', []);
$auditTable->addIndex(['object_class'], 'idx_oro_audit_object_class', []);
$auditTable->addIndex(['object_id', 'object_class', 'type'], 'idx_oro_audit_obj_by_type', []);

$auditTable->addIndex(['organization_id'], 'idx_oro_audit_organization_id', []);
$auditTable->addForeignKeyConstraint(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Oro\Bundle\DataAuditBundle\Migrations\Schema\v2_0_1;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AddIndexToDataAudit implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('oro_audit');
if (!$table->hasIndex('idx_oro_audit_obj_by_type')) {
$table->addIndex(['object_id', 'object_class', 'type'], 'idx_oro_audit_obj_by_type', []);
}
}
}

0 comments on commit 3ca299d

Please sign in to comment.