Collations

COLLATION declarations with provider, locale, and determinism.

ICU collation (non-deterministic)

Non-deterministic collations allow case-insensitive and accent-insensitive comparisons.

SCHEMA public {
    COLLATION case_insensitive (
        PROVIDER      = icu,
        LOCALE        = 'und-u-ks-level2',
        DETERMINISTIC = false
    );
}
-- emits
CREATE COLLATION "public"."case_insensitive" (
    PROVIDER      = icu,
    LOCALE        = 'und-u-ks-level2',
    DETERMINISTIC = false
);

Standard libc collation

SCHEMA public {
    COLLATION custom_en (
        PROVIDER = libc,
        LOCALE   = 'en_US.UTF-8'
    );
}
-- emits
CREATE COLLATION "public"."custom_en" (
    PROVIDER = libc,
    LOCALE   = 'en_US.UTF-8'
);

Collation copy

SCHEMA public {
    COLLATION my_collation (COPY = pg_catalog."default");
}
-- emits
CREATE COLLATION "public"."my_collation" (COPY = pg_catalog."default");

Diffing behaviour

ChangeSQLSafety
Owner changedALTER COLLATION OWNER TOSAFE
Renamed (RENAMED FROM)ALTER COLLATION RENAME TO (+ SET SCHEMA if schema-qualified)CAUTION
REFRESH VERSION present in sourceALTER COLLATION REFRESH VERSION (re-emitted every apply while present)CAUTION
Any other property change (LOCALE/PROVIDER/RULES/FROM target/etc.)DROP COLLATION + CREATE COLLATIONDESTRUCTIVE

Columns using the collation must be re-indexed after a drop-and-recreate.