-- `uses_remaining` moves from jsonb to integer so it can be decremented in SQL. -- -- Postgres has no implicit jsonb -> integer cast, so the USING clause is -- written by hand. Drizzle generated a bare ALTER, which fails with -- "column cannot be cast automatically". Going via text is the documented -- route; COALESCE covers rows where the value is JSON null. ALTER TABLE "invites" ALTER COLUMN "uses_remaining" DROP DEFAULT;--> statement-breakpoint ALTER TABLE "invites" ALTER COLUMN "uses_remaining" SET DATA TYPE integer USING COALESCE(NULLIF("uses_remaining"::text, 'null')::integer, 1);--> statement-breakpoint ALTER TABLE "invites" ALTER COLUMN "uses_remaining" SET DEFAULT 1;--> statement-breakpoint ALTER TABLE "invites" ADD COLUMN "scope_note" text;