Commit 95b15ae8 authored by charlieablett's avatar charlieablett

Modify db migration to use up/down rather than change

- Add changelog file
parent e13a1aa9
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class DefaultWeightMilestoneToNil < ActiveRecord::Migration[5.1] class DefaultWeightToNil < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
...@@ -27,16 +27,23 @@ class DefaultWeightMilestoneToNil < ActiveRecord::Migration[5.1] ...@@ -27,16 +27,23 @@ class DefaultWeightMilestoneToNil < ActiveRecord::Migration[5.1]
# comments: # comments:
# disable_ddl_transaction! # disable_ddl_transaction!
def change def up
update_board_weights_from_none_to_any update_board_weights_from_none_to_any
update_board_milestone_from_none_to_any
end end
def down
update_board_weights_from_any_to_none
end
# up method
def update_board_weights_from_none_to_any def update_board_weights_from_none_to_any
execute("UPDATE boards SET weight = null WHERE weight = -1") execute("UPDATE boards SET weight = null WHERE weight = -1")
end end
def update_board_milestone_from_none_to_any # down method
execute("UPDATE boards SET milestone_id = null WHERE milestone_id = -1")
def update_board_weights_from_any_to_none
execute("UPDATE boards SET weight = -1 WHERE weight = null")
end end
end end
---
title: Properly persist -1 and null for board weight
merge_request: 14180
author:
type: changed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment