Commit 88601cbb authored by Mark Chao's avatar Mark Chao

Add date fixed/from_migrations columns to Epic

Indicate whether start and due dates should be sourced from Epic's issue's milestones.

Post migrate epics to copy milestone dates
parent 23138484
......@@ -954,6 +954,10 @@ ActiveRecord::Schema.define(version: 20180803001726) do
t.string "title_html", null: false
t.text "description"
t.text "description_html"
t.boolean "start_date_is_fixed"
t.boolean "due_date_is_fixed"
t.date "start_date_fixed"
t.date "due_date_fixed"
end
add_index "epics", ["assignee_id"], name: "index_epics_on_assignee_id", using: :btree
......
class AddDateColumnsToEpics < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
change_table :epics do |t|
t.boolean :start_date_is_fixed
t.boolean :due_date_is_fixed
t.date :start_date_fixed
t.date :due_date_fixed
end
end
end
class UpdateDateColumnsOnEpics < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
class Epic < ActiveRecord::Base
self.table_name = 'epics'
include EachBatch
end
def up
Epic.where.not(start_date: nil).each_batch do |batch|
batch.update_all('start_date_is_fixed = true, start_date_fixed = start_date')
end
Epic.where.not(end_date: nil).each_batch do |batch|
batch.update_all('due_date_is_fixed = true, due_date_fixed = end_date')
end
end
def down
# NOOP
end
end
class UpdateEpicDatesFromMilestones < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
class Epic < ActiveRecord::Base
self.table_name = 'epics'
include EachBatch
end
def up
Epic.where(start_date: nil).find_each do |epic|
epic.update_dates
end
end
def down
# NOOP
end
end
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