seria/tools/new-migration

26 lines
711 B
Text
Raw Permalink Normal View History

#!/usr/bin/env php
<?php
2024-10-05 16:42:25 +00:00
use Index\Db\Migration\FsDbMigrationRepo;
require_once __DIR__ . '/../seria.php';
$repo = $seria->createMigrationRepo();
if(!($repo instanceof FsDbMigrationRepo)) {
echo 'Migration repository type does not support creation of templates.' . PHP_EOL;
return;
}
$baseName = implode(' ', array_slice($argv, 1));
$manager = $seria->createMigrationManager();
try {
$names = $manager->createNames($baseName);
} catch(InvalidArgumentException $ex) {
echo $ex->getMessage() . PHP_EOL;
return;
}
$repo->saveMigrationTemplate($names->name, $manager->template($names->className));
echo "Template for '{$names->className}' has been saved to {$names->name}.php." . PHP_EOL;