2
0
Fork 0
forked from flashii/eeprom
eeprom-nabucco/tools/new-migration

27 lines
738 B
Text
Raw Normal View History

2023-10-31 19:54:54 +00:00
#!/usr/bin/env php
<?php
use Index\Data\Migration\FsDbMigrationRepo;
require_once __DIR__ . '/../eeprom.php';
2023-11-07 17:12:47 +00:00
$db = $eeprom->getDatabase();
$repo = $db->createMigrationRepo();
2023-10-31 19:54:54 +00:00
if(!($repo instanceof FsDbMigrationRepo)) {
echo 'Migration repository type does not support creation of templates.' . PHP_EOL;
return;
}
$baseName = implode(' ', array_slice($argv, 1));
2023-11-07 17:12:47 +00:00
$manager = $db->createMigrationManager();
2023-10-31 19:54:54 +00:00
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;