option('force') && ! $this->confirm('Are you sure you want to run ALL migrations? This will add data to your database.')) { $this->info('Migration cancelled.'); return; } $this->info('🚀 Starting complete data migration from old database...'); $this->newLine(); $commands = [ ['command' => 'migrate:outlets', 'name' => 'Outlets', 'options' => ['--recreate' => true]], ['command' => 'migrate:users', 'name' => 'Users'], ['command' => 'migrate:employees', 'name' => 'Employees'], ['command' => 'migrate:categories', 'name' => 'Categories'], ['command' => 'migrate:products', 'name' => 'Products', 'options' => ['--recreate' => true]], ['command' => 'migrate:perfumes', 'name' => 'Perfumes', 'options' => ['--recreate' => true]], ['command' => 'migrate:bottles', 'name' => 'Bottles', 'options' => ['--recreate' => true]], ]; $totalCommands = count($commands); $completed = 0; $failed = 0; foreach ($commands as $commandConfig) { $commandName = $commandConfig['command']; $name = $commandConfig['name']; $options = $commandConfig['options'] ?? []; // Always add force option $options['--force'] = $this->option('skip-confirm'); $this->info("📋 Migrating {$name}..."); $this->newLine(); try { $exitCode = $this->call($commandName, $options); if ($exitCode === 0) { $this->info("✅ {$name} migration completed successfully!"); $completed++; } else { $this->error("❌ {$name} migration failed!"); $failed++; if (! $this->confirm("Continue with remaining migrations despite {$name} failure?")) { $this->warn('Migration stopped by user.'); break; } } } catch (\Exception $e) { $this->error("❌ {$name} migration error: {$e->getMessage()}"); $failed++; if (! $this->confirm("Continue with remaining migrations despite {$name} error?")) { $this->warn('Migration stopped by user.'); break; } } $this->newLine(2); } $this->newLine(); $this->info('🎉 Migration process completed!'); $this->info('📊 Summary:'); $this->info(" ✅ Completed: {$completed}/{$totalCommands} migrations"); if ($failed > 0) { $this->warn(" ❌ Failed: {$failed} migrations"); } if ($completed === $totalCommands) { $this->info('🎊 All migrations completed successfully!'); // Run seeders $this->runSeeders(); } else { $this->warn('⚠️ Some migrations failed. Please check the output above for details.'); } return $failed > 0 ? 1 : 0; } /** * Run the seeders after successful migration */ private function runSeeders() { $this->newLine(); $this->info('🌱 Running seeders...'); $seeders = [ ['class' => UserSeeder::class, 'name' => 'UserSeeder'], ['class' => FormulaSeeder::class, 'name' => 'FormulaSeeder'], ]; $totalSeeders = count($seeders); $completedSeeders = 0; $failedSeeders = 0; foreach ($seeders as $seederConfig) { $seederClass = $seederConfig['class']; $name = $seederConfig['name']; $this->info("📋 Seeding {$name}..."); try { $this->call($seederClass); $this->info("✅ {$name} seeded successfully!"); $completedSeeders++; } catch (\Exception $e) { $this->error("❌ {$name} seeding failed: {$e->getMessage()}"); $failedSeeders++; if (! $this->confirm("Continue with remaining seeders despite {$name} failure?")) { $this->warn('Seeding stopped by user.'); break; } } $this->newLine(); } $this->info('🌱 Seeder process completed!'); $this->info('📊 Seeder Summary:'); $this->info(" ✅ Completed: {$completedSeeders}/{$totalSeeders} seeders"); if ($failedSeeders > 0) { $this->warn(" ❌ Failed: {$failedSeeders} seeders"); } if ($completedSeeders === $totalSeeders) { $this->info('🎊 All seeders completed successfully!'); } else { $this->warn('⚠️ Some seeders failed. Please check the output above for details.'); } } }