Answers for "Migrations -How to add new columns to existing tables #"

PHP
3

add a new column to existing table in a migration

// for Laravel 5+
php artisan make:migration add_email_to_users_table --table=users

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

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

php artisan migrate
Posted by: Guest on January-01-2021
5

add new column in existing migration

php artisan make:migration create_users_table --create=users

php artisan make:migration add_votes_to_users_table --table=users
Posted by: Guest on July-18-2020

Code answers related to "Migrations -How to add new columns to existing tables #"

Browse Popular Code Answers by Language