Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #column #existing #table #migration
ADD COMMENT
Topic
Name
6+6 =