Skip to content

Document and constrain places.rank to valid values #56

@koinsaari

Description

@koinsaari

Summary

The places.rank column accepts any INTEGER. It should be constrained to the documented set of valid ranks and its semantics should be explained in code or schema comments.

Context

The ingestion-service writes rank values to the places table to indicate place importance (used downstream for map zoom-level visibility and result ordering). Both ingestion-service and any future writers need to agree on the value set. Today the contract is implicit.

The agreed semantics are:

  • 1 — most important (e.g. hospitals, universities, transport stations)
  • 2 — standard establishments (restaurants, shops, etc.)
  • 3 — minor features (toilets, ATMs, shelters)

Scope

  • Add a CHECK (rank IN (1, 2, 3)) constraint to places.rank via a new migration
  • Add a COMMENT ON COLUMN places.rank describing the value semantics
  • Update any relevant API/handler documentation that mentions rank

Acceptance criteria

  • Migration adds CHECK constraint allowing only 1, 2, 3 (and NULL if appropriate)
  • Column comment documents the meaning of each rank value
  • Existing rows (if any) pass the constraint or are migrated to a valid value
  • Down migration removes the constraint cleanly

Notes

Open question: should rank be NOT NULL, or is NULL meaningful for places that have no defined importance? Decide before writing the constraint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dbDatabase layer / migrationsenhancementNew feature or requestpriority:shouldShould-have, rough edges

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions