diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-31 16:45:03 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-31 16:46:06 +0300 |
commit | db36ef60e921847f12ccdff294738910c9173c3c (patch) | |
tree | 7d9ab060eb65deb90caa4cbccee55f15d76059b0 /db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb | |
parent | 9b93f8adc8d04ed2f62be06241723491711a6cbd (diff) |
Remove todos for deleted merge requests
Diffstat (limited to 'db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb')
-rw-r--r-- | db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb b/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb new file mode 100644 index 00000000000..54cea964ff2 --- /dev/null +++ b/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb @@ -0,0 +1,17 @@ +class RemoveTodosForDeletedMergeRequests < ActiveRecord::Migration + def up + execute <<-SQL + DELETE FROM todos + WHERE todos.target_type = 'MergeRequest' + AND NOT EXISTS ( + SELECT * + FROM merge_requests + WHERE merge_requests.id = todos.target_id + AND merge_requests.deleted_at IS NULL + ) + SQL + end + + def down + end +end |