-- Add invite_code column without NOT NULL constraint first ALTER TABLE "seasons" ADD COLUMN "invite_code" varchar(20);--> statement-breakpoint -- Generate unique invite codes for existing seasons using UUID -- Takes first 10 characters of UUID without dashes for a short, unique code UPDATE "seasons" SET "invite_code" = substring(replace(gen_random_uuid()::text, '-', ''), 1, 10) WHERE "invite_code" IS NULL;--> statement-breakpoint -- Now make it NOT NULL and add unique constraint ALTER TABLE "seasons" ALTER COLUMN "invite_code" SET NOT NULL;--> statement-breakpoint ALTER TABLE "seasons" ADD CONSTRAINT "seasons_invite_code_unique" UNIQUE("invite_code");