JetBrains / JetBrains/Exposed

Support DESC INDEX

Open
#2,416 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

It would be great to be able to do something like this with an API
```
CREATE INDEX IF NOT EXISTS unit_operations_time_idx ON unit_operations (time DESC);
```

for now, I need to use some code like this to implement this:
```
object UnitOperationsTable : LongIdTable("unit_operations") {
val unitId = integer("unit_id")
val time = defaultNowTimestampTz("time")

init {
index(customIndexName = "unit_operations_unit_id_idx", columns = arrayOf(unitId))
try {
transaction {
exec("CREATE INDEX IF NOT EXISTS unit_operations_time_idx ON unit_operations (time DESC);")
}
} catch (_: ExposedSQLException) {
// when run first time, the table may not exist, so ignore the error
}
}
}
```
and you see, index **wil not** created at the first time.
I'd like some other alternative way to do this

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.