diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-03-14 20:13:36 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-03-14 20:13:36 +0800 |
commit | af8cc2e064bb97a8a1801521735d5403b189bfb5 (patch) | |
tree | 4b5b1d8d0fe00672bca807a6021432810ab63b33 | |
parent | f67d8eb1da269150764224cea1807195cdf2ffb5 (diff) | |
download | gitlab-ce-af8cc2e064bb97a8a1801521735d5403b189bfb5.tar.gz |
Use `remove_foreign_key :timelogs, name: '...'`
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9908#note_25324225
-rw-r--r-- | db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 676e18cddd3..a7d4e141a1a 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -49,15 +49,8 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'") Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") - constraint = - if Gitlab::Database.postgresql? - 'CONSTRAINT' - else - 'FOREIGN KEY' - end - - execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_issues_issue_id" - execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_merge_requests_merge_request_id" + remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id' + remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id' remove_columns :timelogs, :issue_id, :merge_request_id end |