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, NIS currency, Israeli timezones, Supabase integration, and common Israeli data types.
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). You usually need both, on different columns or via separate indexes, because a non-deterministic collation cannot back aUNIQUEconstraint or a plainbtreeindex. - 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). Combineunaccentwhen you need nikud-insensitive matching. - 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.
Hebrew Text Indexing
ICU Collation for Hebrew
PostgreSQL supports ICU collations for proper Hebrew text sorting. Always create a Hebrew collation for columns that store Hebrew text: