Skip to content

iso_codes

ISO country code enum/data types for PostgreSQL, generated with pgrx.

emi_monorepo · ISO country code enum/data types for PostgreSQL, generated with pgrx.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100809iso_codesemi_monorepo0.1.0TYPEGPL-3.0Rust

PostgreSQL · 13, 14, 15, 16, 17

Usage

Sources:

iso_codes adds the CountryCode PostgreSQL enum containing the extension build’s two-letter country-code set. Use it when a column must be constrained to that fixed vocabulary rather than arbitrary text.

Core Workflow

CREATE EXTENSION iso_codes;

CREATE TABLE offices (
    name text NOT NULL,
    country CountryCode NOT NULL
);

INSERT INTO offices VALUES ('New York', 'US'), ('Berlin', 'DE');
SELECT * FROM offices WHERE country = 'US'::CountryCode;

Values outside the enum are rejected. The generated 0.1.0 SQL includes the country-code labels compiled into that release, including XK.

SQL Objects

  • CountryCode is the only user-facing SQL object in the reviewed generated SQL.
  • Enum ordering follows the declaration order in the generated artifact; do not assume that ordering represents geography or business priority.

Operational Notes

Version 0.1.0 is non-relocatable. Its control file sets superuser = true and trusted = false, so creation requires a superuser; it declares no prerequisite extension or preload requirement. Because PostgreSQL enum membership is fixed in the installed SQL, review release diffs before relying on newly assigned or changed codes.

Table reader