diff --git a/db/migrate/20110318012008_delete_disconnected_notifications.rb b/db/migrate/20110318012008_delete_disconnected_notifications.rb
new file mode 100644
index 0000000000000000000000000000000000000000..71579127e079afa6bef81620452651bc31441b6c
--- /dev/null
+++ b/db/migrate/20110318012008_delete_disconnected_notifications.rb
@@ -0,0 +1,11 @@
+class DeleteDisconnectedNotifications < ActiveRecord::Migration
+  def self.up
+    result = execute("SELECT notifications.id FROM notifications
+            LEFT OUTER JOIN posts ON posts.id = notifications.target_id
+            WHERE posts.id IS NULL AND notifications.target_id IS NOT NULL AND notifications.target_type = 'Post'").to_a.flatten!
+    execute("DELETE FROM notifications WHERE notifications.id IN (#{result.join(',')})") if result
+  end
+
+  def self.down
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b64ec39d015f7c3e4886103bd7747e1fa407537c..6f99d15a060136421889c3cdb98e6b3cd18f41c8 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20110317222802) do
+ActiveRecord::Schema.define(:version => 20110318012008) do
 
   create_table "aspect_memberships", :force => true do |t|
     t.integer  "aspect_id",  :null => false