debian-mirror-gitlab/db/migrate/20170707183807_add_group_id_to_milestones.rb
2019-02-13 22:33:31 +05:30

20 lines
544 B
Ruby

class AddGroupIdToMilestones < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
return if column_exists? :milestones, :group_id
change_column_null :milestones, :project_id, true
add_column :milestones, :group_id, :integer
end
def down
# We cannot rollback project_id not null constraint if there are records
# with null values.
execute "DELETE from milestones WHERE project_id IS NULL"
remove_column :milestones, :group_id
change_column :milestones, :project_id, :integer, null: false
end
end