diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-07-07 20:03:13 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-07-07 20:35:32 +0300 |
commit | 4e07305b27101b164d983d51fad60cf715f31501 (patch) | |
tree | 8d3ae9750c477911b8d8f96f48a464e050c1e22a /db/migrate/20170707183807_add_group_id_to_milestones.rb | |
parent | 9c14954a81778a603a38024ce1f3f4953457d13f (diff) |
fix migrations in the future
Diffstat (limited to 'db/migrate/20170707183807_add_group_id_to_milestones.rb')
-rw-r--r-- | db/migrate/20170707183807_add_group_id_to_milestones.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20170707183807_add_group_id_to_milestones.rb b/db/migrate/20170707183807_add_group_id_to_milestones.rb new file mode 100644 index 00000000000..e46fc4f80f0 --- /dev/null +++ b/db/migrate/20170707183807_add_group_id_to_milestones.rb @@ -0,0 +1,18 @@ +class AddGroupIdToMilestones < ActiveRecord::Migration + DOWNTIME = false + + def up + 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 |