Skip to content

Commit

Permalink
- removed unique index on Customer primary/shipping address as it is …
Browse files Browse the repository at this point in the history
…a theoretical posibility that they are exactly the same address
  • Loading branch information
24198 committed Jul 6, 2020
1 parent 584f866 commit 3cc166c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MarelloCustomerBundleInstaller implements
*/
public function getMigrationVersion()
{
return 'v1_4';
return 'v1_4_1';
}

/**
Expand Down Expand Up @@ -106,8 +106,6 @@ protected function createMarelloCustomerTable(Schema $schema)
$table->addColumn('tax_identification_number', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('company_id', 'integer', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['primary_address_id'], 'UNIQ_75C456C9F5B7AF75');
$table->addUniqueIndex(['shipping_address_id'], 'UNIQ_75C456C94D4CFF2B');
$table->addIndex(['organization_id']);

$this->attachmentExtension->addAttachmentAssociation($schema, $table->getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Marello\Bundle\CustomerBundle\Migrations\Schema\v1_4_1;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension;
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface;

use Marello\Bundle\CustomerBundle\Migrations\Schema\MarelloCustomerBundleInstaller;

class MarelloCustomerBundle implements Migration
{
/**
* @inheritDoc
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable(MarelloCustomerBundleInstaller::MARELLO_CUSTOMER_TABLE);
// drop unique indexes for customer primary and shipping address
if ($table->hasIndex('UNIQ_75C456C9F5B7AF75')) {
$table->dropIndex('UNIQ_75C456C9F5B7AF75');
}

if ($table->hasIndex('UNIQ_75C456C94D4CFF2B')) {
$table->dropIndex('UNIQ_75C456C94D4CFF2B');
}

if ($table->hasForeignKey('FK_AD0CE5A24D4CFF2B')) {
$table->removeForeignKey('FK_AD0CE5A24D4CFF2B');
$table->addForeignKeyConstraint(
$schema->getTable('marello_address'),
['shipping_address_id'],
['id'],
['onDelete' => null, 'onUpdate' => null]
);
}
if ($table->hasForeignKey('FK_AD0CE5A2CB134313')) {
$table->removeForeignKey('FK_AD0CE5A2CB134313');
$table->addForeignKeyConstraint(
$schema->getTable('marello_address'),
['primary_address_id'],
['id'],
['onDelete' => null, 'onUpdate' => null]
);
}
}
}

0 comments on commit 3cc166c

Please sign in to comment.