Migrations
Migrations is used to create database schema/table
Factory
Factory file
holds which field should have what value if you want to seed your data.
Basically it defines rules for all of the model fields.
It is usually used for automated testing like unit testing and even continuous integration and continuous delivery.
It would take lot of time to create 50 users manually. So factory helps to automate seeding bigger amount of data.
It uses a library called faker which helps to fake any data such as name, email, number etc.
Seeding the data
Seeding is a process of populating a database with test data. It is used at the beginning of the project to seed first batch of dummy data without having to manually enter each record and it is used only once.
In seeder we just need to use factory to seed dummy data. Then it can create any given number of rows such as 10, 20 or more and it can be even more complex with relationship.