These are some notes for Laravel Migration that are very helpful when migrating databases with up and down methods.

For the latest and best infromation go to the official Laravel Documentation: https://laravel.com/docs/10.x/migrations

The laravel migration class has 2 methods only available: up and down.

up(): used for adding new tables, columns, or indexes to the database,

down() will reverse the operations performed by the up method.

Command and description

Command Description/Explanation
php artisan make:migration create_blogs_table --create=blogs Create a New Table https://www.youtube.com/watch?v=2jQ2M5vD5sM
Results: xxxx_create_blogs_table.php
php artisan migrate Run All
php artisan migrate:refresh --path=database/migrations/[fileName].php Migrate ONLY one table file
php artisan migrate:fresh --path=database/migrations/[fileName].php WARNING: THIS WILL DROP ALL TABLES NOT JUST ONE
* NOTE: Cannot use wildcards in migrate command
example: This will not work:
php artisan migrate:refresh --path=database/migrations/*media*.php
php artisan make:model Example -m Create a new model with migration
php artisan make:migration create_example_table Create a new example table
php artisan migrate:status migrations have run
php artisan migrate --pretend see the SQL statements that will be executed
php artisan migrate:rollback  roll back the latest migration
php artisan migrate:rollback --step=5 roll back the last five migrations
php artisan migrate:reset roll back all of your migrations
php artisan migrate:refresh roll back all of your migrations and then execute the migrate command
php artisan migrate:refresh --seed Refresh the database and run all database seeds
php artisan migrate:refresh --step=5 roll back and re-migrate the last five migrations
php artisan migrate:fresh drop all tables from the database and then execute the migrate command
Create Tables https://laravel.com/docs/10.x/migrations#creating-tables
Updating Tables https://laravel.com/docs/10.x/migrations#updating-tables
Renaming / Dropping Tables https://laravel.com/docs/10.x/migrations#renaming-and-dropping-tables
Creating Columns https://laravel.com/docs/10.x/migrations#creating-columns
Column Types https://laravel.com/docs/10.x/migrations#available-column-types
Column Modifiers [ie: ->nullable() ] https://laravel.com/docs/10.x/migrations#available-column-types
Dropping Columns https://laravel.com/docs/10.x/migrations#dropping-columns
Creating Indexes https://laravel.com/docs/10.x/migrations#creating-indexes