diff --git a/app/Console/Commands/OneOff/AssociateExactMatchTrees.php b/app/Console/Commands/OneOff/AssociateExactMatchTrees.php new file mode 100644 index 00000000..71e92d71 --- /dev/null +++ b/app/Console/Commands/OneOff/AssociateExactMatchTrees.php @@ -0,0 +1,43 @@ +join('tree_species_research', 'v2_tree_species.name', '=', 'tree_species_research.scientific_name') + ->where('v2_tree_species.taxon_id', null); + $this->withProgressBar((clone $query)->count(), function ($progressBar) use ($query) { + $query->chunkById(100, function ($trees) use ($progressBar) { + foreach ($trees as $tree) { + TreeSpecies::where('id', $tree->id)->update(['taxon_id' => $tree->taxon_id]); + $progressBar->advance(); + } + }); + }); + }); + } +}