Answers for "migration change add column type"

PHP
2

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
0

update column type laravel migration

$table-><column_type>('<column_name>')->change();
Posted by: Guest on January-11-2022

Code answers related to "migration change add column type"

Browse Popular Code Answers by Language