Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DESC INDEX #2416

Open
MC-XiaoHei opened this issue Feb 19, 2025 · 0 comments
Open

Support DESC INDEX #2416

MC-XiaoHei opened this issue Feb 19, 2025 · 0 comments

Comments

@MC-XiaoHei
Copy link

MC-XiaoHei commented Feb 19, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant