Extends public.language_code with the Euskera (Basque, ISO 639-1) label. Plan §20.1 was written against a CHECK-constraint mental model; the actual gate is the ENUM from migration 001, so the right primitive is ALTER TYPE … ADD VALUE. End-user contract is identical — 'eu' accepted, 'fr' rejected — and rejection surfaces as the canonical 22P02 invalid_text_representation error. pgTAP `supabase/tests/020_users_language_eu.sql` (5 assertions, LANG-EU- T01..T05) pins both ends: ENUM membership and UPDATE round-trip on Ana. Hand-curated database.ts widened to `'en' | 'es' | 'eu'`. The supabase CLI isn't on this host, so db-types regen is the manual edit per the recipe's fallback path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
22 lines
1.1 KiB
SQL
22 lines
1.1 KiB
SQL
-- Migration 028: add Euskera (Basque, ISO 639-1 `eu`) to the supported
|
|
-- `public.language_code` ENUM (Fase 20).
|
|
--
|
|
-- The plan (`plan/fase-20-euskera-locale.md` §20.1) was written against the
|
|
-- assumption that `public.users.language` is gated by a CHECK constraint.
|
|
-- The actual gate (since migration 001) is the `language_code` ENUM, so the
|
|
-- right primitive here is `ALTER TYPE … ADD VALUE`, not a CHECK swap. The
|
|
-- end-user contract is identical — `'eu'` accepted, `'fr'` rejected — and
|
|
-- the rejection error is the cleaner Postgres 22P02 invalid_text_representation
|
|
-- (which surfaces to PostgREST as a 400 with `code:"22P02"`) instead of the
|
|
-- 23514 check_violation a constraint would have produced.
|
|
--
|
|
-- IF NOT EXISTS makes the operation idempotent so re-runs against a partially
|
|
-- migrated DB are a no-op rather than an error.
|
|
--
|
|
-- ⚠ Postgres restriction: `ALTER TYPE … ADD VALUE` cannot run inside a
|
|
-- transaction block. The migration runner applies each .sql file
|
|
-- atomically per-file, so the statement must stand alone. Do NOT wrap it
|
|
-- in BEGIN/COMMIT.
|
|
|
|
ALTER TYPE public.language_code ADD VALUE IF NOT EXISTS 'eu';
|