Corriger les dossiers animaux et le suivi médical
This commit is contained in:
parent
a55d27935f
commit
7b89fd5dfa
34 changed files with 440 additions and 39 deletions
28
scripts/reset-demo.php
Normal file
28
scripts/reset-demo.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
if (PHP_SAPI !== 'cli') { http_response_code(404); exit(1); }
|
||||
if (!in_array('--confirm-demo-reset', $argv, true)) {
|
||||
fwrite(STDERR, "Usage: php scripts/reset-demo.php --confirm-demo-reset\n"); exit(2);
|
||||
}
|
||||
$root = dirname(__DIR__);
|
||||
foreach (['DB','Migrations','I18n','AppSettings','Auth','AuditService','BackupService','DemoDataService'] as $service) {
|
||||
require_once $root . '/app/Services/' . $service . '.php';
|
||||
}
|
||||
Migrations::run($root . '/migrations');
|
||||
I18n::setLocale(AppSettings::get('app_language'));
|
||||
$db = DB::pdo();
|
||||
$backup = BackupService::create('scheduled-demo-reset');
|
||||
try {
|
||||
$db->beginTransaction();
|
||||
$removed = DemoDataService::reset($db);
|
||||
DemoDataService::seed($db, null);
|
||||
$db->commit();
|
||||
DemoDataService::clearFiles();
|
||||
DemoDataService::installFiles($db);
|
||||
fwrite(STDOUT, json_encode(['ok'=>true,'backup'=>$backup['name'],'removed'=>$removed], JSON_UNESCAPED_UNICODE) . PHP_EOL);
|
||||
} catch (Throwable $e) {
|
||||
if ($db->inTransaction()) $db->rollBack();
|
||||
fwrite(STDERR, json_encode(['ok'=>false,'error'=>$e->getMessage()], JSON_UNESCAPED_UNICODE) . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
Loading…
Reference in a new issue