Reputation: 8448
I use 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 run migrate,
$\> php artisan migrate
gives me this error!
[RuntimeException] Changing columns for table "news" requires Doctrine DBAL; install "doctrine/dbal".
what do i do?
Upvotes: 4
Views: 8762
Reputation: 8448
Warning: Use this method only when you are sure to loose all the values of that column and can have fresh values in it.
But if you want to preserve then this is not the right solution for you.
/**
* 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');
});
}
Upvotes: 5
Reputation: 121
according to laravel docs. You must install doctrine/dbal first if you are using ->change()
function.
Type composer require doctrine/dbal
in your terminal
Upvotes: 6
Reputation: 453
Seems like you're missing a dependency.
Install it with composer:
composer require doctrine/dbal
Upvotes: 4