summary refs log tree commit diff
path: root/synapse/storage/schema/delta
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-08-20 10:04:04 +0100
committerMark Haines <mjark@negativecurvature.net>2015-08-20 10:04:04 +0100
commita0b8e5f2fec1982af20fdafc454047067058fd51 (patch)
treee6b02b94d49fc3ddb3c5ee7793bbc729e3fb5027 /synapse/storage/schema/delta
parentMerge pull request #232 from matrix-org/erikj/appservice_joined_rooms (diff)
parentCheck absent before trying to access keys (diff)
downloadsynapse-a0b8e5f2fec1982af20fdafc454047067058fd51.tar.xz
Merge pull request #211 from matrix-org/email_in_use
Changes for unique emails
Diffstat (limited to 'synapse/storage/schema/delta')
-rw-r--r--synapse/storage/schema/delta/22/user_threepids_unique.sql19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/storage/schema/delta/22/user_threepids_unique.sql b/synapse/storage/schema/delta/22/user_threepids_unique.sql
new file mode 100644
index 0000000000..87edfa454c
--- /dev/null
+++ b/synapse/storage/schema/delta/22/user_threepids_unique.sql
@@ -0,0 +1,19 @@
+CREATE TABLE IF NOT EXISTS user_threepids2 (
+    user_id TEXT NOT NULL,
+    medium TEXT NOT NULL,
+    address TEXT NOT NULL,
+    validated_at BIGINT NOT NULL,
+    added_at BIGINT NOT NULL,
+    CONSTRAINT medium_address UNIQUE (medium, address)
+);
+
+INSERT INTO user_threepids2
+	SELECT * FROM user_threepids WHERE added_at IN (
+		SELECT max(added_at) FROM user_threepids GROUP BY medium, address
+	)
+;
+
+DROP TABLE user_threepids;
+ALTER TABLE user_threepids2 RENAME TO user_threepids;
+
+CREATE INDEX user_threepids_user_id ON user_threepids(user_id);