Adding a column to an existing table – Laravel

Adding a column to an existing table – Laravel

For example we forgot to add the column password to the table users, and we already have inserted datas in the table. The solution is to

1.we build the migration:

php artisan make:migration add_password_to_users –table=users

2.add to the file the column: $table->string(‘password’);

public function up(){
Schema::table(‘users’, function (Blueprint $table) {
$table->string(‘password’);
});
}

3. migrate

php artisan migrate