Hello Everyone,
Today, we will discuss about how to add an extra column in migration after creating a table.
First time we create a table's migration & execute migration command. After this , we realize that we have to add a new column in table.
For this, we can modify table by this easy way.
Firstly run this command for create a new migration file.
php artisan make:migration add_column_name_in_users_table
It will create a new file in migration file. Write in its up() function the following lines.
Schema::table('users', function ($table) {
$table->string('column_name');
});
and in down() function write the following lines:
Schema::table('users', function ($table) {
$table->drop_column('column_name');
php artisan make:migration add_column_name_in_users_table
No comments:
Post a Comment