What is Migration and Seeding in Laravel?

Almost every modern web application interacts with a database. Hence in Laravel, it interacts with databases extremely simple across a variety of supported other databases. Aside from other things you need to learn in creating the task, when working with a project using Laravel, you must be familiar with these two – Migration and Seeding

Migration

Migrations act as a version control system for your database, allowing your team to develop and share the database schema definition for the application. It’s a essential feature in Laravel that allows you to construct a database table and allows you to change and share this database schema for the application. You can also change the table by adding a new column or removing one that already exists.

Moreover, across all of Laravel’s supported database systems, the Laravel Schema facade provides database agnostic functionality for generating and manipulating tables. This façade is typically used by migrations to create and alter database tables and columns.

Seeding

Laravel provides a mechanism for automatically inserting dummy data into the database. Seeding is the term for this procedure. Using the database seeder, developers may quickly add test data to their database table. Additionally, it is highly beneficial because it allows developers to spot issues and optimize efficiency by testing with various data types.

Seed classes in Laravel allow you to populate your database with data and the database/seeders directory contains all seed classes. A DatabaseSeeder class is created for you by default. It can be use to call function to execute other seed classes from this class, allowing you to customize the seeding order.

Leave a Comment

Your email address will not be published. Required fields are marked *