-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance with LiipTestFixturesBundle v2.6.0 #252
Comments
@Dekrikh do the database schema has lots of entites with many columns? You can try to keep the schema: #12 (comment) |
@alexislefebvre I measured the command's execution time using the following: Measure-Command { php bin/console --env=test doctrine:schema:update --force }
Now, I have good performance with #12 (comment), thank you. However, I encountered another issue. In my test, I send a request with the method api of the paht ID of one. The problem is that the test doesn't start with ID 1; it uses the previous ID plus one (AUTO_INCREMENT)." I thought of using the Event https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/events.md to reset an AUTO_INCREMENT. Any thoughts to share with me? |
@Dekrikh Try to set the id to |
I chose simplicity a "DELETE FROM table_name" looping over all tables with a reset of AUTO_INCREMENT = 1; at each start of the test if someone has the same need, this code using doctrine in symfony : public function clearAllTablesInDatabaseAndResetAutoIncrement(){
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$em->getConnection()->exec('SET FOREIGN_KEY_CHECKS = 0');
// clear all the tables
foreach ($em->getMetadataFactory()->getAllMetadata() as $metadata) {
$queryBuilder = $em->createQueryBuilder();
$queryBuilder->delete($metadata->getName());
$queryBuilder->getQuery()->execute();
}
foreach ($em->getMetadataFactory()->getAllMetadata() as $metadata) {
$em->getConnection()->exec('ALTER TABLE ' . $metadata->getTableName() . ' AUTO_INCREMENT = 1;');
}
$em->getConnection()->exec('SET FOREIGN_KEY_CHECKS = 1');
} |
@Dekrikh thanks for sharing the code. Is it faster if you keep the tables but remove the data with |
@alexislefebvre yes, that's a better idea. |
Actually, is your code already doing this? I'm not sure if the call to |
Originally posted by @Dekrikh in #12 (comment)
The text was updated successfully, but these errors were encountered: