diff options
Diffstat (limited to 'db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb')
-rw-r--r-- | db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb new file mode 100644 index 00000000000..d732fb35ce9 --- /dev/null +++ b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddUniqueNamespaceIndexToStorageLimitExclusions < Gitlab::Database::Migration[2.1] + TABLE_NAME = 'namespaces_storage_limit_exclusions' + OLD_INDEX_NAME = 'index_namespaces_storage_limit_exclusions_on_namespace_id' + NEW_INDEX_NAME = 'unique_idx_namespaces_storage_limit_exclusions_on_namespace_id' + + disable_ddl_transaction! + + def up + add_concurrent_index TABLE_NAME, :namespace_id, + unique: true, + name: NEW_INDEX_NAME + + remove_concurrent_index_by_name TABLE_NAME, OLD_INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :namespace_id, + unique: false, + name: OLD_INDEX_NAME + + remove_concurrent_index_by_name TABLE_NAME, NEW_INDEX_NAME + end +end |