1.Introduction
Laravel Artisan is a command-line tool built into projects using Laravel, it provides a lot of functions to help build projects, reduce coding time and automate some tasks.
Laravel Artisan deserves its name, it is really excellent when handling manual jobs by automating them.
If you are looking for a quick way to remove all tables , types, and views when migrating the database, then I will introduce you one way, that is to use php artisan db: wipe
2.Getting Started
Command syntax
1 2 3 | $ php artisan db:wipe {--database=} {--drop-views} {--drop-types} |
Explain more about parameters
- database – Database config (this database will be taken from. env ).
- drop-views – Drop all tables and Views (by default it will drop all tables)
- drop-types – Drop all tables and types (only for Postgres database)
You can also use the command:
1 2 | php artisan migrate:reset |
But it is very slow compared to the number of migrations because it has to iterate over the migrations tables and run executes down for each migrations, and it is important that if in the down method we did not delete the previously set foreign key You can execute the above statement, and you will be forced to remove all tables, views & types directly in the database.
3.Testing
1 2 | php artisan db:wipe |
1 2 3 | Dropped all tables successfully. |
1 2 | php artisan db:wipe --drop-views |
1 2 3 | Dropped all views successfully. Dropped all tables successfully. |
Laravel Artisan makes backend jobs much easier, we can create commands to execute scripts to help write code or administer the website.
It can be said that Laravel Artisan is a very good idea, a tool to help the Laravel framework is making a difference compared to other frameworks.