summaryrefslogtreecommitdiff
path: root/db/migrate/20160309140734_fix_todos.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-09 11:18:13 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-09 11:18:13 -0300
commit22140ced0b881617ef376e21ba28c9bb9b6c5cc4 (patch)
tree43db0959ef679c954e4283cf3d553a30af23219e /db/migrate/20160309140734_fix_todos.rb
parent9e342fb00a50cbb483013acd4644bd31c440f99a (diff)
downloadgitlab-ce-22140ced0b881617ef376e21ba28c9bb9b6c5cc4.tar.gz
Remove invalid todos from database
Diffstat (limited to 'db/migrate/20160309140734_fix_todos.rb')
-rw-r--r--db/migrate/20160309140734_fix_todos.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/20160309140734_fix_todos.rb b/db/migrate/20160309140734_fix_todos.rb
new file mode 100644
index 00000000000..ebe0fc82305
--- /dev/null
+++ b/db/migrate/20160309140734_fix_todos.rb
@@ -0,0 +1,16 @@
+class FixTodos < ActiveRecord::Migration
+ def up
+ execute <<-SQL
+ DELETE FROM todos
+ WHERE todos.target_type IN ('Commit', 'ProjectSnippet')
+ OR NOT EXISTS (
+ SELECT *
+ FROM projects
+ WHERE projects.id = todos.project_id
+ )
+ SQL
+ end
+
+ def down
+ end
+end