We recently made a switch of service provider such that multiple columns in a DB table for this project will need to be renamed.
I am aware of this post which shows how to rename 1 column from 1 table:
php artisan migrate:make rename_stk_column --table="YOUR TABLE" --create
Is there a way to execute this same migration with multiple columns ? (1 migration, not more than 1...trying to minimize number of migration files created)
You can just add multiple renameColumn(); statements for each column that needs to be updated in that given table. Just need to come up with a whatever name you guys/gals use for your migration files.
Just a sample of what I ran
class MultipleColumnUpdate extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function ($table) {
$table->renameColumn('name', 'user_name');
$table->renameColumn('email', 'work_email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function ($table) {
$table->renameColumn('user_name', 'name');
$table->renameColumn('work_email', 'email');
});
}
}