How to add new field in laravel 6 table using migration

Run this command to create a new migration file. 

php artisan make:migration <Filename> --table="<tableName>"
php artisan make:migration add_paid_to_users --table="users"

This will add the up and down method content automatically:

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('users', function (Blueprint $table) {
        //
    });
}

Source : https://stackoverflow.com/questions/16791613/laravel-add-a-new-column-to-existing-table-in-a-migration

No comments:

Post a Comment

Pages