From 8e55c7433434e43ffba80b149af23747242ede29 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 28 Jul 2021 14:41:14 +0100 Subject: [PATCH] Don't recreate indexes if they already exist --- keyserver/storage/postgres/cross_signing_keys_table.go | 2 +- keyserver/storage/postgres/cross_signing_sigs_table.go | 2 +- keyserver/storage/sqlite3/cross_signing_keys_table.go | 2 +- keyserver/storage/sqlite3/cross_signing_sigs_table.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keyserver/storage/postgres/cross_signing_keys_table.go b/keyserver/storage/postgres/cross_signing_keys_table.go index 87d0511b..51f4f8a3 100644 --- a/keyserver/storage/postgres/cross_signing_keys_table.go +++ b/keyserver/storage/postgres/cross_signing_keys_table.go @@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS keyserver_cross_signing_keys ( stream_id BIGINT NOT NULL ); -CREATE UNIQUE INDEX keyserver_cross_signing_keys_idx ON keyserver_cross_signing_keys(user_id, key_type, stream_id); +CREATE UNIQUE INDEX IF NOT EXISTS keyserver_cross_signing_keys_idx ON keyserver_cross_signing_keys(user_id, key_type, stream_id); ` type crossSigningKeysStatements struct { diff --git a/keyserver/storage/postgres/cross_signing_sigs_table.go b/keyserver/storage/postgres/cross_signing_sigs_table.go index bd0f5862..be10ccf8 100644 --- a/keyserver/storage/postgres/cross_signing_sigs_table.go +++ b/keyserver/storage/postgres/cross_signing_sigs_table.go @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS keyserver_cross_signing_sigs ( signature TEXT NOT NULL ); -CREATE UNIQUE INDEX keyserver_cross_signing_sigs_idx ON keyserver_cross_signing_sigs(user_id, target_user_id, target_device_id); +CREATE UNIQUE INDEX IF NOT EXISTS keyserver_cross_signing_sigs_idx ON keyserver_cross_signing_sigs(user_id, target_user_id, target_device_id); ` type crossSigningSigsStatements struct { diff --git a/keyserver/storage/sqlite3/cross_signing_keys_table.go b/keyserver/storage/sqlite3/cross_signing_keys_table.go index 81de19a9..bd8bbc60 100644 --- a/keyserver/storage/sqlite3/cross_signing_keys_table.go +++ b/keyserver/storage/sqlite3/cross_signing_keys_table.go @@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS keyserver_cross_signing_keys ( stream_id BIGINT NOT NULL ); -CREATE UNIQUE INDEX keyserver_cross_signing_keys_idx ON keyserver_cross_signing_keys(user_id, key_type, stream_id); +CREATE UNIQUE INDEX IF NOT EXISTS keyserver_cross_signing_keys_idx ON keyserver_cross_signing_keys(user_id, key_type, stream_id); ` type crossSigningKeysStatements struct { diff --git a/keyserver/storage/sqlite3/cross_signing_sigs_table.go b/keyserver/storage/sqlite3/cross_signing_sigs_table.go index f6a4bc06..db8e1912 100644 --- a/keyserver/storage/sqlite3/cross_signing_sigs_table.go +++ b/keyserver/storage/sqlite3/cross_signing_sigs_table.go @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS keyserver_cross_signing_sigs ( signature TEXT NOT NULL ); -CREATE UNIQUE INDEX keyserver_cross_signing_sigs_idx ON keyserver_cross_signing_sigs(user_id, target_user_id, target_device_id); +CREATE UNIQUE INDEX IF NOT EXISTS keyserver_cross_signing_sigs_idx ON keyserver_cross_signing_sigs(user_id, target_user_id, target_device_id); ` type crossSigningSigsStatements struct {