private function migrateComments() { $this->info('Importing Comments'); $errorCount = 0; if (!\Nexus\Comment::first()) { $count = \DB::select('select count(comment_id) as count from commenttable')[0]->count; $this->line("Found {$count} comments "); $bar = $this->output->createProgressBar($count); $classicComments = \DB::table('commenttable')->get(); foreach ($classicComments as $classicComment) { $newComment = new \Nexus\Comment(); $newComment->id = $classicComment->comment_id; $newComment->text = $classicComment->text; $newComment->user_id = $classicComment->user_id; $newComment->author_id = $classicComment->from_id; if ($classicComment->readstatus === 'n') { $newComment->read = false; } else { $newComment->read = true; } try { $newComment->save(); $bar->advance(); } catch (\Exception $e) { $errorCount++; \Log::error('Nexus:upgrade - Failed to add comment ' . $e); } } $bar->finish(); if ($errorCount) { $this->error("\nEncountered {$errorCount} errors. See log for details"); } $this->info("\nComments Complete\n"); unset($classicComments); } else { $this->error('Upgrade: found existing comments - skipping Comments'); } }