Ir al contenido principal
Petanque Life

Federation Onboarding & Migration

F01.08 14 funcionalidades Entregado

En resumen

Federation Onboarding & Migration is the white-glove pipeline that takes a new federation from blank tenant to live operations — a stateful onboarding wizard, CSV/XML bulk import with validate/dry-run/apply modes, source-system migration plans, sandbox pilots, idempotent data cleansing, and per-batch rollback. It also covers standalone clubs migrating into a federation tenant.

Cómo funciona

The onboarding wizard at /federation-onboarding/wizard is a state machine: tenant-config → districts → clubs → players → review → complete. Drafts are accumulated as the operator advances, and only on complete does the platform materialise them into real TenantConfig, District, Club and PlayerProfile documents in a transactional sequence. Bulk import is stateless under /federation-onboarding/imports/* and supports three modes: validate (rows are parsed and rule-checked, nothing is written), dry_run (a full diff report classifies every row as new, update, unchanged or error) and apply (writes happen).

Validation respects TenantConfig.org_hierarchy_depth, so the same rule set evaluates a flat Norwegian import and a deep French one. Before validation runs, an idempotent cleansing pipeline normalises every field — names trimmed, code/district_code uppercased, status lowercased, email lowercased, phone numbers reduced to plus-prefix-and-digits, dates rewritten from DD/MM/YYYY, DD.MM.YYYY, DD-MM-YYYY, YYYY/MM/DD or YYYY.MM.DD into ISO YYYY-MM-DD when unambiguous (ambiguous MDY is left for the validator to reject). Every rewrite is reported as a warning on ImportRowReport with cleaned_count on ImportReport so the operator sees exactly what was changed.

The migration-plan generator is a side-effect-free function that returns an ordered MigrationPlan: prepare_source → create_sandbox → import_districts → validate_clubs → dry_run_clubs → apply_clubs → validate_players → apply_players → pilot_signoff → production_cutover, with source-specific warnings (FFBE/SBF/DPV quirks) and risk levels that auto-escalate on volume (>5000 players → high; >500 clubs on low baseline → medium). For flat hierarchies or requires_sandbox_pilot=false the plan strips the district and sandbox steps. Sandbox tenants wrap a cloned TenantConfig as a SandboxTenant with lifecycle active → promoted or active → discarded, idempotency-protected with 409 on invalid transitions; discard soft-deletes the underlying config for audit.

Rollback is captured by ImportBatch — every apply run records created_ids and pre-mutation update_snapshots; manual rollback uses /imports/batches/{id}/rollback, and a mid-apply failure triggers automatic rollback that stamps the batch auto_rolled_back. Both paths log structured audit events. The standalone-club path (F01.09, PL-T010) is a four-step admin wizard that moves Club, License, Match, Membership, Ranking and CalendarEvent documents from the standalone tenant into the target federation, sets the source read-only, and offers a 30-day rollback window with conflict-resolution policies (skip/rename/overwrite) on license-number and club-code collisions.

Capacidades clave

  • Walk a new federation through a stateful wizard from tenant config to first players.
  • Import clubs and players in CSV/XML with validate, dry_run and apply modes.
  • Cleanse imported data idempotently before validation and report every rewrite as a warning.
  • Generate a source-system-aware migration plan with risk escalation and ordered steps.
  • Spin up sandbox tenants for pilot installation with promote/discard lifecycle.
  • Roll back any apply run manually or automatically on mid-apply failure with full audit.
  • Migrate standalone clubs into a federation tenant with consent, conflict resolution and 30-day rollback.

En la práctica

On a Tuesday morning the IT lead of a new national federation runs a full onboarding rehearsal. He generates a migration plan, the planner tags his volume (8 200 players) high-risk and recommends a sandbox pilot. He provisions a sandbox, runs the club CSV in validate mode (32 cleansing warnings, 4 errors), fixes the 4 rows, runs dry_run (212 new, 18 update, 0 unchanged, 0 error), then apply — an ImportBatch is created with all 230 created_ids.

Two days later a player CSV apply hits a Mongo write error half-way; auto-rollback kicks in, the batch is stamped auto_rolled_back, the structured audit event federation_onboarding.import_auto_rollback fires. After fixing the source data he reruns the import successfully, signs off the pilot, and flips the sandbox to promoted for production cutover.

Funcionalidades de este subsistema

14
ID Status Funcionalidades
F01.08.01 Entregado Self-service onboarding wizard for new federations ✅ PL-F0108a
F01.08.02 Entregado Bulk import of clubs and players (CSV, XML) ✅ PL-F0108a
F01.08.03 Entregado Business-rule validation of imported rows per tenant ✅ PL-F0108a
F01.08.04 Entregado Dry-run diff report (new/update/unchanged/error) ✅ PL-F0108a
F01.08.05 Entregado Migrationsplan-generator (källsystem → Petanque Life) — POST /federation-onboarding/migration-plans returnerar ordnade steg, källsystemsspecifika varningar och risknivåer (FFBE/SBF/DPV-heuristik, volymbaserad eskalering) ✅ PL-F0108b
F01.08.06 Entregado Sandbox-tenant för pilotinstallation — /federation-onboarding/sandboxes wrappar TenantConfig, lifecycle active → promoted \ discarded, discard soft-deletar konfigen | ✅ PL-F0108b
F01.08.07 Entregado Datavalidering och rensning under import — idempotent städpipeline före validering, per-fält-normalisering (whitespace, casing, email, telefon, DD/MM/YYYY → ISO), omskrivningar rapporteras som warnings/cleaned_count ✅ PL-F0108b
F01.08.08 Entregado Rollback av import vid fel — ImportBatch spårar created_ids + pre-mutation update_snapshots, manuell rollback via /imports/batches/{id}/rollback och auto-rollback vid mid-apply-fel (stämplas auto_rolled_back) ✅ PL-F0108b
F01.09.01 Entregado Dry-run migration plan with per-collection document counting and conflict detection ✅ PL-T010
F01.09.02 Entregado Consent flow — one-time token invitation to club admin, acceptance endpoint ✅ PL-T010
F01.09.03 Entregado Migration execution — move documents, update tenant_id, set source read-only ✅ PL-T010
F01.09.04 Entregado 30-day rollback window — revert all migrated documents, lift read-only ✅ PL-T010
F01.09.05 Entregado Conflict resolution — license number / club code collision (skip/rename/overwrite) ✅ PL-T010
F01.09.06 Entregado Four-step admin wizard UI with migration dashboard and rollback controls ✅ PL-T010

Partes interesadas que necesitan este subsistema

Aparece en 1 análisis de partes interesadas