Globinours/scripts/asm3-plan.php

28 lines
895 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
declare(strict_types=1);
require dirname(__DIR__) . '/app/Services/DB.php';
require dirname(__DIR__) . '/app/Services/Asm3Analyzer.php';
require dirname(__DIR__) . '/app/Services/Asm3MigrationPlanner.php';
$source = $argv[1] ?? null;
$output = $argv[2] ?? null;
if (!$source) {
fwrite(STDERR, "Usage : php scripts/asm3-plan.php <dump.sql> [rapport.json]\n");
exit(2);
}
try {
$plan = Asm3MigrationPlanner::plan($source, DB::pdo());
$json = json_encode($plan, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\n";
} catch (Throwable $e) {
fwrite(STDERR, "Erreur : {$e->getMessage()}\n");
exit(1);
}
if ($output) {
if (file_put_contents($output, $json) === false) {
fwrite(STDERR, "Impossible décrire le rapport.\n");
exit(1);
}
echo "Plan écrit dans {$output}\n";
} else {
echo $json;
}