flashii/eeprom
Archived
3
0
Fork 1
This repository has been archived on 2025-03-27. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
eeprom/tools/migrate

36 lines
985 B
PHP
Executable file

#!/usr/bin/env php
<?php
require_once __DIR__ . '/../eeprom.php';
$lockPath = $eeprom->dbCtx->getMigrateLockPath();
if(is_file($lockPath))
die('A migration script is already running.' . PHP_EOL);
touch($lockPath);
try {
echo 'Creating migration manager...' . PHP_EOL;
$manager = $eeprom->dbCtx->createMigrationManager();
echo 'Preparing to run migrations...' . PHP_EOL;
$manager->init();
echo 'Creating migration repository...' . PHP_EOL;
$repo = $eeprom->dbCtx->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;
} catch(Exception $ex) {
var_dump($ex);
} finally {
unlink($lockPath);
}