<?php

declare(strict_types=1);

/**
 * M6 per-property sync cursor/state.
 *
 * @return callable(PDO, string): void
 */
return static function (\PDO $pdo, string $prefix): void {
    if (!preg_match('/^[a-zA-Z0-9_]+$/', $prefix)) {
        throw new InvalidArgumentException('Invalid table prefix');
    }
    $t = '`' . $prefix . 'google_properties`';

    try { $pdo->exec("ALTER TABLE {$t} ADD COLUMN `last_sync_date` date NULL"); } catch (\Throwable) {}
    try { $pdo->exec("ALTER TABLE {$t} ADD COLUMN `last_sync_at` datetime NULL"); } catch (\Throwable) {}
    try { $pdo->exec("ALTER TABLE {$t} ADD COLUMN `last_sync_error` varchar(255) NULL"); } catch (\Throwable) {}
};

