flash.moe/tools/new-migration

26 lines
711 B
Text
Raw Normal View History

2024-06-11 00:24:12 +00:00
#!/usr/bin/env php
2023-10-13 22:25:40 +00:00
<?php
2024-10-21 20:50:01 +00:00
use Index\Db\Migration\FsDbMigrationRepo;
2023-10-13 22:25:40 +00:00
require_once __DIR__ . '/../makai.php';
$repo = $makai->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 = $makai->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;