diff --git a/internal/credential/query.go b/internal/credential/query.go index 9aa590e9b..9d92ca754 100644 --- a/internal/credential/query.go +++ b/internal/credential/query.go @@ -26,7 +26,7 @@ with stores as ( select public_id from credential_store where %s -- search condition for project IDs is constructed - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), vault_stores as ( @@ -102,7 +102,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listStoresPageTemplate = ` @@ -111,7 +111,7 @@ with stores as ( from credential_store where (create_time, public_id) < (@last_item_create_time, @last_item_id) and %s -- search condition for project IDs is constructed - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), vault_stores as ( @@ -187,7 +187,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listStoresRefreshTemplate = ` @@ -196,7 +196,7 @@ with stores as ( from credential_store where update_time > @updated_after_time and %s -- search condition for project IDs is constructed - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), vault_stores as ( @@ -272,7 +272,7 @@ final as ( ) select * from final -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` listStoresRefreshPageTemplate = ` @@ -282,7 +282,7 @@ with stores as ( where update_time > @updated_after_time and (update_time, public_id) < (@last_item_update_time, @last_item_id) and %s -- search condition for project IDs is constructed - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), vault_stores as ( @@ -358,6 +358,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/credential/static/query.go b/internal/credential/static/query.go index 4a6a53b03..787872b86 100644 --- a/internal/credential/static/query.go +++ b/internal/credential/static/query.go @@ -56,7 +56,7 @@ with credentials as ( select public_id from credential_static where store_id = @store_id - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), json_creds as ( @@ -122,7 +122,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listCredentialsPageTemplate = ` @@ -131,7 +131,7 @@ with credentials as ( from credential_static where store_id = @store_id and (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 ), json_creds as ( @@ -197,7 +197,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listCredentialsRefreshTemplate = ` @@ -206,7 +206,7 @@ with credentials as ( from credential_static where store_id = @store_id and update_time > @updated_after_time - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), json_creds as ( @@ -272,7 +272,7 @@ final as ( ) select * from final -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` listCredentialsRefreshPageTemplate = ` @@ -282,7 +282,7 @@ with credentials as ( where store_id = @store_id and 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 ), json_creds as ( @@ -348,6 +348,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/credential/vault/query.go b/internal/credential/vault/query.go index 5b9801ca7..b65a1c40c 100644 --- a/internal/credential/vault/query.go +++ b/internal/credential/vault/query.go @@ -204,7 +204,7 @@ with libraries as ( select public_id from credential_library where store_id = @store_id - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ), generic_libs as ( @@ -266,7 +266,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listLibrariesPageTemplate = ` @@ -275,7 +275,7 @@ with libraries as ( from credential_library where store_id = @store_id and (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 ), generic_libs as ( @@ -337,7 +337,7 @@ final as ( ) select * from final -order by create_time desc, public_id asc; +order by create_time desc, public_id desc; ` listLibrariesRefreshTemplate = ` @@ -346,7 +346,7 @@ with libraries as ( from credential_library where store_id = @store_id and update_time > @updated_after_time - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ), generic_libs as ( @@ -408,7 +408,7 @@ final as ( ) select * from final -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` listLibrariesRefreshPageTemplate = ` @@ -418,7 +418,7 @@ with libraries as ( where store_id = @store_id and 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 ), generic_libs as ( @@ -480,6 +480,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/03_credential_static_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/03_credential_static_base_table_updates.up.sql index 146199139..73fe34c36 100644 --- a/internal/db/schema/migrations/oss/postgres/80/03_credential_static_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/03_credential_static_base_table_updates.up.sql @@ -60,9 +60,9 @@ begin; -- Add new indexes for the create and update time queries. create index credential_static_create_time_public_id_idx - on credential_static (create_time desc, public_id asc); + on credential_static (create_time desc, public_id desc); create index credential_static_update_time_public_id_idx - on credential_static (update_time desc, public_id asc); + on credential_static (update_time desc, public_id desc); analyze credential_static; diff --git a/internal/db/schema/migrations/oss/postgres/80/04_credential_library_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/04_credential_library_base_table_updates.up.sql index 20f8621ef..b7923cdce 100644 --- a/internal/db/schema/migrations/oss/postgres/80/04_credential_library_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/04_credential_library_base_table_updates.up.sql @@ -54,9 +54,9 @@ begin; -- Add new indexes for the create and update time queries. create index credential_library_create_time_public_id_idx - on credential_library (create_time desc, public_id asc); + on credential_library (create_time desc, public_id desc); create index credential_library_update_time_public_id_idx - on credential_library (update_time desc, public_id asc); + on credential_library (update_time desc, public_id desc); analyze credential_library; diff --git a/internal/db/schema/migrations/oss/postgres/80/07_credential_store_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/07_credential_store_base_table_updates.up.sql index a963ebcd9..3726588bc 100644 --- a/internal/db/schema/migrations/oss/postgres/80/07_credential_store_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/07_credential_store_base_table_updates.up.sql @@ -50,9 +50,9 @@ begin; -- Add new indexes for the create and update time queries. create index credential_store_create_time_public_id_idx - on credential_store (create_time desc, public_id asc); + on credential_store (create_time desc, public_id desc); create index credential_store_update_time_public_id_idx - on credential_store (update_time desc, public_id asc); + on credential_store (update_time desc, public_id desc); analyze credential_store;