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

20160831223750_remove_features_enabled_from_projects.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aec709aaf59f203d1518f1a32e9972becfda6eb2 (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
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

# rubocop:disable Migration/UpdateLargeTable
class RemoveFeaturesEnabledFromProjects < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers
  disable_ddl_transaction!

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = true
  DOWNTIME_REASON = "Removing fields from database requires downtine."

  def up
    remove_column :projects, :issues_enabled
    remove_column :projects, :merge_requests_enabled
    remove_column :projects, :builds_enabled
    remove_column :projects, :wiki_enabled
    remove_column :projects, :snippets_enabled
  end

  # Ugly SQL but the only way i found to make it work on both Postgres and Mysql
  # It will be slow but it is ok since it is a revert method
  def down
    add_column_with_default(:projects, :issues_enabled, :boolean, default: true, allow_null: false)
    add_column_with_default(:projects, :merge_requests_enabled, :boolean, default: true, allow_null: false)
    add_column_with_default(:projects, :builds_enabled, :boolean, default: true, allow_null: false)
    add_column_with_default(:projects, :wiki_enabled, :boolean, default: true, allow_null: false)
    add_column_with_default(:projects, :snippets_enabled, :boolean, default: true, allow_null: false)
  end
end