Files
rspade_system/app/RSpade/Commands/Migrate/Pending_Command.php
root f6fac6c4bc Fix bin/publish: copy docs.dist from project root
Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 02:08:33 +00:00

76 lines
2.1 KiB
PHP
Executable File

<?php
/**
* CODING CONVENTION:
* This file follows the coding convention where variable_names and function_names
* use snake_case (underscore_wherever_possible).
*/
namespace App\RSpade\Commands\Migrate;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\RSpade\Core\Database\MigrationPaths;
/**
* Show pending migrations that have not been run yet
*
* This command displays a simple list of migration files that are present
* in the migrations directory but have not yet been executed against the database.
*/
class Pending_Command extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'migrate:pending';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show pending migrations that have not been run';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// Get the migrator instance
$migrator = app('migrator');
// Get migration files from all migration directories
$migration_files = [];
foreach (MigrationPaths::get_all_paths() as $path) {
$migration_files = array_merge(
$migration_files,
$migrator->getMigrationFiles($path)
);
}
// Get migrations that have already been run
$ran_migrations = $migrator->getRepository()->getRan();
// Find pending migrations (files not in the ran list)
$pending_migrations = array_diff(array_keys($migration_files), $ran_migrations);
// Sort them to maintain chronological order
sort($pending_migrations);
if (empty($pending_migrations)) {
$this->info('No pending migrations.');
return 0;
}
$this->line('Migrations Pending:');
foreach ($pending_migrations as $migration) {
$this->line('- ' . $migration);
}
return 0;
}
}