MEGAINFRA-WEBAPP/scripts/migrations
DEls a0d335b235 fix(timesheets): stamp site on log rows, ending read-time drift
The timesheet log carried neither site nor project_code; attribution was
synthesised at read time from employees.site, so moving a worker to
another site silently migrated their entire payroll history with them.
docs/data-model.md flags this as the schema's worst drift risk.

Adds an optional site relation (maxSelect 1, cascadeDelete false so
deleting a site cannot destroy payroll history) and stamps all 1367 rows
from the employee's current site. 1367/1367 written, 0 orphans.

Tightened to required in Task 16, once the import route writes it on
every new row.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 10:48:51 +02:00
..
2026-08-19-extend-data-import-batches.py feat(migration): add async-queue fields to data_import_batches 2026-08-19 19:19:17 +02:00
2026-08-24-data-import-batches-allow-xlsx.py fix(data-import-batches): allow xlsx MIME on original_file 2026-08-24 22:17:45 +02:00
2026-08-24-fuel-logs-latest-consumption.py feat(fuel): drop-in xlsx/csv import for pump sheets 2026-08-24 22:03:08 +02:00
2026-08-28-vehicles-attention-dismissed.py feat(fuel): PB schema migration for attention_dismissed_at 2026-08-28 12:26:23 +02:00
2026-08-28-vehicles-unit-type-optional.py fix(pb): make vehicles.unit_type optional 2026-08-28 15:26:33 +02:00
2026-08-29-fixed-costs-recurring-backfill.py fix(schema): ensure is_recurring=false writes are preserved 2026-08-28 13:43:38 +02:00
2026-08-31-data-import-batches-allow-pdf-images.py fix(pb): allow PDF and image MIME on data_import_batches.original_file 2026-08-31 12:20:41 +02:00
2026-09-11-add-document-fields.py feat(schema): add file_hash and queue fields to DNs and POs 2026-09-11 10:29:10 +02:00
2026-09-11-backfill-entity-file-hashes.py fix(migration): separate download failures from missing files 2026-09-11 10:39:54 +02:00
2026-09-11-backfill-fuel-log-sites.py fix(fuel): backfill site on 147 orphaned fuel logs 2026-09-11 10:44:19 +02:00
2026-09-11-backfill-timesheet-sites.py fix(timesheets): stamp site on log rows, ending read-time drift 2026-09-11 10:48:51 +02:00