Laravel Change Table or Column Name with Data Type Tutorial

In this tutorial you will learn about the Laravel Change Table or Column Name with Data Type Tutorial and its application with practical example.

In this Laravel Change Table or Column Name with Data Type Tutorial I will show you how change column name or change column type with laravel migration. In this article I will also show you how to rename column name in laravel migration. You will also learn how to change data type in laravel migration. In this example we will be using “doctrine/dbal” composer package.

Laravel Change Table or Column Name with Data Type Tutorial

In this step by step tutorial I will demonstrate you how to change column name or  how to change column data type in laravel migration.

Create Laravel Application

Create Model

Add the table values for migration in migrations/timestamp_create_students_table file:

Run laravel migration command:

Install DBAL Package

In this step we will install doctrine/dbal composer package. Please use the following command to install doctrine/dbal package.

Rename Laravel Column Name with Migration

In this example we will change column name “gender” to “subjects” so run command to create a new migration file:

Add the code in newly created rename_gender_in_students_table.php file:

Run the below command to change or rename the column value gender to subjects:

Update Data Type with Laravel Migration

Now we will change the data type using laravel migration.

In this tutorial we have learn about the Laravel Change Table or Column Name with Data Type Tutorial and its application with practical example. I hope you will like this tutorial.