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

class AddEpicBoardRecentVisitsTable < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  def up
    with_lock_retries do
      unless table_exists?(:boards_epic_board_recent_visits)
        create_table :boards_epic_board_recent_visits do |t|
          t.references :user, index: true, null: false, foreign_key: { on_delete: :cascade }
          t.references :epic_board, index: true, foreign_key: { to_table: :boards_epic_boards, on_delete: :cascade }, null: false
          t.references :group, index: true, foreign_key: { to_table: :namespaces, on_delete: :cascade }, null: false
          t.timestamps_with_timezone null: false
        end
      end
    end
  end

  def down
    with_lock_retries do
      drop_table :boards_epic_board_recent_visits
    end
  end
end