-
-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi,
I'd like to insert a lot of data into my User table, which contains many columns, but it's taking a long time. So I used another entity called Message, which has a few columns. Unfortunately, importing 1 million rows is also taking a long time. It's been going on for over an hour.
I'm wondering if it's possible to insert a lot of data with Foundy.
Would a batch processing solution offered by Doctrine be worth implementing in Foundry?
Thanks :).
<?php
namespace App\DataFixtures;
use App\Entity\User;
use App\Factory\MessageFactory;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use function Zenstruck\Foundry\Persistence\repository;
use function Zenstruck\Foundry\Persistence\flush_after;
final class AppFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
flush_after(function () {
$user1 = repository(User::class)->find(805);
$user2 = repository(User::class)->find(804);
MessageFactory::createMany(1000000, attributes: fn ($i) => [
'sender' => $user1,
'receiver' => $user2,
]);
});
}
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request