Files
TREK/server/src/db/entities/TourWaypoints.entity.ts
T
Maurice c956fe92ba Merge dev into feat/tours and port Tours onto MikroORM
dev now runs on MikroORM, so the positional migrations, seeds.ts and
DatabaseService the Tours server side was built on are gone. Behaviour
is unchanged; persistence moves onto dev's architecture:

- one MikroORM migration for tour_types, tours and tour_waypoints,
  idempotent so instances that ran the old positional steps keep
  their data; the hike tour type is seeded inside it, the addon row
  in the AddonSeeder
- entities and repositories for the three tables, tours domain on
  repositories and UnitOfWork
- tour facet joins in places, assignments and days re-applied on the
  repository code

Fixes found while porting:

- GPX import checks addon, trip access and permission in the handler
  instead of guards, so a refused upload gets a 403/404 instead of a
  connection reset
- copying a trip copies its tours and waypoints
- a tour cannot be moved onto a day that already has it
- updateTour checks existence inside its transaction

Adds tours e2e tests and rewrites the tours unit tests onto the
migrated test database.
2026-10-06 22:43:09 +02:00

30 lines
885 B
TypeScript

import { EntityRepositoryType, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
import { TourWaypointsRepository } from '../repositories/TourWaypoints.repository';
import { Tours } from './Tours.entity';
export class TourWaypoints {
[EntityRepositoryType]?: TourWaypointsRepository;
id!: number & Opt;
place!: Ref<Tours>;
place_id!: number;
lat!: number;
lng!: number;
role!: string;
sequence!: number;
}
export const TourWaypointsSchema = defineEntity({
class: TourWaypoints,
repository: () => TourWaypointsRepository,
uniques: [{ properties: ['place', 'sequence'] }],
properties: {
id: p.integer().primary(),
place: () => p.manyToOne(Tours).ref().name('place_id').deleteRule('cascade').hidden(),
place_id: p.integer().persist(false),
lat: p.double(),
lng: p.double(),
role: p.text(),
sequence: p.integer(),
},
});