<?php
declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../app/bootstrap.php';

use App\Database\Connection;
use App\Repositories\PersonRepository;

try {
    $db = new Connection();
    $repo = new PersonRepository($db);
    $count = $repo->backfillCustomerProductsFromRequestedServices();
    echo "Backfill completed. Updated persons: {$count}" . PHP_EOL;
    exit(0);
} catch (Throwable $e) {
    fwrite(STDERR, 'Backfill failed: ' . $e->getMessage() . PHP_EOL);
    exit(1);
}

