| name | project-mtp-postgres-ltree | ||
|---|---|---|---|
| description | Multi-Tenant Platform repo uses PostgreSQL 17+ exclusively and uses ltree extension for hierarchical data. | ||
| metadata |
|
For the multi-tenant-platform repo at D:\Projects\mtp\mtp-docs (GitHub: paramhq/mtp-docs):
Why: User stated explicitly: "we will be using postgres v17 or later only in this, we will also use ltree for hierarchical data". Treat as hard architectural constraint.
How to apply:
- PostgreSQL 17+ only. No SQL Server, no other RDBMS suggestions in this repo's docs/code.
- Use Postgres-specific features freely:
jsonb,gen_random_uuid(), native JSON path operators (->,->>,@?,@@), partial indexes, generated columns, range types. - Hierarchical data via
ltreeextension (path-as-string with.separators, GiST indexes for ancestor/descendant queries).
- All SQL Server-flavored guidance must be revised:
NVARCHAR(MAX)→textorjsonb- JSON column →
jsonb(not stringly-typednvarchar) JSON_VALUE(col, '$.path')→col -> 'key'(jsonb) orcol ->> 'key'(text)- Computed columns + indexed JSON_VALUE → GIN indexes on jsonb or expression indexes
uniqueidentifier→uuidRAISERROR(..., 16, 1)(state 50000+) →RAISE EXCEPTION USING ERRCODE = '...'or domain-specific SQLSTATEOPENJSONshredding →jsonb_to_recordset/jsonb_array_elements
- SP-message i18n migration plan (page 08) needs Postgres ERRCODE strategy instead of state-number mapping.
- Page 09 ExtensionData column =
jsonb, indexable via GIN or expression indexes — no need for persisted computed columns.
- Account/cost-centre hierarchies
- Org chart / role hierarchy
- Permissions tree
- Class/section/student hierarchies in school ERP scenarios
- Category trees, menu hierarchies, location/region trees
- This repo's stack note must explicitly call out Postgres 17 + ltree, not "SQL Server".
- ORM: assume EF Core 9 with Npgsql provider, or Dapper with Npgsql, or both.
- Connection string keys: Postgres style.
Related: pairs with [[project-gnschoolerp-api-conventions]] which still uses SQL Server — those conventions do NOT carry over to the multi-tenant-platform repo.