From 5cdf938129f43670c84cb5f3e1b11cff0c7b4ff6 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Thu, 8 Jan 2026 13:09:04 +0100 Subject: [PATCH] Remove leftovers from the old email verification system --- ...030_remove_user_emails_old_confirmation.sql | 18 ++++++++++++++++++ ...f035e9a087ff27b06e804464a432d93e5a25f1.json | 17 ----------------- ...b099255155193dafbbd185cd8f26d93ff423a7.json | 17 +++++++++++++++++ crates/syn2mas/src/mas_writer/mod.rs | 13 +++++++------ .../syn2mas__mas_writer__test__write_user.snap | 1 - ...er__test__write_user_with_access_token.snap | 1 - ...s_writer__test__write_user_with_device.snap | 1 - ...as_writer__test__write_user_with_email.snap | 4 +--- ...writer__test__write_user_with_password.snap | 1 - ...r__test__write_user_with_refresh_token.snap | 1 - ...__write_user_with_unsupported_threepid.snap | 1 - ...write_user_with_upstream_provider_link.snap | 1 - 12 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 crates/storage-pg/migrations/20260108120030_remove_user_emails_old_confirmation.sql delete mode 100644 crates/syn2mas/.sqlx/query-08ad2855f0baaaed9d6af23c8bf035e9a087ff27b06e804464a432d93e5a25f1.json create mode 100644 crates/syn2mas/.sqlx/query-ebf68b70b3e22a04b57b5587b4b099255155193dafbbd185cd8f26d93ff423a7.json diff --git a/crates/storage-pg/migrations/20260108120030_remove_user_emails_old_confirmation.sql b/crates/storage-pg/migrations/20260108120030_remove_user_emails_old_confirmation.sql new file mode 100644 index 000000000..f5ba7a023 --- /dev/null +++ b/crates/storage-pg/migrations/20260108120030_remove_user_emails_old_confirmation.sql @@ -0,0 +1,18 @@ +-- Copyright 2026 Element Creations Ltd. +-- +-- SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +-- Please see LICENSE in the repository root for full details. + +-- We reworked how email verification works in +-- https://github.com/element-hq/matrix-authentication-service/pull/3784 +-- but kept some old schema around to allow rolling back. We're safe to drop +-- those now + +-- Users don't have a 'primary email' anymore +ALTER TABLE users DROP COLUMN primary_user_email_id; + +-- Replaced by user_email_authentications +DROP TABLE user_email_confirmation_codes; + +-- User emails are always confirmed when they are in this table now +ALTER TABLE user_emails DROP COLUMN confirmed_at; diff --git a/crates/syn2mas/.sqlx/query-08ad2855f0baaaed9d6af23c8bf035e9a087ff27b06e804464a432d93e5a25f1.json b/crates/syn2mas/.sqlx/query-08ad2855f0baaaed9d6af23c8bf035e9a087ff27b06e804464a432d93e5a25f1.json deleted file mode 100644 index 545389cb6..000000000 --- a/crates/syn2mas/.sqlx/query-08ad2855f0baaaed9d6af23c8bf035e9a087ff27b06e804464a432d93e5a25f1.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO syn2mas__user_emails\n (user_email_id, user_id, email, created_at, confirmed_at)\n SELECT * FROM UNNEST($1::UUID[], $2::UUID[], $3::TEXT[], $4::TIMESTAMP WITH TIME ZONE[], $4::TIMESTAMP WITH TIME ZONE[])\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "UuidArray", - "UuidArray", - "TextArray", - "TimestamptzArray" - ] - }, - "nullable": [] - }, - "hash": "08ad2855f0baaaed9d6af23c8bf035e9a087ff27b06e804464a432d93e5a25f1" -} diff --git a/crates/syn2mas/.sqlx/query-ebf68b70b3e22a04b57b5587b4b099255155193dafbbd185cd8f26d93ff423a7.json b/crates/syn2mas/.sqlx/query-ebf68b70b3e22a04b57b5587b4b099255155193dafbbd185cd8f26d93ff423a7.json new file mode 100644 index 000000000..12de563c0 --- /dev/null +++ b/crates/syn2mas/.sqlx/query-ebf68b70b3e22a04b57b5587b4b099255155193dafbbd185cd8f26d93ff423a7.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO syn2mas__user_emails\n (user_email_id, user_id, email, created_at)\n SELECT * FROM UNNEST($1::UUID[], $2::UUID[], $3::TEXT[], $4::TIMESTAMP WITH TIME ZONE[])\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "UuidArray", + "TextArray", + "TimestamptzArray" + ] + }, + "nullable": [] + }, + "hash": "ebf68b70b3e22a04b57b5587b4b099255155193dafbbd185cd8f26d93ff423a7" +} diff --git a/crates/syn2mas/src/mas_writer/mod.rs b/crates/syn2mas/src/mas_writer/mod.rs index 6d59ec4b9..bd42c14b1 100644 --- a/crates/syn2mas/src/mas_writer/mod.rs +++ b/crates/syn2mas/src/mas_writer/mod.rs @@ -406,19 +406,20 @@ impl WriteBatch for MasNewEmailThreepid { created_ats.push(created_at); } - // `confirmed_at` is going to get removed in a future MAS release, - // so just populate with `created_at` sqlx::query!( r#" - INSERT INTO syn2mas__user_emails - (user_email_id, user_id, email, created_at, confirmed_at) - SELECT * FROM UNNEST($1::UUID[], $2::UUID[], $3::TEXT[], $4::TIMESTAMP WITH TIME ZONE[], $4::TIMESTAMP WITH TIME ZONE[]) + INSERT INTO syn2mas__user_emails + (user_email_id, user_id, email, created_at) + SELECT * FROM UNNEST($1::UUID[], $2::UUID[], $3::TEXT[], $4::TIMESTAMP WITH TIME ZONE[]) "#, &user_email_ids[..], &user_ids[..], &emails[..], &created_ats[..], - ).execute(&mut *conn).await.into_database("writing emails to MAS")?; + ) + .execute(&mut *conn) + .await + .into_database("writing emails to MAS")?; Ok(()) } diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user.snap index 39a3a5011..76628de28 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user.snap @@ -8,6 +8,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_access_token.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_access_token.snap index 3dbb948ec..5f947e45f 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_access_token.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_access_token.snap @@ -26,6 +26,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_device.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_device.snap index 13cb9dc89..f21ba3789 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_device.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_device.snap @@ -20,6 +20,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_email.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_email.snap index e8b8a1e96..51da80060 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_email.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_email.snap @@ -3,8 +3,7 @@ source: crates/syn2mas/src/mas_writer/mod.rs expression: db_snapshot --- user_emails: - - confirmed_at: "1970-01-01 00:00:00+00" - created_at: "1970-01-01 00:00:00+00" + - created_at: "1970-01-01 00:00:00+00" email: alice@example.org user_email_id: 00000000-0000-0000-0000-000000000002 user_id: 00000000-0000-0000-0000-000000000001 @@ -14,6 +13,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_password.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_password.snap index 4b6e8696c..1966dd5c4 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_password.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_password.snap @@ -15,6 +15,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_refresh_token.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_refresh_token.snap index 80c52bd8c..893770400 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_refresh_token.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_refresh_token.snap @@ -33,6 +33,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_unsupported_threepid.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_unsupported_threepid.snap index c2e7a9e50..e81697c6b 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_unsupported_threepid.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_unsupported_threepid.snap @@ -13,6 +13,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice diff --git a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_upstream_provider_link.snap b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_upstream_provider_link.snap index adb6d4ee4..7b9173eb3 100644 --- a/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_upstream_provider_link.snap +++ b/crates/syn2mas/src/mas_writer/snapshots/syn2mas__mas_writer__test__write_user_with_upstream_provider_link.snap @@ -42,6 +42,5 @@ users: deactivated_at: ~ is_guest: "false" locked_at: ~ - primary_user_email_id: ~ user_id: 00000000-0000-0000-0000-000000000001 username: alice