BigW Consortium Gitlab

20130218141327_convert_closed_to_state_in_merge_request.rb 722 Bytes
Newer Older
1
# rubocop:disable all
2
class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration
3 4
  include Gitlab::Database

5
  def up
6 7 8
    execute "UPDATE #{table_name} SET state = 'merged' WHERE closed = #{true_value} AND merged = #{true_value}"
    execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value} AND merged = #{false_value}"
    execute "UPDATE #{table_name} SET state = 'opened' WHERE closed = #{false_value}"
9 10 11
  end

  def down
12 13 14 15 16 17 18 19
    execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'closed'"
    execute "UPDATE #{table_name} SET closed = #{true_value}, merged = #{true_value} WHERE state = 'merged'"
  end

  private

  def table_name
    MergeRequest.table_name
20 21
  end
end