DDC-3966: After 2.5 upgrade: doctrine:schema:update --force fails because it detects invalid index name #4846

Open
opened 2026-01-22 14:50:26 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Oct 30, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user renoreckling:

We just upgraded to doctrine 2.5.1.
On our Postgresql DB, running doctrine:schema:update --force after we load our schema from migrations now fails with the following error:

  [Doctrine\DBAL\Exception\TableNotFoundException]                                                          
  An exception occurred while executing 'ALTER INDEX idx*55881faae3e6fba2 RENAME TO IDX*55881FAA2C5BC23E':  
  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "idx_55881faae3e6fba2" does not exist             

I think that should be impossible. I looked into the DB and there is no index named idx_55881faae3e6fba2 in the database.

The target name IDX_55881FAA2C5BC23E has previously existed but was removed some time ago via db migrations and the appropriate entity change.

This does not happen in doctrine/orm 2.4.4

Originally created by @doctrinebot on GitHub (Oct 30, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user renoreckling: We just upgraded to doctrine 2.5.1. On our Postgresql DB, running doctrine:schema:update --force after we load our schema from migrations now fails with the following error: ``` [Doctrine\DBAL\Exception\TableNotFoundException] An exception occurred while executing 'ALTER INDEX idx*55881faae3e6fba2 RENAME TO IDX*55881FAA2C5BC23E': SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "idx_55881faae3e6fba2" does not exist ``` I think that should be impossible. I looked into the DB and there is no index named idx_55881faae3e6fba2 in the database. The target name IDX_55881FAA2C5BC23E has previously existed but was removed some time ago via db migrations and the appropriate entity change. This does not happen in doctrine/orm 2.4.4
admin added the Bug label 2026-01-22 14:50:26 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2015):

Comment created by renoreckling:

This seems to be caused by an existing foreign key that assumes the presence of an index on the id_column.

We have the situation:

Table A has a column b_id with foreign key constraint to table B.id.

Doctrine seems to assume that every foreign key is accompanied with a matching index, in this example on Table A.b_id, which is missing in our case.

@doctrinebot commented on GitHub (Oct 30, 2015): Comment created by renoreckling: This seems to be caused by an existing foreign key that assumes the presence of an index on the id_column. We have the situation: Table A has a column b_id with foreign key constraint to table B.id. Doctrine seems to assume that every foreign key is accompanied with a matching index, in this example on Table A.b_id, which is missing in our case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4846