Categories: 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

Evolution History of computer Technology

Evolution History of computer Technology (HISTORY OF COMPUTER) Evolution of computer is a study of…

3 weeks ago

Maturity of Enterprise Architecture Practice

Maturity of Enterprise Architecture Practice Maturity of Enterprise Architecture Practice   DOWNLOAD

2 months ago

Computer Science Project Report Guidelines and Sample

Guidelines (Click Below to Download) SAMPLE 1 SAMPLE 2

8 months ago