Add Democratic fundraising platform.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
26
prisma/migrations/20260515210000_user_username/migration.sql
Normal file
26
prisma/migrations/20260515210000_user_username/migration.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Add optional username column, backfill, then constrain.
|
||||
ALTER TABLE "User" ADD COLUMN "username" TEXT;
|
||||
|
||||
UPDATE "User"
|
||||
SET "username" =
|
||||
LEFT(
|
||||
COALESCE(
|
||||
NULLIF(
|
||||
regexp_replace(
|
||||
lower(trim(split_part("email", '@', 1))),
|
||||
'[^a-z0-9_]',
|
||||
'_',
|
||||
'g'
|
||||
),
|
||||
''
|
||||
),
|
||||
'supporter'
|
||||
),
|
||||
23
|
||||
)
|
||||
|| '_'
|
||||
|| right(replace("id", '-', ''), 8);
|
||||
|
||||
ALTER TABLE "User" ALTER COLUMN "username" SET NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User" ("username");
|
||||
Reference in New Issue
Block a user