From d4b60241db17c7a3d2eb3173aeee039074cedf8a Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Wed, 3 Jan 2024 17:29:49 -0800 Subject: [PATCH] internal/db: storage bucket pagination migrations (#4213) --- .../80/16_storage_bucket_updates.up.sql | 14 +++++++++++++ .../tests/pagination/storage_bucket.sql | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 internal/db/schema/migrations/oss/postgres/80/16_storage_bucket_updates.up.sql create mode 100644 internal/db/sqltest/tests/pagination/storage_bucket.sql diff --git a/internal/db/schema/migrations/oss/postgres/80/16_storage_bucket_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/16_storage_bucket_updates.up.sql new file mode 100644 index 0000000000..a9ccd73481 --- /dev/null +++ b/internal/db/schema/migrations/oss/postgres/80/16_storage_bucket_updates.up.sql @@ -0,0 +1,14 @@ +-- Copyright (c) HashiCorp, Inc. +-- SPDX-License-Identifier: BUSL-1.1 + +begin; + + -- Add new indexes for the create time and update time queries. + create index storage_plugin_storage_bucket_create_time_public_id_idx + on storage_plugin_storage_bucket (create_time desc, public_id desc); + create index storage_plugin_storage_bucket_update_time_public_id_idx + on storage_plugin_storage_bucket (update_time desc, public_id desc); + + analyze storage_plugin_storage_bucket; + +commit; diff --git a/internal/db/sqltest/tests/pagination/storage_bucket.sql b/internal/db/sqltest/tests/pagination/storage_bucket.sql new file mode 100644 index 0000000000..36f4df3f5e --- /dev/null +++ b/internal/db/sqltest/tests/pagination/storage_bucket.sql @@ -0,0 +1,20 @@ +-- Copyright (c) HashiCorp, Inc. +-- SPDX-License-Identifier: BUSL-1.1 + +begin; + select plan(2); + + select has_index( + 'storage_plugin_storage_bucket', + 'storage_plugin_storage_bucket_create_time_public_id_idx', + array['create_time', 'public_id'] + ); + select has_index( + 'storage_plugin_storage_bucket', + 'storage_plugin_storage_bucket_update_time_public_id_idx', + array['update_time', 'public_id'] + ); + + select * from finish(); + +rollback;