Turfi Platform Documentation
Official Turfi documentation portal for users, admins, and developers.
Documentation Search
Search only within Turfi documentation pages.
C
Leagues
League registry contract.
Entity: Leagues
1. Overview
- League registry linking governance organizations, lifecycle state, and lookup-backed competition context used by imports and admin tools.
- Belongs to an organization.
- May carry gender and league-type lookup assignments.
- Provides an optional parent for competitions.
- Visible at
/admin/data/registries/leagues.
2. Database Schema
Columns
| column | type | nullable | default | notes | |
|---|---|---|---|---|---|
| address_id | string \ | null | yes | null | Relationship-bearing column. |
| created_at | string \ | null | yes | null | Base table field. |
| string \ | null | yes | null | Base table field. | |
| gender_id | string \ | null | yes | null | Relationship-bearing column. |
| id | string | no | generated UUID default | Base table field. | |
| key | string | no | none | Base table field. | |
| league_type_id | string \ | null | yes | null | Relationship-bearing column. |
| name | string | no | none | Base table field. | |
| normalized_name | string \ | null | yes | null | Base table field. |
| organization_id | string \ | null | yes | null | Relationship-bearing column. |
| phone | string \ | null | yes | null | Base table field. |
| province | string \ | null | yes | null | Base table field. |
| slug | string \ | null | yes | null | Base table field. |
| status | string | no | database default or generated | Lifecycle field when present. | |
| updated_at | string \ | null | yes | null | Base table field. |
| website | string \ | null | yes | null | Base table field. |
Foreign Keys
| column | references | table | on delete |
|---|---|---|---|
| address_id | id | addresses | NO ACTION |
| gender_id | id | genders | NO ACTION |
| league_type_id | id | league_types | NO ACTION |
| organization_id | id | organizations | NO ACTION |
Indexes
No migration-defined indexes were discovered in the checked-in SQL history for this table.
Constraints
- Unique: none discovered in checked-in migrations.
- Check: none discovered in checked-in migrations.
Triggers
No migration-defined triggers were discovered in the checked-in SQL history for this table.
Views (if any)
| name | purpose |
|---|---|
| v_leagues | Curated admin registry read model for leagues. |
3. Import Contract
Accepted Columns
keynameslugstatusorganization_keyorganizationorganization_idleague_type_keyleague_typeleague_type_idgender_keygendergender_idaddress_line1address_line2cityprovincepostal_codecountryphoneemailwebsite
Resolution Rules
organization_key,league_type_key, andgender_keyresolve on the target tablekeycolumn first.- Non-suffixed relationship fields resolve by
key, thenslug, thenname. - Lookup-backed values are normalized to their lookup ids before writes when the CSV uses keys or labels.
Required Fields
name
Optional Fields
keyslugstatusorganization_keyorganizationorganization_idleague_type_keyleague_typeleague_type_idgender_keygendergender_idaddress_line1address_line2cityprovincepostal_codecountryphoneemailwebsite
Failure Rules
- Missing
namefails immediately. - Organization mismatches pause or fail depending on import execution context because leagues cannot safely persist with the wrong parent.
- Lookup mismatches are expected to go through mismatch handling before database validation.
4. Frontend Registry Mapping
Grid Columns
| label | field | source |
|---|---|---|
| Name | name | v_leagues.name / leagues.name |
| League Type | league_type_key | v_leagues.league_type / league_types |
| Gender | gender_key | v_leagues.gender / genders |
| Address | address | v_leagues.address / addresses |
| City | city | v_leagues.city / addresses.city |
| Province | province | v_leagues.province / addresses.province |
| Phone | phone | leagues.phone |
| leagues.email | ||
| Website | website | leagues.website |
| Status | status | leagues.status |
| Organization | organization_name | organizations.name |
Filters
| filter | field | type |
|---|---|---|
| Search | name, normalized_name, organization_name, city, province, phone, email, website | text substring |
| Organization | organization_id | select |
| League Type | league_type_id | lookup select |
| Gender | gender_id | lookup select |
| Province | province | text / distinct select |
| Status | status | select |
Display Logic
- League type and gender are rendered from lookup labels, not raw UUIDs.
- Organization is displayed by resolved organization name.
- Address attributes are flattened from the linked shared address relationship.
5. Lifecycle Rules
- League lifecycle is status-driven when the base table exposes a
statusconstraint. - Updates must preserve organization alignment because downstream competitions inherit league context.
- Delete behavior should be treated as governed by dependent competition relationships even if not all deletes are UI-blocked.