Last deployment:

Turfi Platform Documentation

Official Turfi documentation portal for users, admins, and developers.

Back to support

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

columntypenullabledefaultnotes
age_group_idstring \nullyesnullRelationship-bearing column.
age_group_lookup_idstring \nullyesnullRelationship-bearing column.
competition_format_idstringnononeRelationship-bearing column.
competition_format_lookup_idstring \nullyesnullRelationship-bearing column.
competition_type_idstringnononeRelationship-bearing column.
competition_type_lookup_idstring \nullyesnullRelationship-bearing column.
created_atstringnodatabase default or generatedBase table field.
end_datestring \nullyesnullBase table field.
gender_idstring \nullyesnullRelationship-bearing column.
gender_lookup_idstring \nullyesnullRelationship-bearing column.
idstringnogenerated UUID defaultBase table field.
keystringnononeBase table field.
league_idstring \nullyesnullRelationship-bearing column.
namestringnononeBase table field.
organization_idstringnononeRelationship-bearing column.
points_drawnumbernodatabase default or generatedBase table field.
points_lossnumbernodatabase default or generatedBase table field.
points_winnumbernodatabase default or generatedBase table field.
season_idstring \nullyesnullRelationship-bearing column.
slugstring \nullyesnullBase table field.
start_datestring \nullyesnullBase table field.
statusstring \nullyesnullLifecycle field when present.
tie_breaker_orderstring[]nodatabase default or generatedBase table field.
updated_atstring \nullyesnullBase table field.

Foreign Keys

columnreferencestableon delete
age_group_ididage_groupsNO ACTION
competition_format_ididcompetition_formatsNO ACTION
competition_type_ididcompetition_typesNO ACTION
gender_ididgendersNO ACTION
league_ididleaguesNO ACTION
organization_ididorganizationsNO ACTION
season_ididseasonsNO 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)

namepurpose
v_competitionsCurated admin registry read model for competitions.

3. Import Contract

Accepted Columns

  • key
  • name
  • slug
  • status
  • organization_key
  • organization
  • organization_id
  • league_key
  • league
  • league_id
  • season_key
  • season
  • season_id
  • age_group_key
  • age_group
  • age_group_id
  • gender_key
  • gender
  • gender_id
  • competition_type_key
  • competition_type
  • competition_type_id
  • type
  • competition_format_key
  • competition_format
  • competition_format_id
  • format
  • start_date
  • end_date
  • points_win
  • points_draw
  • points_loss
  • tie_breaker_order

Resolution Rules

  • *_key relationship inputs resolve on target key columns first.
  • Non-suffixed relationship inputs resolve by key, then slug, then name.
  • 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

  • key
  • slug
  • status
  • organization_key
  • organization
  • organization_id
  • league_key
  • league
  • league_id
  • season_key
  • season
  • season_id
  • age_group_key
  • age_group
  • age_group_id
  • gender_key
  • gender
  • gender_id
  • competition_type_key
  • competition_type
  • competition_type_id
  • type
  • competition_format_key
  • competition_format
  • competition_format_id
  • format
  • start_date
  • end_date
  • points_win
  • points_draw
  • points_loss
  • tie_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

labelfieldsource
Namenamev_competitions.name / competitions.name
Start Datestart_datecompetitions.start_date
End Dateend_datecompetitions.end_date
Age Groupage_group_keyv_competitions.age_group / age_groups
Gendergender_keyv_competitions.gender / genders
Competition Typecompetition_type_keyv_competitions.competition_type / competition_types
Competition Formatcompetition_format_keyv_competitions.competition_format / competition_formats
Statusstatuscompetitions.status
Seasonseason_nameseasons.name
Leagueleague_nameleagues.name
Organizationorganization_nameorganizations.name

Filters

filterfieldtype
Searchnametext substring
Organizationorganization_idselect
Seasonseason_idselect
Leagueleague_idselect
Age Groupage_group_idlookup select
Gendergender_idlookup select
Typecompetition_type_idlookup select
Formatcompetition_format_idlookup select
Statusstatusselect

Display Logic

  • Organization, league, and season display as resolved names, never raw ids.
  • Age-group keys like u13 are normalized for display as U13.
  • 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.