From 70b8df85e72c9796a13c7f09481d7634752aae09 Mon Sep 17 00:00:00 2001 From: Michael Milton Date: Mon, 18 Dec 2023 16:38:11 -0500 Subject: [PATCH] tweak tests and move sessions to prior established file --- .../80/05_session_base_table_updates.up.sql | 18 ++++++++++++----- .../80/10_session_base_table_updates.up.sql | 20 ------------------- .../db/sqltest/tests/pagination/session.sql | 4 ++-- 3 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 internal/db/schema/migrations/oss/postgres/80/10_session_base_table_updates.up.sql diff --git a/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql index 1bffedf3fcd..cfa829b236a 100644 --- a/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql @@ -3,11 +3,19 @@ begin; - -- Add new indexes for the create time and update time queries. - create index session_create_time_public_id_idx - on session (create_time desc, public_id asc); - create index session_update_time_public_id_idx - on session (update_time desc, public_id asc); + -- Add new indexes for the create and update time queries. + create index session_create_time_list_idx + on session (create_time desc, + public_id, + project_id, + user_id, + termination_reason); + create index session_update_time_list_idx + on session (update_time desc, + public_id, + project_id, + user_id, + termination_reason); analyze session; diff --git a/internal/db/schema/migrations/oss/postgres/80/10_session_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/10_session_base_table_updates.up.sql deleted file mode 100644 index 886e62df1d4..00000000000 --- a/internal/db/schema/migrations/oss/postgres/80/10_session_base_table_updates.up.sql +++ /dev/null @@ -1,20 +0,0 @@ --- Copyright (c) HashiCorp, Inc. --- SPDX-License-Identifier: BUSL-1.1 - -begin; - - -- Add new indexes for the create and update time queries. - create index session_create_time_list_idx - on session (create_time desc, - public_id, - project_id, - user_id, - termination_reason); - create index session_update_time_list_idx - on session (update_time desc, - public_id, - project_id, - user_id, - termination_reason); - -commit; \ No newline at end of file diff --git a/internal/db/sqltest/tests/pagination/session.sql b/internal/db/sqltest/tests/pagination/session.sql index f1ed46374a7..cb729d15eff 100644 --- a/internal/db/sqltest/tests/pagination/session.sql +++ b/internal/db/sqltest/tests/pagination/session.sql @@ -4,8 +4,8 @@ begin; select plan(2); - select has_index('session', 'session_create_time_public_id_idx', array['create_time', 'public_id']); - select has_index('session', 'session_update_time_public_id_idx', array['update_time', 'public_id']); + select has_index('session', 'session_create_time_list_idx', array['create_time', 'public_id', 'project_id', 'user_id', 'termination_reason']); + select has_index('session', 'session_update_time_list_idx', array['update_time', 'public_id', 'project_id', 'user_id', 'termination_reason']); select * from finish();