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

20180517082340_add_not_null_constraints_to_project_authorizations.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 859e341d04bc71ab5a8b72c3e8c1c931a6dedc4c (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
class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  def up
    execute <<~SQL
      ALTER TABLE project_authorizations
        ALTER COLUMN user_id SET NOT NULL,
        ALTER COLUMN project_id SET NOT NULL,
        ALTER COLUMN access_level SET NOT NULL
    SQL
  end

  def down
    execute <<~SQL
      ALTER TABLE project_authorizations
        ALTER COLUMN user_id DROP NOT NULL,
        ALTER COLUMN project_id DROP NOT NULL,
        ALTER COLUMN access_level DROP NOT NULL
    SQL
  end
end