mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Add descending index support #6459
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fmonts on GitHub (May 2, 2020).
Feature Request
Summary
Currently, there is no way to create a descending index (with the DESC attribute).
This feature is present in MySQL, MSSQL, PostgreSQL, and probably in the other platforms as well.
(In MySQL older than 8.0 and MariaDB it's accepted but ignored)
It should be allowed a way to create ASC/DESC indexes, for example with:
Or
@fmonts commented on GitHub (May 2, 2020):
Workaround: you can manually edit the table or add "DESC" in your migration query and luckily the schema generation tool doesn't revert it to ASC when you run it again
@beberlei commented on GitHub (Jul 5, 2020):
We cant support everything in SchemaTool, your workaround is the way to go.
@24HOURSMEDIA commented on GitHub (Jun 27, 2023):
I disagree with 'We cant support everything in SchemaTool', the descending index is a standard mysql 8, aurora, etc feature
and we absolutely need it on very large tables.
So then the schema created by doctrine is not complete without migrations.
@derrabus commented on GitHub (Jun 27, 2023):
You're disagreeing with a fact here. 🤷🏻
You're right, there's broad support among database vendors for the
ASC/DESCkeywords inCREATE INDEX.If you want to work on a PR, please feel encouraged to do so. First of all, the DBAL library needs to be able to create and introspect this kind of indexes. If you need help with that, feel free to open an issue or draft PR there.
@24HOURSMEDIA commented on GitHub (Jun 28, 2023):
Interesting thought to help improve doctrine in this respect.
However my job for this case is primarily devops engineer and keeping our databases affordable and stable.
I doubt my client wants to spend resources on maintaining 3rd party libraries.
I might pick it up if I have spare time some time.
Then I'd be enlisted as a doctrine contributor ? :)
@devbranch-vitaliy commented on GitHub (Jun 12, 2025):
Completely agree with @24HOURSMEDIA, @beberlei closed the ticket without a valid reason.
Since we have the Index attribute/annotation, it must handle the possible option that the DB supports.
It's ridiculous,
whereoprion is supported, but a simple ASC/DESC is not 🤡My opinion is that the issue must be reopened.
@EdouardCourty commented on GitHub (Jul 22, 2025):
Hi, I strongly agree with @devbranch-vitaliy, every index feature should be supported.
Please reopen this issue!
@colesnic89 commented on GitHub (Jan 3, 2026):
or like this
#[ORM\Index(fields: ['ownerNumber', 'updatedAt' => 'DESC', 'id' => 'DESC'])]