mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-07 19:55:46 -05:00
Migration to clear invalid custom urls
This commit is contained in:
21
migrations/20260826153531-clear-invalid-user-custom-urls.ts
Normal file
21
migrations/20260826153531-clear-invalid-user-custom-urls.ts
Normal file
@@ -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<any>): Promise<void> {
|
||||
await sql`
|
||||
update "User"
|
||||
set "customUrl" = null
|
||||
where "customUrl" is not null
|
||||
and "customUrl" glob '*[^a-zA-Z0-9_-]*'
|
||||
`.execute(db);
|
||||
}
|
||||
Reference in New Issue
Block a user