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/migrate

35 lines
894 B
Text
Raw Normal View History

2023-11-06 00:45:15 +00:00
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../satori.php';
try {
touch(SAT_ROOT . '/.migrating');
chmod(SAT_ROOT . '/.migrating', 0777);
$db = $sat->getDatabase();
echo 'Creating migration manager...' . PHP_EOL;
$manager = $db->createMigrationManager();
echo 'Preparing to run migrations...' . PHP_EOL;
$manager->init();
echo 'Creating migration repository...' . PHP_EOL;
$repo = $db->createMigrationRepo();
echo 'Running migrations...' . PHP_EOL;
$completed = $manager->processMigrations($repo);
if(empty($completed)) {
echo 'There were no migrations to run!' . PHP_EOL;
} else {
echo 'The following migrations have been completed:' . PHP_EOL;
foreach($completed as $migration)
echo ' - ' . $migration . PHP_EOL;
}
echo PHP_EOL;
} finally {
unlink(SAT_ROOT . '/.migrating');
}