summaryrefslogtreecommitdiff
path: root/db/migrate/20200106085831_add_timestamps_to_packages_tags.rb
blob: 2720d9b3297ff4f91f7ef129b1132c6d1b0643e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class AddTimestampsToPackagesTags < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  # We disable these cops here because adding this column is safe. The table does not
  # have any data in it.
  # rubocop: disable Migration/AddIndex
  def up
    add_timestamps_with_timezone(:packages_tags, null: false)
    add_index(:packages_tags, [:package_id, :updated_at], order: { updated_at: :desc })
  end

  # We disable these cops here because adding this column is safe. The table does not
  # have any data in it.
  # rubocop: disable Migration/RemoveIndex
  def down
    remove_index(:packages_tags, [:package_id, :updated_at])
    remove_timestamps(:packages_tags)
  end
end