18943: Migrate created_at indexes to (created_at, uuid)
[arvados.git] / services / api / db / migrate / 20220401153101_fix_created_at_indexes.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class FixCreatedAtIndexes < ActiveRecord::Migration[5.2]
6   def tables
7     %w{collections links logs groups users}
8   end
9
10   def up
11     tables.each do |t|
12       remove_index t.to_sym, :created_at
13       add_index t.to_sym, [:created_at, :uuid]
14     end
15   end
16
17   def down
18     tables.each do |t|
19       remove_index t.to_sym, [:created_at, :uuid]
20       add_index t.to_sym, :created_at
21     end
22   end
23 end