2020-04-22 19:07:51 +05:30
|
|
|
# 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 }
|
2020-05-24 23:13:21 +05:30
|
|
|
t.string :canonical_email, null: false, index: true # rubocop:disable Migration/PreventStrings
|
2020-04-22 19:07:51 +05:30
|
|
|
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
|
2020-06-23 00:09:42 +05:30
|
|
|
# rubocop:disable Migration/DropTable
|
2020-04-22 19:07:51 +05:30
|
|
|
drop_table(:user_canonical_emails)
|
2020-06-23 00:09:42 +05:30
|
|
|
# rubocop:enable Migration/DropTable
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|