diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-24 05:14:02 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-30 18:09:34 +0300 |
commit | 9b93f8adc8d04ed2f62be06241723491711a6cbd (patch) | |
tree | 1a72351e92209386853d58bc3473df98f86060e7 /db/migrate/20160324020319_remove_todos_for_deleted_issues.rb | |
parent | 07e1ec5dc1473458c899e745e02e021abfe02212 (diff) |
Destroy related todos when an issue is deleted
Diffstat (limited to 'db/migrate/20160324020319_remove_todos_for_deleted_issues.rb')
-rw-r--r-- | db/migrate/20160324020319_remove_todos_for_deleted_issues.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb b/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb new file mode 100644 index 00000000000..1fff9759d1e --- /dev/null +++ b/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb @@ -0,0 +1,17 @@ +class RemoveTodosForDeletedIssues < ActiveRecord::Migration + def up + execute <<-SQL + DELETE FROM todos + WHERE todos.target_type = 'Issue' + AND NOT EXISTS ( + SELECT * + FROM issues + WHERE issues.id = todos.target_id + AND issues.deleted_at IS NULL + ) + SQL + end + + def down + end +end |