From 4b71c7734b9c7729c2a1fabadf736a848cb1a8b1 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 26 Aug 2026 18:38:58 +0300 Subject: [PATCH] Migration to clear invalid custom urls --- ...26153531-clear-invalid-user-custom-urls.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 migrations/20260826153531-clear-invalid-user-custom-urls.ts diff --git a/migrations/20260826153531-clear-invalid-user-custom-urls.ts b/migrations/20260826153531-clear-invalid-user-custom-urls.ts new file mode 100644 index 000000000..62fce1656 --- /dev/null +++ b/migrations/20260826153531-clear-invalid-user-custom-urls.ts @@ -0,0 +1,21 @@ +import { type Kysely, sql } from "kysely"; + +/** + * Clears the custom URLs that predate the `/^[a-zA-Z0-9-_]+$/` rule the profile form + * enforces today, leaving those users linked by their Discord id instead. + * + * They are all from the pre-Kysely era and cannot be created any more, but they are not + * harmless leftovers: + * - a value containing `?` truncates the link at that character, so `/u/leo?????` is + * requested as `/u/leo` — a 404, or worse, a different user's profile. + * - the profile form prefills the field with the stored value, so these users cannot + * save any profile change at all without first picking a new custom URL. + */ +export async function up(db: Kysely): Promise { + await sql` + update "User" + set "customUrl" = null + where "customUrl" is not null + and "customUrl" glob '*[^a-zA-Z0-9_-]*' + `.execute(db); +}