diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-24 19:17:39 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-01-24 19:17:39 +0000 |
commit | 5f410001eb718e23835d933e66f4973bfd2b0a10 (patch) | |
tree | 0353258bc33ac4de0c4f6931505d4b81a76a0763 | |
parent | 94cc7cfad25f2c28bd4db8ca1fd39ece98c206b4 (diff) | |
parent | 929c20c2bc851c084e81713441a73c82174556a0 (diff) | |
download | gitlab-ce-5f410001eb718e23835d933e66f4973bfd2b0a10.tar.gz |
Merge branch 'add-existence-checks-in-backported-migrations-ce' into 'master'
Make the time estimate migrations reversible
See merge request !8749
-rw-r--r-- | db/migrate/20161223034433_add_estimate_to_issuables_ce.rb | 12 | ||||
-rw-r--r-- | db/migrate/20161223034646_create_timelogs_ce.rb | 6 |
2 files changed, 16 insertions, 2 deletions
diff --git a/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb b/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb index 2cbe626d752..d5116dfab49 100644 --- a/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb +++ b/db/migrate/20161223034433_add_estimate_to_issuables_ce.rb @@ -3,7 +3,7 @@ class AddEstimateToIssuablesCe < ActiveRecord::Migration DOWNTIME = false - def change + def up unless column_exists?(:issues, :time_estimate) add_column :issues, :time_estimate, :integer end @@ -12,4 +12,14 @@ class AddEstimateToIssuablesCe < ActiveRecord::Migration add_column :merge_requests, :time_estimate, :integer end end + + def down + if column_exists?(:issues, :time_estimate) + remove_column :issues, :time_estimate + end + + if column_exists?(:merge_requests, :time_estimate) + remove_column :merge_requests, :time_estimate + end + end end diff --git a/db/migrate/20161223034646_create_timelogs_ce.rb b/db/migrate/20161223034646_create_timelogs_ce.rb index e8a4b406012..66d9cd823fb 100644 --- a/db/migrate/20161223034646_create_timelogs_ce.rb +++ b/db/migrate/20161223034646_create_timelogs_ce.rb @@ -3,7 +3,7 @@ class CreateTimelogsCe < ActiveRecord::Migration DOWNTIME = false - def change + def up unless table_exists?(:timelogs) create_table :timelogs do |t| t.integer :time_spent, null: false @@ -17,4 +17,8 @@ class CreateTimelogsCe < ActiveRecord::Migration add_index :timelogs, :user_id end end + + def down + drop_table :timelogs if table_exists?(:timelogs) + end end |