<?php

declare(strict_types=1);

if (PHP_SAPI !== 'cli') {
    http_response_code(404);
    exit;
}

require dirname(__DIR__) . '/app/bootstrap.php';

use App\Database;

$statement = Database::connection()->prepare(
    'DELETE FROM inquiries
     WHERE closed_at IS NOT NULL
       AND closed_at < DATE_SUB(NOW(), INTERVAL 1 YEAR)'
);
$statement->execute();

fwrite(STDOUT, sprintf("보유기간이 지난 문의 %d건을 삭제했습니다.\n", $statement->rowCount()));
