orm: ERROR: index "primary" does not exist

Cannot for the life of me find where this DROP INDEX "primary"; is coming from. If I execute each query statement generated from the output of “doctrine:schema:update” everything goes just fine. Symfony 3.2 / Postgres 9.6.1 / Doctrine 2.5 (bundle 1.6)

  An exception occurred while executing 'DROP INDEX "primary"':
  SQLSTATE[42704]: Undefined object: 7 ERROR:  index "primary" does not exist

I’ve searched my code and there’s not a single instance of declaring any indexes named primary.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (7 by maintainers)

Most upvoted comments

As asked already twice, a test case is needed. The above are examples.

@Ocramius this is definitely a legit bug. It has seemed intermittent for me but I can reproduce it using postgres and a composite key.

  • Add the following entity and create your schema.
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
class Test
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id()
     */
    protected $id;

    /**
     * @ORM\Column(type="integer")
     * @ORM\Id()
     */
    protected $test;
}
  • Then just remove the second index and run an update.
  • That errors with SQLSTATE[42704]: Undefined object: 7 ERROR: index "primary" does not exist

Any update on this? I’m struggling with this problem.

Hello, I had the same problem; I just drop manually the of the entity (database table) you need to change indexes (for example DROP INDEX actual_pk) and then re-run your doctrine update or query.

As asked already twice, a test case is needed. The above are examples.

Eh, example would be fresh install of a Symfony project using Postgres. Nothing special needs to be done. It just happens out of the box. Don’t even need to drop any indexes. Just make an entity change, generate a migration and there it goes.

Any update on this? I’m struggling with this problem.