addArgument('name', InputArgument::REQUIRED, 'The migration name (e.g. create_users_table)'); } protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); // Convert name to class format (CreateUsersTable) $className = str_replace(' ', '', ucwords(str_replace('_', ' ', $name))); // Generate timestamp for ordering $timestamp = date('YmdHis'); // Define file name $fileName = "{$timestamp}_{$name}.php"; // Migrations directory path $migrationsPath = dirname(__DIR__, 3) . '/database/migrations'; if (!is_dir($migrationsPath)) { mkdir($migrationsPath, 0755, true); } $filePath = $migrationsPath . '/' . $fileName; // Migration template $template = <<hasTable('table_name')) { Capsule::schema()->create('table_name', function (Blueprint \$table) { \$table->id(); \$table->timestamps(); }); } } /** * Reverse the migrations. * * @return void */ public function down(): void { Capsule::schema()->dropIfExists('table_name'); } } PHP; if (file_put_contents($filePath, $template)) { $output->writeln("Migração criada com sucesso: {$fileName}"); return Command::SUCCESS; } else { $output->writeln("Falha ao criar o arquivo de migração."); return Command::FAILURE; } } }