When I use ./bin/doctrine orm:fixtures:load to populate tables with sample data first migration sets auto incremental table id like 1,2,3,4,5 etc…
After second orm:fixtures:load migration command it purges all data and sets ids like 5,6,7,8,9 and so on…
How can I reset AI id counter to 1 when I load fixtures many times?
$ app/console help doctrine:fixtures:loadBy default Doctrine Data Fixtures uses DELETE statements to drop the existing rows from
the database. If you want to use a TRUNCATE statement instead you can use the –purge-with-truncate flag:
Truncate will reset the auto increments.
UPDATE
The console command is for Symfony, but it should be the same using Doctrine only:
UPDATE #2 for the comment about throwing an exception
If you have foreign keys, you can only reset the
AUTO_INCREMENTthrough regular SQL: