israeli-postgres-toolkit
Installation
SKILL.md
Israeli Postgres Toolkit
Best practices, patterns, and scripts for building PostgreSQL databases tailored to Israeli applications. Covers Hebrew text handling, shekel currency, Israeli timezones, Supabase integration, and common Israeli data types.
Assumes PostgreSQL 13+ (the patterns use gen_random_uuid() from core, non-deterministic ICU collations need 12+, and generated columns need 12+). Current stable is PostgreSQL 18.
Instructions
Follow this workflow when setting up or reviewing a PostgreSQL database for an Israeli app:
- Verify encoding and timezone first. Run
SHOW server_encoding;(must beUTF8, neverSQL_ASCIIorLATIN1) andSHOW timezone;. Set the database timezone withALTER DATABASE your_db SET timezone = 'Asia/Jerusalem';. Getting these wrong corrupts Hebrew and offsets every timestamp, and fixing it later means a data migration. - Pick the collation strategy. Decide per column whether you need Hebrew display ordering (non-deterministic ICU collation
he-IL-x-icu) or uniqueness/btreeindexing (deterministic collation). A non-deterministic collation does supportUNIQUEconstraints andbtreeindexes (verified on PostgreSQL 17), but it cannot be used withLIKE/pattern matching, so keep a deterministic column or expression around for prefix search. - Choose the search approach. For exact and prefix matching use
btree. For fuzzy/typo-tolerant Hebrew search usepg_trgm. For multi-field ranked search use full-text search with thesimpleconfiguration (see "Full-Text Search with Hebrew" below). For nikud-insensitive Hebrew matching use thestrip_nikud()function shown below;unaccentonly strips Latin diacritics, not Hebrew nikud. - Apply Israeli data-type constraints. Use the
CHECKconstraints and helper functions fromscripts/israeli-data-types.sql(teudat zehut, phone, postal code, business number, IBAN) and callvalidate_teudat_zehut()for the ID check digit rather than reimplementing it in application code.