Laravel

HOW TO ADD A NEW COLUMN TO EXISTING DATABASE [LARAVEL]

First of all make a new migration

php artisan make:migration add_mobile_to_userinfo

2. put this code in up() function

public function up()
{
Schema::table('users', function($table) {
$table->integer('mobile');
});
}

 

3. put this code in down() function

public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('mobile');
});
}

 

4. Migrate the databse

php artisan migrate

 

5. Do not forget to rollback

php artisan migrate:rollback;

 

jaminrai

Share
Published by
jaminrai

Recent Posts

Skype Closes Its Doors After 20 Years: A Look Back and the Apps That Faded with It

After 20 years of transforming global communication, Skype has officially ceased operations. Microsoft, which purchased…

7 days ago

The Duck and the Tortoise: A Tale of Patience and Teamwork

In a serene forest by the edge of a sparkling lake, there lived a cheerful…

1 month ago

10 Smart Strategies for a Secure and Enjoyable Retirement

Retiring comfortably is a goal many aspire to achieve, and with the right strategies, it’s…

1 month ago

Troubleshooting a Slow Computer

Is your computer running frustratingly slow? Don't worry; you're not alone in facing this common…

1 month ago

The Clever Fox and the Greedy Crow

Once, in a sunny forest, Fox and Crow were friends. One day, Crow found a…

1 month ago