From a39e1d3d1994c19161edf363b0f59d5ab4030dbc Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 15 Jan 2025 17:08:15 +0100 Subject: [PATCH] Cleanup the unverified emails from the database --- .../20250115155255_cleanup_unverified_emails.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 crates/storage-pg/migrations/20250115155255_cleanup_unverified_emails.sql diff --git a/crates/storage-pg/migrations/20250115155255_cleanup_unverified_emails.sql b/crates/storage-pg/migrations/20250115155255_cleanup_unverified_emails.sql new file mode 100644 index 000000000..bc3c834e6 --- /dev/null +++ b/crates/storage-pg/migrations/20250115155255_cleanup_unverified_emails.sql @@ -0,0 +1,14 @@ +-- Copyright 2025 New Vector Ltd. +-- +-- SPDX-License-Identifier: AGPL-3.0-only +-- Please see LICENSE in the repository root for full details. + +-- This drops all the unverified email addresses from the database, as they are +-- now always verified when they land in the user_emails table. +-- We don't drop the `confirmed_at` column to allow rolling back + +-- First, truncate all the confirmation codes +TRUNCATE TABLE email_confirmation_codes; + +-- Then, delete all the unverified email addresses +DELETE FROM user_emails WHERE confirmed_at IS NULL;