diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-31 10:45:03 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-31 10:46:06 -0300 |
commit | db36ef60e921847f12ccdff294738910c9173c3c (patch) | |
tree | 7d9ab060eb65deb90caa4cbccee55f15d76059b0 /db | |
parent | 9b93f8adc8d04ed2f62be06241723491711a6cbd (diff) | |
download | gitlab-ce-db36ef60e921847f12ccdff294738910c9173c3c.tar.gz |
Remove todos for deleted merge requests
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 18 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index 9b9319ddb4f..90eaff1a4dd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160324020319) do +ActiveRecord::Schema.define(version: 20160331133914) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |