Remove invalid todos from database
This commit is contained in:
parent
9e342fb00a
commit
22140ced0b
2 changed files with 17 additions and 1 deletions
16
db/migrate/20160309140734_fix_todos.rb
Normal file
16
db/migrate/20160309140734_fix_todos.rb
Normal file
|
@ -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
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160305220806) do
|
||||
ActiveRecord::Schema.define(version: 20160309140734) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Reference in a new issue