46 lines
770 B
PHP
46 lines
770 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Core\Commands;
|
||
|
|
|
||
|
|
use App\Core\Database\Migrator;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* NovaCore Migrate Command
|
||
|
|
* CLI command to run database migrations
|
||
|
|
*/
|
||
|
|
class MigrateCommand
|
||
|
|
{
|
||
|
|
private Migrator $migrator;
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$this->migrator = new Migrator();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the command
|
||
|
|
*/
|
||
|
|
public function execute(): void
|
||
|
|
{
|
||
|
|
echo "Running database migrations...\n";
|
||
|
|
$this->migrator->run();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Rollback migrations
|
||
|
|
*/
|
||
|
|
public function rollback(): void
|
||
|
|
{
|
||
|
|
echo "Rolling back migrations...\n";
|
||
|
|
$this->migrator->rollback();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show migration status
|
||
|
|
*/
|
||
|
|
public function status(): void
|
||
|
|
{
|
||
|
|
$this->migrator->status();
|
||
|
|
}
|
||
|
|
}
|