add new column in laravel migration

add another field in existing migration laravel
php artisan make:migration add_paid_to_users_table --table=users
add column to migration laravel
class AddProfileToUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('profile')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('shop_users', function (Blueprint $table) {
$table->dropColumn(['profile']);
});
}
}
add column to migration laravel
php artisan make:migration add_profile_to_users
add new column in laravel migration
Schema::table('table_name', function (Blueprint $table) {
$table->string('column_name', 255)->nullable()->after('previous_column_name');
});
add new column in existing table in laravel migration
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('paid');
});
}
add new column in existing table in laravel migration
public function up()
{
Schema::table('users', function($table) {
$table->integer('paid');
});
}

Leave a Comment