The import command and a sample of how it can be used. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ok, So this IS NOT a PR to merge but more of a sample that you can pick apart and use whatever you like or toss completely.
To test it out, make a database with some data and populate it with 1-100 million rows of random data and relationships. Anything that will strain the computer that you are on so queries actually take a few seconds. 2-5 seconds is a good benchmark for unoptimized versions. Try and transform with chunk and normally it will take long, really long like possibly minutes or hours before it either comes through or fails based on your memory cpu limits.
Transforms using this strategy will still take a bit of time but I cut this migration down by 80%, enough to keep it complex but basically easy enough that most Laravel beginners could follow it without any real questions. This should complete on 1 million users in about 30 - 60 seconds. You could probably speed it up or slow it down by changing saveEvery to 100 or 10 or even 1 and playing with RAM etc...
Also in this example I didn't use the screen annotation function but I normally using it when purging key mismatches or looking for dead data in a function
$this->updateStepWithMessage("Updating all the matched {$foreignKey}s in {$inTable}");will read something like
Hope you find this useful. If you find better faster ways to do this please let me know :)