<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class MigrateAllCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'migrate:all';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run all migration commands in correct order';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->info('🚀 Starting global data migration process...');
        $startTime = microtime(true);

        $commands = [
            'migrate:user' => '👥 Migrating users...',
            'migrate:department' => '🏢 Migrating departments...',
            'migrate:location' => '📍 Migrating locations & sub-locations...',
            'migrate:classification' => '🏷️ Migrating classifications & sub-classifications...',
            'migrate:theme' => '🎨 Migrating themes...',
            'migrate:media-monitoring' => '🖥️ Migrating media monitoring...',
            'migrate:company' => '🏭 Migrating companies & partner media...',
            'migrate:journalist' => '📰 Migrating journalists...',
            'migrate:news' => '🗞️ Migrating news...',
            'migrate:announcement' => '📢 Migrating announcements...',
            'migrate:cooperation' => '🤝 Migrating cooperations, proposals & reports...',
            'migrate:content-recap' => '📊 Migrating content recaps...',
            'migrate:issue-management' => '⚠️ Migrating issue management...',
        ];

        foreach ($commands as $command => $description) {
            $this->newLine();
            $this->info($description);
            $this->call($command);
        }

        $endTime = microtime(true);
        $duration = number_format($endTime - $startTime, 2);

        $this->newLine();
        $this->info("✅ Global migration completed in {$duration} seconds!");
    }
}
