how to change migration witouh chnage an other laravel code example

Example 1: how to migrate new column without empty the table in laravel

Use below command to modify the existing table

php artisan make:migration add_shipped_via_and_terms_colums_to_purchase_orders_table --table=purchase_orders
use --create for creating the new table and --table for modifying the existing table.

Now a new migration file will be created. Inside the up() function in this file add these line

Schema::table('purchase_orders', function(Blueprint $table){
    $table->string('shipped_via');
    $table->string('terms');
});
And then run php artisan migrate

Example 2: how to migrate new column without empty the table in laravel

php artisan make:migration add_shipped_via_and_terms_colums_to_purchase_orders_table --table=purchase_orders

Tags:

Php Example