Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20200214025454_add_canonical_emails.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80cf535abfad2f7cce70774b4b79f2d9d4af70e4 (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
25
26
# frozen_string_literal: true

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

  DOWNTIME = false

  def up
    with_lock_retries do
      create_table :user_canonical_emails do |t|
        t.timestamps_with_timezone
        t.references :user, index: false, null: false, foreign_key: { on_delete: :cascade }
        t.string :canonical_email, null: false, index: true # rubocop:disable Migration/AddLimitToStringColumns
      end
    end

    add_index :user_canonical_emails, [:user_id, :canonical_email], unique: true
    add_index :user_canonical_emails, :user_id, unique: true
  end

  def down
    with_lock_retries do
      drop_table(:user_canonical_emails)
    end
  end
end