Catalyst / admin/Synapse-Sonar 14.8 GB / 57.8 GB 40.0 GB free
Help Sign in

admin / Synapse-Sonar

public

Attack Surface Simulation

Code Issues Pull requests Pipelines Packages Security Insights Wiki Settings
Synapse-Sonar / synapse-sonar / prisma / migrations / 20260629020000_user_username / migration.sql 716 B · main
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
-- Switch login identity from per-tenant email to a global username.

-- 1. Add username (nullable first so existing rows can be backfilled)
ALTER TABLE "users" ADD COLUMN "username" TEXT;

-- 2. Backfill existing rows from email (dev data); fall back to id if needed
UPDATE "users" SET "username" = COALESCE("email", "id") WHERE "username" IS NULL;

-- 3. Email is now optional metadata
ALTER TABLE "users" ALTER COLUMN "email" DROP NOT NULL;

-- 4. Drop the old per-tenant email uniqueness
DROP INDEX IF EXISTS "users_tenantId_email_key";

-- 5. Enforce username: NOT NULL + globally unique
ALTER TABLE "users" ALTER COLUMN "username" SET NOT NULL;
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");