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

20200430174637_create_group_deploy_keys.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9771ae013ea5293375f8c831d3107187f647c11c (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
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

class CreateGroupDeployKeys < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers
  DOWNTIME = false

  disable_ddl_transaction!

  def up
    unless table_exists?(:group_deploy_keys)
      with_lock_retries do
        create_table :group_deploy_keys do |t|
          t.references :user, foreign_key: { on_delete: :restrict }, index: true
          t.timestamps_with_timezone
          t.datetime_with_timezone :last_used_at
          t.datetime_with_timezone :expires_at
          t.text :key, null: false, unique: true
          t.text :title
          t.text :fingerprint, null: false, unique: true
          t.binary :fingerprint_sha256

          t.index :fingerprint, unique: true
          t.index :fingerprint_sha256
        end
      end
    end

    add_text_limit(:group_deploy_keys, :key, 4096)
    add_text_limit(:group_deploy_keys, :title, 255)
    add_text_limit(:group_deploy_keys, :fingerprint, 255)
  end

  def down
    drop_table :group_deploy_keys
  end
end