Answers for "how to add column and migration in database first"

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

Code answers related to "how to add column and migration in database first"

Browse Popular Code Answers by Language