Skip to content

Commit

Permalink
Merge branch 'bug/MAR10001-tax-unique-index-fix' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
24198 committed Apr 26, 2018
2 parents eb27215 + 3219402 commit 4d4dde3
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Marello/Bundle/CatalogBundle/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Category extends ExtendCategory implements OrganizationAwareInterface
/**
* @var string
*
* @ORM\Column(type="string", nullable=false)
* @ORM\Column(type="string", nullable=false, unique=true)
* @ConfigField(
* defaultValues={
* "dataaudit"={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MarelloCatalogBundleInstaller implements Installation, ActivityExtensionAw
*/
public function getMigrationVersion()
{
return 'v1_1';
return 'v1_1_1';
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Marello\Bundle\CatalogBundle\Migrations\Schema\v1_1_1;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class MarelloCatalogBundle implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
/** Tables generation **/
$this->updateCatalogCategoryTable($schema);
}

/**
* Create marello_catalog_category table
*
* @param Schema $schema
*/
protected function updateCatalogCategoryTable(Schema $schema)
{
$table = $schema->getTable('marello_catalog_category');
if ($table->hasIndex('UNIQ_C4B343DF77153098')) {
$table->renameIndex('UNIQ_C4B343DF77153098', 'marello_catalog_category_codeidx');
}
}
}
9 changes: 8 additions & 1 deletion src/Marello/Bundle/TaxBundle/Entity/TaxCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
* TaxCode
*
* @ORM\Entity(repositoryClass="Marello\Bundle\TaxBundle\Entity\Repository\TaxCodeRepository")
* @ORM\Table(name="marello_tax_tax_code")
* @ORM\Table(name="marello_tax_tax_code",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="marello_tax_code_codeidx",
* columns={"code"}
* )
* }
* )
* @Oro\Config(
* routeName="marello_tax_taxcode_index",
* routeView="marello_tax_taxcode_view",
Expand Down
9 changes: 8 additions & 1 deletion src/Marello/Bundle/TaxBundle/Entity/TaxJurisdiction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@

/**
* @ORM\Entity
* @ORM\Table("marello_tax_tax_jurisdiction")
* @ORM\Table("marello_tax_tax_jurisdiction",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="marello_tax_jurisdiction_codeidx",
* columns={"code"}
* )
* }
* )
* @ORM\HasLifecycleCallbacks
* @Config(
* mode="hidden",
Expand Down
9 changes: 8 additions & 1 deletion src/Marello/Bundle/TaxBundle/Entity/TaxRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
* TaxRate
*
* @ORM\Entity(repositoryClass="Marello\Bundle\TaxBundle\Entity\Repository\TaxRateRepository")
* @ORM\Table(name="marello_tax_tax_rate")
* @ORM\Table(name="marello_tax_tax_rate",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="marello_tax_rate_codeidx",
* columns={"code"}
* )
* }
* )
* @Oro\Config(
* routeName="marello_tax_taxrate_index",
* routeView="marello_tax_taxrate_view",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MarelloTaxBundleInstaller implements Installation
*/
public function getMigrationVersion()
{
return 'v1_3';
return 'v1_3_1';
}

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ protected function createMarelloTaxTaxCodeTable(Schema $schema)
$table->addColumn('description', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('data', 'json_array', ['notnull' => false, 'comment' => '(DC2Type:json_array)']);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code']);
$table->addUniqueIndex(['code'], 'marello_tax_code_codeidx');
}

/**
Expand All @@ -68,7 +68,7 @@ protected function createMarelloTaxTaxRateTable(Schema $schema)
$table->addColumn('rate', 'percent', ['notnull' => true, 'comment' => '(DC2Type:percent)']);
$table->addColumn('data', 'json_array', ['notnull' => false, 'comment' => '(DC2Type:json_array)']);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code']);
$table->addUniqueIndex(['code'], 'marello_tax_rate_codeidx');
}

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ protected function createMarelloTaxJurisdictionTable(Schema $schema)
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('data', 'json_array', ['notnull' => false, 'comment' => '(DC2Type:json_array)']);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code'], 'UNIQ_2CBEF9AE77153098');
$table->addUniqueIndex(['code'], 'marello_tax_jurisdiction_codeidx');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function createMarelloTaxTaxCodeTable(Schema $schema)
$table->addColumn('code', 'string', ['notnull' => true, 'length' => 32]);
$table->addColumn('description', 'string', ['notnull' => false, 'length' => 255]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code']);
$table->addUniqueIndex(['code'], 'marello_tax_code_codeidx');
}

/**
Expand All @@ -53,7 +53,7 @@ protected function createMarelloTaxTaxRateTable(Schema $schema)
$table->addColumn('code', 'string', ['notnull' => true, 'length' => 32]);
$table->addColumn('rate', 'float', ['notnull' => true]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code']);
$table->addUniqueIndex(['code'], 'marello_tax_rate_codeidx');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function createMarelloTaxJurisdictionTable(Schema $schema)
$table->addColumn('description', 'text', ['notnull' => false]);
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code'], 'UNIQ_2CBEF9AE77153098');
$table->addUniqueIndex(['code'], 'marello_tax_jurisdiction_codeidx');
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Marello\Bundle\TaxBundle\Migrations\Schema\v1_3_1;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class MarelloTaxBundle implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
/** Tables generation **/
$this->updateMarelloTaxCodeTable($schema);
$this->updateMarelloTaxJurisdictionTable($schema);
$this->updateMarelloTaxRateTable($schema);
}

/**
* {@inheritdoc}
* @param Schema $schema
*/
protected function updateMarelloTaxCodeTable(Schema $schema)
{
$table = $schema->getTable('marello_tax_tax_code');
if ($table->hasIndex('uniq_marello_tax_tax_code_code')) {
$table->renameIndex('uniq_marello_tax_tax_code_code', 'marello_tax_code_codeidx');
}
}

/**
* {@inheritdoc}
* @param Schema $schema
*/
protected function updateMarelloTaxJurisdictionTable(Schema $schema)
{
$table = $schema->getTable('marello_tax_tax_jurisdiction');
if ($table->hasIndex('UNIQ_2CBEF9AE77153098')) {
$table->renameIndex('UNIQ_2CBEF9AE77153098', 'marello_tax_jurisdiction_codeidx');
}
}

/**
* {@inheritdoc}
* @param Schema $schema
*/
protected function updateMarelloTaxRateTable(Schema $schema)
{
$table = $schema->getTable('marello_tax_tax_rate');
if ($table->hasIndex('uniq_marello_tax_tax_rate_code')) {
$table->renameIndex('uniq_marello_tax_tax_rate_code', 'marello_tax_rate_codeidx');
}
}
}

0 comments on commit 4d4dde3

Please sign in to comment.