This repository has been archived on 2024-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
satori-services/tools/new-migration

27 lines
735 B
Text
Raw Normal View History

2023-11-06 00:45:15 +00:00
#!/usr/bin/env php
<?php
use Index\Data\Migration\FsDbMigrationRepo;
require_once __DIR__ . '/../satori.php';
$db = $sat->getDatabase();
$repo = $db->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 = $db->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;