Forgot to CTRL+S this file, oops!

This commit is contained in:
flash 2023-01-01 03:50:41 +00:00
parent 9efe8e6853
commit cd959b7e55

View file

@ -15,18 +15,21 @@ class MigrateCommand implements CommandInterface {
} }
public function dispatch(CommandArgs $args): void { public function dispatch(CommandArgs $args): void {
if($args->getArg(0) === 'rollback') {
echo 'Migration rollback is gone.' . PHP_EOL;
return;
}
touch(MSZ_ROOT . '/.migrating'); touch(MSZ_ROOT . '/.migrating');
chmod(MSZ_ROOT . '/.migrating', 0777); chmod(MSZ_ROOT . '/.migrating', 0777);
try {
echo "Creating migration manager.." . PHP_EOL; echo "Creating migration manager.." . PHP_EOL;
$migrationManager = new DatabaseMigrationManager(DB::getPDO(), MSZ_ROOT . '/database'); $migrationManager = new DatabaseMigrationManager(DB::getPDO(), MSZ_ROOT . '/database');
$migrationManager->setLogger(function ($log) { $migrationManager->setLogger(function ($log) {
echo $log . PHP_EOL; echo $log . PHP_EOL;
}); });
if($args->getArg(0) === 'rollback') {
echo 'Migration rollback is gone.' . PHP_EOL;
} else {
$migrationManager->migrate(); $migrationManager->migrate();
$errors = $migrationManager->getErrors(); $errors = $migrationManager->getErrors();
@ -39,8 +42,8 @@ class MigrateCommand implements CommandInterface {
foreach($errors as $error) foreach($errors as $error)
echo $error . PHP_EOL; echo $error . PHP_EOL;
} }
} } finally {
unlink(MSZ_ROOT . '/.migrating'); unlink(MSZ_ROOT . '/.migrating');
} }
}
} }