hanyuu/tools/new-migration

26 lines
708 B
Text
Raw Permalink Normal View History

2023-01-07 04:36:22 +00:00
#!/usr/bin/env php
<?php
2024-11-13 23:58:43 +00:00
use Index\Db\Migration\FsDbMigrationRepo;
2023-01-07 04:36:22 +00:00
require_once __DIR__ . '/../hanyuu.php';
$repo = $hau->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 = $hau->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;