From 93937b2b313e5b1020d21f3f2cad404ecff659c2 Mon Sep 17 00:00:00 2001
From: Erik Johnston <erik@matrix.org>
Date: Fri, 10 Apr 2015 18:47:03 +0100
Subject: Remove duplicate rows

---
 synapse/storage/schema/delta/16/remove_duplicates.sql | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 synapse/storage/schema/delta/16/remove_duplicates.sql

(limited to 'synapse/storage/schema/delta/16/remove_duplicates.sql')

diff --git a/synapse/storage/schema/delta/16/remove_duplicates.sql b/synapse/storage/schema/delta/16/remove_duplicates.sql
new file mode 100644
index 0000000000..65c97b5e2f
--- /dev/null
+++ b/synapse/storage/schema/delta/16/remove_duplicates.sql
@@ -0,0 +1,9 @@
+
+
+DELETE FROM event_to_state_groups WHERE state_group not in (
+    SELECT MAX(state_group) FROM event_to_state_groups GROUP BY event_id
+);
+
+DELETE FROM event_to_state_groups WHERE rowid not in (
+    SELECT MIN(rowid) FROM event_to_state_groups GROUP BY event_id
+);
-- 
cgit 1.5.1

