Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

Cleaning up dummy data

How to clean up the dummy data after inserting many dummy data?

0 likes
3 replies
tykus's avatar

Without context it is difficult to help.

If you are in development, and you are happy to clear everything from your database, then php artisan migrate:fresh will drop all your tables (and data) and re-run migrations - everything will be lost!

davy_yg's avatar
Level 27

only the data and not the table.

For instance I am having a car table without any data. And I use factory to insert it with 100 dummy data. Now, I want to delete it all without deleting the table so it's ready to be inserted with a new data.

How to do this?

tykus's avatar

You can drop all data and reset the primary key without dropping the table using truncate() method, for example within php artisan tinker

Car::truncate();

otherwise, you could do this directly on your database using the command that is appropriate to your particular DBMS.

Please or to participate in this conversation.