-- Hand-written, like 0005, because drizzle-kit cannot express this safely. -- -- Two traps live in these three lines. -- -- First, `ALTER TYPE ... ADD VALUE` could not run inside a transaction block -- before Postgres 12, and the drizzle migrator wraps every migration in one. -- PIG targets Postgres 16, where it is permitted; what remains forbidden even -- on 16 is *using* the new value in the same transaction, so nothing here may -- reference 'viewer' — no backfill, no default change, no CHECK. Adding one -- later means its own migration. -- -- Second, `BEFORE 'member'` is not cosmetic. `viewer` outranks nobody, and the -- enum's sort order is what `ORDER BY role` and any future comparison would -- use. Appending it to the end would silently make the least privileged role -- sort as the most senior. ALTER TYPE "public"."pig_team_role" ADD VALUE IF NOT EXISTS 'viewer' BEFORE 'member';