Fix #39. Duplicated index 'subscriptions.subscription_unique' removed.

This commit is contained in:
Alexey Skobkin 2017-11-06 04:43:23 +03:00
parent 34bf869cea
commit a44ce74d9b
2 changed files with 35 additions and 3 deletions

View file

@ -0,0 +1,34 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* subscription_unique index was removed because it was duplicating PK of the table.
*/
class Version20171106013937 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP INDEX subscriptions.subscription_unique');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE UNIQUE INDEX subscription_unique ON subscriptions.subscriptions (author_id, subscriber_id)');
}
}

View file

@ -5,9 +5,7 @@ namespace Skobkin\Bundle\PointToolsBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Table(name="subscriptions", schema="subscriptions", uniqueConstraints={ * @ORM\Table(name="subscriptions", schema="subscriptions")
* @ORM\UniqueConstraint(name="subscription_unique", columns={"author_id", "subscriber_id"})}
* )
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository", readOnly=true) * @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository", readOnly=true)
*/ */
class Subscription class Subscription