summaryrefslogtreecommitdiff
path: root/db/migrate/20170809142252_cleanup_appearances_schema.rb
blob: 4c5d6a6d75d8be8fa09dc2c56100c1e98de34137 (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
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class CleanupAppearancesSchema < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

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

  NOT_NULL_COLUMNS = %i[title description created_at updated_at]

  TIME_COLUMNS = %i[created_at updated_at]

  def up
    NOT_NULL_COLUMNS.each do |column|
      change_column_null :appearances, column, false
    end

    TIME_COLUMNS.each do |column|
      change_column :appearances, column, :datetime_with_timezone
    end
  end

  def down
    NOT_NULL_COLUMNS.each do |column|
      change_column_null :appearances, column, true
    end

    TIME_COLUMNS.each do |column|
      change_column :appearances, column, :datetime # rubocop: disable Migration/Datetime
    end
  end
end