Turfi Platform Documentation
Official Turfi documentation portal for users, admins, and developers.
Documentation Search
Search only within Turfi documentation pages.
C
Competitions
Competition registry contract.
Entity: Competitions
1. Overview
- Competition registry joining governance, seasonal context, league context, participant classification, and standings behavior.
- Belongs to an organization and season.
- May belong to a league.
- Uses age group, gender, competition type, and competition format lookups.
- Owns team registrations through
team_competitions. - Visible at
/admin/data/registries/competitions.
2. Database Schema
Columns
| column | type | nullable | default | notes | |
|---|---|---|---|---|---|
| age_group_id | string \ | null | yes | null | Relationship-bearing column. |
| age_group_lookup_id | string \ | null | yes | null | Relationship-bearing column. |
| competition_format_id | string | no | none | Relationship-bearing column. | |
| competition_format_lookup_id | string \ | null | yes | null | Relationship-bearing column. |
| competition_type_id | string | no | none | Relationship-bearing column. | |
| competition_type_lookup_id | string \ | null | yes | null | Relationship-bearing column. |
| created_at | string | no | database default or generated | Base table field. | |
| end_date | string \ | null | yes | null | Base table field. |
| gender_id | string \ | null | yes | null | Relationship-bearing column. |
| gender_lookup_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_id | string \ | null | yes | null | Relationship-bearing column. |
| name | string | no | none | Base table field. | |
| organization_id | string | no | none | Relationship-bearing column. | |
| points_draw | number | no | database default or generated | Base table field. | |
| points_loss | number | no | database default or generated | Base table field. | |
| points_win | number | no | database default or generated | Base table field. | |
| season_id | string \ | null | yes | null | Relationship-bearing column. |
| slug | string \ | null | yes | null | Base table field. |
| start_date | string \ | null | yes | null | Base table field. |
| status | string \ | null | yes | null | Lifecycle field when present. |
| tie_breaker_order | string[] | no | database default or generated | Base table field. | |
| updated_at | string \ | null | yes | null | Base table field. |
Foreign Keys
| column | references | table | on delete |
|---|---|---|---|
| age_group_id | id | age_groups | NO ACTION |
| competition_format_id | id | competition_formats | NO ACTION |
| competition_type_id | id | competition_types | NO ACTION |
| gender_id | id | genders | NO ACTION |
| league_id | id | leagues | NO ACTION |
| organization_id | id | organizations | NO ACTION |
| season_id | id | seasons | 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_competitions | Curated admin registry read model for competitions. |
3. Import Contract
Accepted Columns
keynameslugstatusorganization_keyorganizationorganization_idleague_keyleagueleague_idseason_keyseasonseason_idage_group_keyage_groupage_group_idgender_keygendergender_idcompetition_type_keycompetition_typecompetition_type_idtypecompetition_format_keycompetition_formatcompetition_format_idformatstart_dateend_datepoints_winpoints_drawpoints_losstie_breaker_order
Resolution Rules
*_keyrelationship inputs resolve on targetkeycolumns first.- Non-suffixed relationship inputs resolve by
key, thenslug, thenname. - Competition organization, league, and season are fail-fast relationships in the import engine and must not silently persist as null.
- Type, format, age group, and gender are lookup-backed and normalized before base table writes.
Required Fields
name
Optional Fields
keyslugstatusorganization_keyorganizationorganization_idleague_keyleagueleague_idseason_keyseasonseason_idage_group_keyage_groupage_group_idgender_keygendergender_idcompetition_type_keycompetition_typecompetition_type_idtypecompetition_format_keycompetition_formatcompetition_format_idformatstart_dateend_datepoints_winpoints_drawpoints_losstie_breaker_order
Failure Rules
- Organization, league, and season fail hard when unresolved.
- Invalid lookup values for type, format, gender, or age group go through mismatch handling before hitting database checks.
- Status values not in the allowed lifecycle set fail validation; they do not auto-map silently.
4. Frontend Registry Mapping
Grid Columns
| label | field | source |
|---|---|---|
| Name | name | v_competitions.name / competitions.name |
| Start Date | start_date | competitions.start_date |
| End Date | end_date | competitions.end_date |
| Age Group | age_group_key | v_competitions.age_group / age_groups |
| Gender | gender_key | v_competitions.gender / genders |
| Competition Type | competition_type_key | v_competitions.competition_type / competition_types |
| Competition Format | competition_format_key | v_competitions.competition_format / competition_formats |
| Status | status | competitions.status |
| Season | season_name | seasons.name |
| League | league_name | leagues.name |
| Organization | organization_name | organizations.name |
Filters
| filter | field | type |
|---|---|---|
| Search | name | text substring |
| Organization | organization_id | select |
| Season | season_id | select |
| League | league_id | select |
| Age Group | age_group_id | lookup select |
| Gender | gender_id | lookup select |
| Type | competition_type_id | lookup select |
| Format | competition_format_id | lookup select |
| Status | status | select |
Display Logic
- Organization, league, and season display as resolved names, never raw ids.
- Age-group keys like
u13are normalized for display asU13. - Lookup-based type and format filters convert keys to lookup ids before fallback table queries.
5. Lifecycle Rules
- Competition status is lifecycle-critical and explicitly constrained; see the schema constraints section.
- Standings behavior and registration validity depend on competition type, format, and official score triggers.
- Delete should be considered high-risk because games, standings, and team registrations depend on competition identity.