35 lines
1,005 B
PHP
Executable file
35 lines
1,005 B
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
use Index\Data\Migration\DbMigrationManager;
|
|
use Index\Data\Migration\FsDbMigrationRepo;
|
|
|
|
require_once __DIR__ . '/../eeprom.php';
|
|
|
|
try {
|
|
touch(PRM_ROOT . '/.migrating');
|
|
chmod(PRM_ROOT . '/.migrating', 0777);
|
|
|
|
echo 'Creating migration manager...' . PHP_EOL;
|
|
$manager = new DbMigrationManager($db, 'prm_' . DbMigrationManager::DEFAULT_TABLE);
|
|
|
|
echo 'Preparing to run migrations...' . PHP_EOL;
|
|
$manager->init();
|
|
|
|
echo 'Creating migration repository...' . PHP_EOL;
|
|
$repo = new FsDbMigrationRepo(PRM_MIGRATIONS);
|
|
|
|
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');
|
|
}
|