mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 05:15:35 +07:00
feat: add trustlab:migrate-ca command for simplified CA migrations
This commit is contained in:
61
app/Console/Commands/TrustLabMigrateCa.php
Normal file
61
app/Console/Commands/TrustLabMigrateCa.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class TrustLabMigrateCa extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'trustlab:migrate-ca
|
||||
{--fresh : Drop all tables and re-run all migrations}
|
||||
{--seed : Seed the database with records}
|
||||
{--force : Force the operation to run when in production}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run migrations for the CA database (mysql_ca) using the isolated path';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting TrustLab CA Migration...');
|
||||
|
||||
$parameters = [
|
||||
'--database' => 'mysql_ca',
|
||||
'--path' => 'database/migrations/ca',
|
||||
];
|
||||
|
||||
if ($this->option('force')) {
|
||||
$parameters['--force'] = true;
|
||||
}
|
||||
|
||||
if ($this->option('seed')) {
|
||||
$parameters['--seed'] = true;
|
||||
}
|
||||
|
||||
$command = $this->option('fresh') ? 'migrate:fresh' : 'migrate';
|
||||
|
||||
$this->comment("Running command: php artisan {$command} --database=mysql_ca --path=database/migrations/ca " . ($this->option('force') ? '--force' : ''));
|
||||
|
||||
$exitCode = Artisan::call($command, $parameters, $this->output);
|
||||
|
||||
if ($exitCode === 0) {
|
||||
$this->info('CA Migration completed successfully.');
|
||||
} else {
|
||||
$this->error('CA Migration failed.');
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user