diff --git a/internal/authtoken/query.go b/internal/authtoken/query.go index 1b416b893..6c5d5c351 100644 --- a/internal/authtoken/query.go +++ b/internal/authtoken/query.go @@ -17,7 +17,7 @@ with auth_tokens as ( expiration_time, status from auth_token - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), auth_accounts as ( @@ -47,7 +47,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listAuthTokensPageTemplate = ` with auth_tokens as ( @@ -60,7 +60,7 @@ with auth_tokens as ( status from auth_token where (create_time, public_id) < (@last_item_create_time, @last_item_id) - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), auth_accounts as ( @@ -90,7 +90,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` refreshAuthTokensTemplate = ` with auth_tokens as ( @@ -103,7 +103,7 @@ with auth_tokens as ( status from auth_token where update_time > @updated_after_time - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), auth_accounts as ( @@ -133,7 +133,7 @@ final as ( ) select * from final -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` refreshAuthTokensPageTemplate = ` with auth_tokens as ( @@ -147,7 +147,7 @@ with auth_tokens as ( from auth_token where update_time > @updated_after_time and (update_time, public_id) < (@last_item_update_time, @last_item_id) - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), auth_accounts as ( @@ -177,6 +177,6 @@ final as ( ) select * from final -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` ) diff --git a/internal/db/schema/migrations/oss/postgres/80/06_auth_token_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/06_auth_token_base_table_updates.up.sql index 2d52fef59..b088c67f1 100644 --- a/internal/db/schema/migrations/oss/postgres/80/06_auth_token_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/06_auth_token_base_table_updates.up.sql @@ -5,10 +5,10 @@ begin; -- Add new indexes for the create time and update time queries. create index auth_token_create_time_public_id_idx - on auth_token (create_time desc, public_id asc); + on auth_token (create_time desc, public_id desc); create index auth_token_update_time_public_id_idx - on auth_token (update_time desc, public_id asc); + on auth_token (update_time desc, public_id desc); analyze auth_token; -commit; \ No newline at end of file +commit;