Changing column type using laravel migration using Doctrine DBAL gives error

I am using Laravel 5.2, Php7, Apache, Windows

My migration file is "2016_03_30_095234_alter_date_update_news_table.php"

class AddSlugUpdateNewsTable extends Migration
{
    /**
     * Run the migrations.
     * php artisan make:migration add_slug_update_news_table
     * @return void
     */
    public function up()
    {
        Schema::table('news', function (Blueprint $table) {
            $table->date('slug')->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('news', function (Blueprint $table) {
            $table->dateTime('slug')->change();
        });
    }
}

But after starting migrate,

$\> php artisan migrate

gives me this error !

[RuntimeException] Changing the columns for the news table requires the DBAL Doctrine; set doctrine / dbal.

What am I doing?

+4
source share
3 answers
/**
 * Run the migrations.
 * php artisan make:migration alter_date_update_news_table
 * @return void
 */
public function up()
{
    Schema::table('news', function (Blueprint $table) {
        $table->dropColumn('date');
    });
    Schema::table('news', function (Blueprint $table) {
        $table->date('date')->after('image');
    });        
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('news', function (Blueprint $table) {
        $table->dropColumn('date');
    });
    Schema::table('news', function (Blueprint $table) {
        $table->dateTime('date')->after('image');
    });  
}
+1
source

laravel docs. doctrine/dbal, ->change().

composer require doctrine/dbal

+4

It seems like you are lacking in addiction.

Install it using the composer:

composer require doctrine/dbal
+2
source

All Articles