summaryrefslogtreecommitdiff
path: root/db/migrate/20220629220129_increase_webauthn_xid_length.rb
blob: c5b107ce3f6bfc09319d9d46326c34a805dc9012 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class IncreaseWebauthnXidLength < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  def up
    new_constraint_name = check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length_v3')
    add_text_limit :webauthn_registrations, :credential_xid, 1364, constraint_name: new_constraint_name

    prev_constraint_name = check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length_v2')
    remove_text_limit :webauthn_registrations, :credential_xid, constraint_name: prev_constraint_name
  end

  def down
    # no-op: Danger of failling if there are records with length(credential_xid) > 1364
  end
end