Migrations are like version control for our database. Means we don’t have to worry about versions of the database and laravel because it interacts with the database by command, we don’t need to interact with the database manually. By using migration, we create/define tables, structures, seeds value in the database. We also don’t need to add columns manually in the database.
How to create a migration.
To create migration we call a command, see below:-
After hitting Enter migration creates. See below how it looks:-
How to add columns in Database by migration.
To add a column, we open our migration and add column in up function and use migrate command to add in database. See below how:-
After adding column we call migrate command to add in the database.
Column migrated in database. See below:-
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021