Commit af8cc2e0 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use `remove_foreign_key :timelogs, name: '...'`

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9908#note_25324225
parent f67d8eb1
...@@ -49,15 +49,8 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration ...@@ -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('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'") Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'")
constraint = remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id'
if Gitlab::Database.postgresql? remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id'
'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_columns :timelogs, :issue_id, :merge_request_id remove_columns :timelogs, :issue_id, :merge_request_id
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