fix(db): preserve OAuth user verified status during migration

Update emailVerified type conversion to set OAuth users (those with
account records) as verified before converting timestamp to boolean.
This commit is contained in:
2026-04-06 23:16:58 -04:00
parent afb27eb66d
commit 2a808f8ca1

View File

@@ -13,6 +13,8 @@ ALTER TABLE "account" RENAME COLUMN "expires_at" TO "accessTokenExpiresAt";--> s
ALTER TABLE "account" RENAME COLUMN "id_token" TO "idToken";--> statement-breakpoint
ALTER TABLE "verification" DROP CONSTRAINT "verificationToken_identifier_token_pk";--> statement-breakpoint
ALTER TABLE "account" DROP CONSTRAINT "account_provider_providerAccountId_pk";--> statement-breakpoint
-- Mark OAuth users as verified before type conversion
UPDATE "user" SET "emailVerified" = NOW() WHERE "emailVerified" IS NULL AND id IN (SELECT "userId" FROM account);
ALTER TABLE "user" ALTER COLUMN "emailVerified" SET DATA TYPE boolean USING ("emailVerified" IS NOT NULL);--> statement-breakpoint
ALTER TABLE "session" DROP CONSTRAINT "session_pkey";--> statement-breakpoint
ALTER TABLE "session" ADD COLUMN "id" text PRIMARY KEY NOT NULL DEFAULT gen_random_uuid();--> statement-breakpoint