eeprom/tools/migrate

35 lines
897 B
Text
Raw Normal View History

2023-10-31 19:54:54 +00:00
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../eeprom.php';
try {
touch(PRM_ROOT . '/.migrating');
chmod(PRM_ROOT . '/.migrating', 0777);
2023-11-07 17:12:47 +00:00
$db = $eeprom->getDatabase();
2023-10-31 19:54:54 +00:00
echo 'Creating migration manager...' . PHP_EOL;
2023-11-07 17:12:47 +00:00
$manager = $db->createMigrationManager();
2023-10-31 19:54:54 +00:00
echo 'Preparing to run migrations...' . PHP_EOL;
$manager->init();
echo 'Creating migration repository...' . PHP_EOL;
2023-11-07 17:12:47 +00:00
$repo = $db->createMigrationRepo();
2023-10-31 19:54:54 +00:00
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(PRM_ROOT . '/.migrating');
}