fix(tours): keep the shipped ski migrations and follow the ski tour through

The winter label and four-discipline migrations are already on
feat/tours-board-rest, so a database that ran them would refuse to boot
or fail the old CHECK. 045500, 045520 and 046100 are back as they
shipped, and a new migration drops both winter_activity columns and
adds ski_discipline again with the six disciplines. The entity and
table types follow the column to its new place.

German, Hungarian, Indonesian and English no longer name the whole type
with the ski touring word, and the info dot speaks of ski tours and
tracks. search_tour_pois and its wiki row list rides and ski and winter
tours. Snowshoeing gets a snowshoe glyph instead of the walk's
footprints, a ski import without a discipline can be planned over (the
planner asks for it), and an overlay shown by default tries its tiles
afresh each time it comes on.
This commit is contained in:
Maurice
2026-10-20 18:39:04 +02:00
parent 164a3633ac
commit be6702f3ab
48 changed files with 273 additions and 84 deletions
+10 -10
View File
@@ -46,10 +46,10 @@ export class Tours {
bike_profile?: TToursBikeProfile | null;
run_profile?: TToursRunProfile | null;
run_pace_seconds_per_km?: number | null;
ski_discipline?: TToursSkiDiscipline | null;
ski_technique?: TToursSkiTechnique | null;
track_started_at?: string | null;
track_ended_at?: string | null;
ski_discipline?: TToursSkiDiscipline | null;
tourTypeRef!: Ref<TourTypes>;
tour_activities_collection = new Collection<TourActivities>(this);
tour_activities_collection1 = new Collection<TourActivities>(this);
@@ -108,6 +108,14 @@ export const ToursRunProfile = {
export type TToursRunProfile = (typeof ToursRunProfile)[keyof typeof ToursRunProfile];
export const ToursSkiTechnique = {
CLASSIC: 'classic',
SKATING: 'skating',
UNKNOWN: 'unknown',
} as const;
export type TToursSkiTechnique = (typeof ToursSkiTechnique)[keyof typeof ToursSkiTechnique];
export const ToursSkiDiscipline = {
ALPINE: 'alpine',
SNOWBOARD: 'snowboard',
@@ -119,14 +127,6 @@ export const ToursSkiDiscipline = {
export type TToursSkiDiscipline = (typeof ToursSkiDiscipline)[keyof typeof ToursSkiDiscipline];
export const ToursSkiTechnique = {
CLASSIC: 'classic',
SKATING: 'skating',
UNKNOWN: 'unknown',
} as const;
export type TToursSkiTechnique = (typeof ToursSkiTechnique)[keyof typeof ToursSkiTechnique];
export const ToursSchema = defineEntity({
class: Tours,
repository: () => ToursRepository,
@@ -177,10 +177,10 @@ export const ToursSchema = defineEntity({
bike_profile: p.enum(() => ToursBikeProfile).nullable(),
run_profile: p.enum(() => ToursRunProfile).nullable(),
run_pace_seconds_per_km: p.integer().nullable(),
ski_discipline: p.enum(() => ToursSkiDiscipline).nullable(),
ski_technique: p.enum(() => ToursSkiTechnique).nullable(),
track_started_at: p.type(DbTimestampType).nullable(),
track_ended_at: p.type(DbTimestampType).nullable(),
ski_discipline: p.enum(() => ToursSkiDiscipline).nullable(),
tourTypeRef: () => p.manyToOne(TourTypes).ref().joinColumn('tour_type').hidden().index('idx_tours_tour_type'),
tour_activities_collection: () => p.oneToMany(TourActivities).mappedBy('place').hidden(),
tour_activities_collection1: () => p.oneToMany(TourActivities).mappedBy('trackPlace').hidden(),
+1 -1
View File
@@ -33,8 +33,8 @@ export interface ToursTable {
bike_profile: InsertOptional<string | null>;
run_profile: InsertOptional<string | null>;
run_pace_seconds_per_km: InsertOptional<number | null>;
ski_discipline: InsertOptional<string | null>;
ski_technique: InsertOptional<string | null>;
track_started_at: InsertOptional<string | null>;
track_ended_at: InsertOptional<string | null>;
ski_discipline: InsertOptional<string | null>;
}
@@ -0,0 +1,16 @@
import { Migration } from '@mikro-orm/migrations';
/**
* HIK-01: a hike can carry a winter label, winter hiking or snowshoeing. It
* is a column of the tour, NULL on every tour saved before and on every other
* type, so no existing tour changes, and nothing routes or times by it.
*/
export class Migration20200101045500_a_hike_can_be_marked_as_a_winter_activity extends Migration {
override name = 'Migration20200101045500_a_hike_can_be_marked_as_a_winter_activity';
override up(): void {
this.addSql(
"ALTER TABLE tours ADD COLUMN winter_activity TEXT CHECK (winter_activity IS NULL OR winter_activity IN ('winter_hike', 'snowshoe'))",
);
}
}
@@ -1,21 +1,19 @@
import { Migration } from '@mikro-orm/migrations';
/**
* SKI-02: a tour can be a ski and winter tour, planned in the planner or
* imported from a GPX file. The `ski` key has been in `tour_types`, disabled
* and without a routing profile, since every contract type was seeded; it is
* switched on here and keeps no routing profile: the planner draws its legs
* itself. The discipline (alpine, snowboard, cross-country, ski touring,
* snowshoe or winter hike) and, for cross-country, the technique are columns
* of the tour, NULL on every other type, so no existing tour changes its
* meaning.
* SKI-02: a tour can be a ski track, imported from a GPX file and kept as it
* was recorded. The `ski` key has been in `tour_types`, disabled and without
* a routing profile, since every contract type was seeded; it is switched on
* here and keeps no routing profile, since TREK routes no ski track. The
* discipline and, for cross-country, the technique are columns of the tour,
* NULL on every other type, so no existing tour changes its meaning.
*/
export class Migration20200101045520_a_tour_can_be_a_ski_track extends Migration {
override name = 'Migration20200101045520_a_tour_can_be_a_ski_track';
override up(): void {
this.addSql(
"ALTER TABLE tours ADD COLUMN ski_discipline TEXT CHECK (ski_discipline IS NULL OR ski_discipline IN ('alpine', 'snowboard', 'cross_country', 'touring', 'snowshoe', 'winter_hike'))",
"ALTER TABLE tours ADD COLUMN ski_discipline TEXT CHECK (ski_discipline IS NULL OR ski_discipline IN ('alpine', 'snowboard', 'cross_country', 'touring'))",
);
this.addSql(
"ALTER TABLE tours ADD COLUMN ski_technique TEXT CHECK (ski_technique IS NULL OR ski_technique IN ('classic', 'skating', 'unknown'))",
@@ -36,6 +36,7 @@ export class Migration20200101046100_a_collection_keeps_whole_tours extends Migr
match_confidence REAL,
max_hiking_difficulty INTEGER,
bike_profile TEXT,
winter_activity TEXT,
run_profile TEXT,
run_pace_seconds_per_km INTEGER,
ski_discipline TEXT,
@@ -0,0 +1,41 @@
import { columnNames } from '../migration-utils';
import { Migration } from '@mikro-orm/migrations';
/**
* SKI-02: snowshoeing and winter hiking are disciplines of a ski and winter
* tour, no longer a winter label on a hike. A hike is summer only.
*
* `tours.winter_activity` (045500) and `collection_tours.winter_activity`
* (046100) go. A hike that carried the label stays a hike, without it:
* turning it into a ski tour would drop its routed legs, and nothing routes
* or times by the label.
*
* `tours.ski_discipline` (045520) takes the six disciplines. SQLite cannot
* change a CHECK in place, and rebuilding `tours` would mean rebuilding every
* table that references it, so the column is added again instead: its values
* wait in a plain helper column, the old column goes, the new one comes with
* the new CHECK and takes them back. Nothing indexes the column or names it in
* another constraint, so the drop is allowed. The column now sits last in the
* table, which the generated entity and table types follow.
*/
export class Migration20200101046130_snowshoeing_and_winter_hiking_are_ski_disciplines extends Migration {
override name = 'Migration20200101046130_snowshoeing_and_winter_hiking_are_ski_disciplines';
override async up(): Promise<void> {
if ((await columnNames(this, 'tours')).has('winter_activity')) {
this.addSql('ALTER TABLE tours DROP COLUMN winter_activity');
}
if ((await columnNames(this, 'collection_tours')).has('winter_activity')) {
this.addSql('ALTER TABLE collection_tours DROP COLUMN winter_activity');
}
this.addSql('ALTER TABLE tours ADD COLUMN ski_discipline_kept TEXT');
this.addSql('UPDATE tours SET ski_discipline_kept = ski_discipline');
this.addSql('ALTER TABLE tours DROP COLUMN ski_discipline');
this.addSql(
"ALTER TABLE tours ADD COLUMN ski_discipline TEXT CHECK (ski_discipline IS NULL OR ski_discipline IN ('alpine', 'snowboard', 'cross_country', 'touring', 'snowshoe', 'winter_hike'))",
);
this.addSql('UPDATE tours SET ski_discipline = ski_discipline_kept');
this.addSql('ALTER TABLE tours DROP COLUMN ski_discipline_kept');
}
}
+1 -1
View File
@@ -326,7 +326,7 @@ export function applyGlobalMiddleware(
// through fetch and needs it here.
'https://tiles.openseamap.org',
// OpenSnowMap's transparent piste layer (SKI-01), offered in the Tours planner with
// no tour open, for a hike and for a ski track; the GL map reads it through fetch.
// no tour open and for a ski tour; the GL map reads it through fetch.
'https://tiles.opensnowmap.org',
// OpenHikingMap, the hiking base map of the Tours planner (MAP-01), loaded only
// while a user shows it and the admin allows it; GL reads it through fetch.
+1 -1
View File
@@ -224,7 +224,7 @@ export class ToursMcp {
@Tool({
name: 'search_tour_pois',
description:
'Search places along the saved line of a tour: what a hike, a run, a bike tour, a paddle tour or a city walk stops for (viewpoint, peak, shelter, drinking_water, food, toilets, picnic, campsite, sights, slipway, boat_rental, bike_repair for repair stations and bike shops, and for a city walk museum for museums and galleries, park for parks and gardens, cafe, restaurant and market), within corridor_m metres of the line. Answers each place with its source (TREK places index or OpenStreetMap), kind, address, website and phone where known, opening hours as the source has them (a hint to check, never a promise), distance_m (straight across to the line, not a detour) and along_m (from the start along the line); up to 60, the nearest to the line when more match, listed from the start. When sights are asked for, the best known places near the line (by the page views of their Wikidata item) are searched too: a square or landmark no category names is added as a sight, and the highlights among them carry highlight: true and come first, the best known first. A place OpenStreetMap has no name for (a tap, a bench) comes with an empty name. unavailable lists the categories no source could be searched for right now: their places are missing, not absent, so ask again later rather than reporting none. partial says some stretches could not be searched, capped that only the first part of a long line was, truncated that more places matched. A tour saved with its points only (route_pending) has no line to search along yet. Nothing is added to the tour or the trip.',
'Search places along the saved line of a tour: what a hike, a run, a ride, a bike tour, a paddle tour, a ski and winter tour or a city walk stops for (viewpoint, peak, shelter, drinking_water, food, toilets, picnic, campsite, sights, slipway, boat_rental, bike_repair for repair stations and bike shops, for a ski and winter tour cafe and restaurant as well, and for a city walk museum for museums and galleries, park for parks and gardens, cafe, restaurant and market), within corridor_m metres of the line. Answers each place with its source (TREK places index or OpenStreetMap), kind, address, website and phone where known, opening hours as the source has them (a hint to check, never a promise), distance_m (straight across to the line, not a detour) and along_m (from the start along the line); up to 60, the nearest to the line when more match, listed from the start. When sights are asked for, the best known places near the line (by the page views of their Wikidata item) are searched too: a square or landmark no category names is added as a sight, and the highlights among them carry highlight: true and come first, the best known first. A place OpenStreetMap has no name for (a tap, a bench) comes with an empty name. unavailable lists the categories no source could be searched for right now: their places are missing, not absent, so ask again later rather than reporting none. partial says some stretches could not be searched, capped that only the first part of a long line was, truncated that more places matched. A tour saved with its points only (route_pending) has no line to search along yet. Nothing is added to the tour or the trip.',
inputSchema: {
tripId: idSchema,
placeId: idSchema.describe('The place id of the tour, as list_tours gives it'),