Reputation: 49
I am having a problem in Laravel 5.3.
It won't allow me to drop a column from an existing table. I have run 'composer require doctrine/dbal' and that worked fine, but my column will not delete.
My add_column_to_table code:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddColumnToTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table)
{
$table->string('avatar')->default('default.pngs');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function ($table)
{
$table->dropColumn('avatar');
});
}
}
Thanks
Upvotes: 0
Views: 1822
Reputation: 1387
You should rollback your migration:
php artisan migrate:rollback
But make sure that column is empty on your table.
Upvotes: 0
Reputation:
Try this:
public function down()
{
Schema::table('users', function (Blueprint $table)
{
$table->dropColumn('avatar');
});
}
}
Upvotes: 0
Reputation: 3582
To drop the column you need to rollback the migration in the following manner
php artisan migrate:rollback
Upvotes: 1