Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To modify several column names within a single migration using Laravel 5.0, you can use the change method along with multiple table methods in the up function of the migration file. Here is an example:

public function up()
{
    Schema::table('users', function ($table) {
        $table->renameColumn('name', 'first_name');
        $table->renameColumn('email', 'contact_email');
    });
}

In this example, we are modifying the column names of name and email within the users table. We first use the renameColumn method to rename the name column to first_name, and then rename the email column to contact_email.

Note that you should also create a corresponding down function to revert these changes if needed:

public function down()
{
    Schema::table('users', function ($table) {
        $table->renameColumn('first_name', 'name');
        $table->renameColumn('contact_email', 'email');
    });
}