Migrations :-
- Now, discuss about some concepts in LARAVEL.
- Migrations are like version control for our database, allowing a team to easily modify and share the application's database schema.
- Migrations are typically paired with Laravel's schema builder to easily build our application's database schema.
- To create a migration, use the make:migration Artisan command:-
Syntax:-
php artisan make:migration table_name
Example:-
php artisan make:migration create_users_table
- Once we run the above command in the DOS prompt, the new migration will be saved in the database/migration directory.
- Each migration file name contains a timestamp which allows Laravel to understand the order of the migrations.
- A migration class contains two methods: up and down .
down :- This method is used to reverse the operations performed by the up method.
- To run the migrations, we need to use the migrate Artisan command, i.e,
php artisan migrate
- If we receive a "class not found" error while running migrations, then we need to run the composer dump‐autoload command
- To rollback the latest migration "operation", we need to use the rollback command.
php artisan migrate:rollback
- To rollback all of our application's migrations, we need to use the below command:-
php artisan migrate:reset
No comments:
Post a Comment