If you want to change the columns name of an existing table, at first you need to write the following way. Suppose we have a table name users . So we need to run the following command first.
php artisan make:migration rename_description_to_content_on_users_table --table=users
then, a new migration file will be created. Let's say, there is a column name description. I want to change this name to 'bio'. So now, I need to edit the migration file like this.
Schema::table('users', function (Blueprint $table) {
//
$table->renameColumn('description', 'bio');
});
Then run, php artisan migrate command. And done!
Thanks. Happy coding!
Top comments (0)